baziorek
baziorek

Reputation: 2684

vcpkg how to edit package file when compilation fails when installing package?

I'm installing dependencies for some project which downloads dependencies with vcpkg (the project is Hyperledger Iroha, but it does not matter). Unfortunately when compiling dependencies with my compiler (g++ 12.1.0) one of packages (abseil) is not compiling.

The reason why it is not compiling is easy to fix in code - just one line to change.

The line is pointed by cmake:

CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:146 (message):
    Command failed: /usr/bin/cmake --build . --config Debug --target install -- -v -j13
    Working Directory: /home/agh/Pulpit/blockchain/internship2022/iroha/vcpkg-build/buildtrees/abseil/x64-linux-dbg
    See logs for more information:
      /home/agh/Pulpit/blockchain/internship2022/iroha/vcpkg-build/buildtrees/abseil/install-x64-linux-dbg-out.log

and the error is:

/home/agh/Pulpit/blockchain/internship2022/iroha/vcpkg-build/buildtrees/abseil/src/ca9688e9f6-e4cda1d679.clean/absl/debugging/failure_signal_handler.cc:139:32: error: no matching function for call to ‘max(long int, int)’
  139 |   size_t stack_size = (std::max(SIGSTKSZ, 65536) + page_mask) & ~page_mask;
      |                        ~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/12.1.0/algorithm:60,

The reason is easy to fix - I just need to change one line to fix this. Unfortunately when I'm changing the line of code and then after rerunning:

vcpkg install abseil

my changes are being removed before compilation. I found option which should help: --editable, but it is happening again.

I would like to ask what is more professional (but still fast) way to change files, which are being build with vcpkg and containing errors?


The one solution which I found is that I can edit package: -- Using cached /home/agh/Pulpit/blockchain/internship2022/iroha/vcpkg-build/downloads/abseil-abseil-cpp-997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz when I edit the package I see error:

          File path: [ /home/agh/Pulpit/blockchain/internship2022/iroha/vcpkg-build/downloads/abseil-abseil-cpp-997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz ]
      Expected hash: [ bdd80a2278eef121e8837791fdebca06e87bfff4adc438c123e0ce11efc42a8bd461edcbbe18c0eee05be2cd6100f9acf8eab3db58ac73322b5852e6ffe7c85b ]
        Actual hash: [ cf8bb1676d2fcba8bdd4bc30e2060bc5552a348d6e192561aec2763460120b10dcb86e29efe60d972d4b241783563bc8067381c48209daee4ecc429786ef6bba ]

so I can edit file containing the hash: ports/abseil/portfile.cmake


Another solution is to run proper cmake of the abseil project with VERBOSE=1, then copy failing build commands after that edit files and rerun commands.


I know that my solutions are quite dirty so I would like to know if there is cleaner way to solve problem - how to edit source code of a library when it is not compiling when we use vcpkg package manager?

Upvotes: 2

Views: 2363

Answers (2)

Headlein
Headlein

Reputation: 11

Here u have more simply way. Im used for custom code changed for ffmpeg using and then build with vcpkg.

Rebuild vcpkg without installing again

Upvotes: 1

Osyotr
Osyotr

Reputation: 1152

This is how I do it:

  1. Run install with --editable
vcpkg install abseil --editable
  1. Initialize git repo in source dir:
cd buildtrees/abseil/src/_random_string_/
git init .
git add .
git commit -m "init"
  1. Patch the library
  2. Verify the library builds by calling install with --editable again
vcpkg install abseil --editable
  1. Create patch from changes (or commits)
git diff > fix_build.patch
  1. Copy patch into port dir and adjust portfile.cmake
vcpkg_from_github(
    REPO google/abseil
    ...
    PATCHES fix_build.patch # <-- this is our patch
)
  1. Copy the port directory into your project's overlay-ports dir. -OR- Update port version, submit it into your custom registry.
  2. (optional, but appreciated) Create PR in upstream and vcpkg main repo.

Upvotes: 9

Related Questions