2

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?

baziorek
  • 2,502
  • 2
  • 29
  • 43

2 Answers2

7

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.
Osyotr
  • 784
  • 1
  • 7
  • 20
1

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

Headlein
  • 11
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 27 '23 at 09:54