trailofbits / uthenticode

A cross-platform library for verifying Authenticode signatures
https://trailofbits.github.io/uthenticode/
MIT License
136 stars 33 forks source link

Unable to build from source using README.md instructions #45

Closed scudette closed 3 years ago

scudette commented 3 years ago

This might be a noob question but I am unable to build from source using the instructions. I am not very familiar with cmake or vcpkg so maybe this is the issue (it has been a while since i fought with c++).

I installed vcpkg from source and built it fine, then it seems to install pe-parse correctly, but when trying to build uthenticode it cant find it and i cant figure out how to tell it where it is installed.

mic@devbox:~/projects/uthenticode$ ~/projects/vcpkg/vcpkg install pe-parse
Computing installation plan...
The following packages are already installed:
    pe-parse[core]:x64-linux -> 1.2.0
Package pe-parse:x64-linux is already installed

Total elapsed time: 47.66 us

The package pe-parse:x64-linux provides CMake targets:

    find_package(pe-parse CONFIG REQUIRED)
    target_link_libraries(main PRIVATE pe-parse::pe-parser-library)

mic@devbox:~/projects/uthenticode$ mkdir build && cd build
mic@devbox:~/projects/uthenticode/build$ cmake ..
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at src/CMakeLists.txt:5 (find_package):
  By not providing "Findpe-parse.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "pe-parse",
  but CMake did not find one.

  Could not find a package configuration file provided by "pe-parse" with any
  of the following names:

    pe-parseConfig.cmake
    pe-parse-config.cmake

  Add the installation prefix of "pe-parse" to CMAKE_PREFIX_PATH or set
  "pe-parse_DIR" to a directory containing one of the above files.  If
  "pe-parse" provides a separate development package or SDK, be sure it has
  been installed.

-- Configuring incomplete, errors occurred!
See also "/home/mic/projects/uthenticode/build/CMakeFiles/CMakeOutput.log".
scudette commented 3 years ago

Sorry for this - i figured it out. I first needed to install vcpkg properly:

mic@devbox:~/projects/uthenticode/build$ ~/projects/vcpkg/vcpkg integrate install
Applied user-wide integration for this vcpkg root.

CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=/home/mic/projects/vcpkg/scripts/buildsystems/vcpkg.cmake"
mic@devbox:~/projects/uthenticode/build$ cmake -DCMAKE_TOOLCHAIN_FILE=/home/mic/projects/vcpkg/scripts/buildsystems/vcpkg.cmake ..

From a clean build directory worked to properly configure the project and it built then.

woodruffw commented 3 years ago

Thanks for posting your solution! Yep, you need to configure CMake to get its packages from the vcpkg toolchain. It's a little annoying, but you should only need to do it once per CMake build (or set it globally in your environment).

I'd be happy to accept a PR that tweaks the README slightly to include a reference to CMAKE_TOOLCHAIN_FILE 😄