need to include pcre2 static library in my CMake project.
... include_directories(SupportFiles/OSLinux/pcre2) ... add_library(libpcre2 STATIC IMPORTED GLOBAL) find_library(libpcre2_path NAMES libpcre2-32.a HINTS ${CMAKE_SOURCE_DIR}/SupportFiles/OSLinux/pcre2/ REQUIRED NO_CMAKE_SYSTEM_PATH) message(">>>>>> libpcre2_path = ${libpcre2_path}") set_property(TARGET libpcre2 PROPERTY IMPORTED_LOCATION ${libpcre2_path}) target_link_libraries(appservicehttpmodule PRIVATE libpcre2) ...
Library was found in my project and no CMake errors are.
#define PCRE2_CODE_UNIT_WIDTH 32 #include "pcre2.h" ... pcre2_code *pcode = pcre2_compile(...)
get an error :
/usr/bin/ld: CMakeFiles/UnitTest.dir/test.cpp.o: in function `moduleTest_pcre2Presence_Test::TestBody()': /home/.../GoogleTest/test.cpp:248: undefined reference to `pcre2_compile_32'
What is wrong? Why this lib is not linked?
Thanks in advance.
(I don't have enough reputation to leave comments :( )
The linker error seems to be from a separate executable (a unit test). Does it have libpcre2
added as a dependency (using target_link_libraries()
)?