SimonKagstrom / kcov

Code coverage tool for compiled programs, Python and Bash which uses debugging information to collect and report data without special compilation options
http://simonkagstrom.github.io/kcov/
GNU General Public License v2.0
720 stars 110 forks source link

Undefined reference to curl functions with libcurl-dev installed #355

Closed TheBlueMatt closed 3 years ago

TheBlueMatt commented 3 years ago

Our build script of kcov (which is copied from the example build script for Codecov.io, so I assume you may get this question a few times), is currently failing with undefined symbols to curl_easy, despite libcurl4-openssl-dev being installed on the machine. Is there some other package or dependency that needs to be installed that CMake isn't detecting?

CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
CMake Warning (dev) at /usr/local/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:426 (message):
  The package name passed to `find_package_handle_standard_args` (LIBBFD)
  does not match the name of the calling package (Bfd).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/FindBfd.cmake:79 (find_package_handle_standard_args)
  src/CMakeLists.txt:3 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found LIBBFD: /usr/lib/x86_64-linux-gnu/libbfd.so  
-- Target architectures: x86_64
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.58.0")  
-- Found DL: /usr/lib/x86_64-linux-gnu/libdl.so
-- Found M: /usr/lib/x86_64-linux-gnu/libm.so
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.1.1j")  
-- Found LibElf: /usr/lib/x86_64-linux-gnu/libelf.so  
CMake Warning (dev) at /usr/local/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:426 (message):
-- Found ElfUtils: /usr/lib/x86_64-linux-gnu/libdw.so  
  The package name passed to `find_package_handle_standard_args` (ElfUtils)
  does not match the name of the calling package (Elfutils).  This can lead
  to problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/FindElfutils.cmake:70 (find_package_handle_standard_args)
  src/CMakeLists.txt:139 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: /home/runner/work/rust-lightning/rust-lightning/kcov-master/build
Scanning dependencies of target kcov_system_lib
[  1%] Building CXX object src/CMakeFiles/kcov_system_lib.dir/engines/system-mode-binary-lib.cc.o
[  2%] Building CXX object src/CMakeFiles/kcov_system_lib.dir/utils.cc.o
[  3%] Building CXX object src/CMakeFiles/kcov_system_lib.dir/system-mode/registration.cc.o
[  5%] Linking CXX shared library libkcov_system_lib.so
[  5%] Built target kcov_system_lib
[  6%] Generating version.c
Scanning dependencies of target kcov-system-daemon
[  7%] Building CXX object src/CMakeFiles/kcov-system-daemon.dir/configuration.cc.o
[  8%] Building CXX object src/CMakeFiles/kcov-system-daemon.dir/dummy-solib-handler.cc.o
[ 10%] Building CXX object src/CMakeFiles/kcov-system-daemon.dir/engine-factory.cc.o
[ 11%] Building CXX object src/CMakeFiles/kcov-system-daemon.dir/engines/system-mode-file-format.cc.o
[ 12%] Building CXX object src/CMakeFiles/kcov-system-daemon.dir/engines/ptrace.cc.o
[ 14%] Building CXX object src/CMakeFiles/kcov-system-daemon.dir/engines/ptrace_linux.cc.o
[ 15%] Building CXX object src/CMakeFiles/kcov-system-daemon.dir/filter.cc.o
[ 16%] Building CXX object src/CMakeFiles/kcov-system-daemon.dir/gcov.cc.o
[ 17%] Building CXX object src/CMakeFiles/kcov-system-daemon.dir/main-system-daemon.cc.o
[ 19%] Building CXX object src/CMakeFiles/kcov-system-daemon.dir/parser-manager.cc.o
[ 20%] Building CXX object src/CMakeFiles/kcov-system-daemon.dir/system-mode/file-data.cc.o
[ 21%] Building CXX object src/CMakeFiles/kcov-system-daemon.dir/system-mode/registration.cc.o
[ 23%] Building CXX object src/CMakeFiles/kcov-system-daemon.dir/utils.cc.o
[ 24%] Building C object src/CMakeFiles/kcov-system-daemon.dir/version.c.o
[ 25%] Linking CXX executable kcov-system-daemon
CMakeFiles/kcov-system-daemon.dir/utils.cc.o: In function `escape_url(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/runner/work/rust-lightning/rust-lightning/kcov-master/src/utils.cc:536: undefined reference to `curl_easy_init'
/home/runner/work/rust-lightning/rust-lightning/kcov-master/src/utils.cc:541: undefined reference to `curl_easy_escape'
/home/runner/work/rust-lightning/rust-lightning/kcov-master/src/utils.cc:552: undefined reference to `curl_easy_cleanup'
collect2: error: ld returned 1 exit status
make[2]: *** [src/kcov-system-daemon] Error 1
src/CMakeFiles/kcov-system-daemon.dir/build.make:304: recipe for target 'src/kcov-system-daemon' failed
make[1]: *** [src/CMakeFiles/kcov-system-daemon.dir/all] Error 2
make: *** [all] Error 2
CMakeFiles/Makefile2:171: recipe for target 'src/CMakeFiles/kcov-system-daemon.dir/all' failed
Makefile:170: recipe for target 'all' failed
SimonKagstrom commented 3 years ago

Sorry, it's a regression from yesterday. The library used by kcov-system-daemon links with curl, and apparently it's enough for osx but maybe not for Linux. I've pushed a CMakeLists.txt change to explicitly link it to kcov-system-daemon as well.

SimonKagstrom commented 3 years ago

Closed with various build fixes, thanks for the report!