CMake build error: undefined reference to 'deflateEnd' - c++

I'm trying to use zlib in my project. The CMakeLists.txt is as follows:
cmake_minimum_required(VERSION 3.5)
project(cmake-demo LANGUAGES CXX)
# The version number.
set(CMDemo_VERSION_MAJOR 0)
set(CMDemo_VERSION_MINOR 1)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(${PROJECT_SOURCE_DIR}/build/conan_paths.cmake)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/build)
find_package(uwebsockets)
#ZLIB
if(ZLIB_FOUND)
set(INC_DIRS ${INC_DIRS} ${ZLIB_INCLUDE_DIRS})
set(LINK_LIBS ${LINK_LIBS} ${ZLIB_LIBS})
endif()
# Global approach
if(uwebsockets_FOUND)
set(INC_DIRS ${INC_DIRS} ${uwebsockets_INCLUDE_DIRS})
set(LINK_LIBS ${LINK_LIBS} ${uwebsockets_LIBS})
endif()
#libuv
if(libuv_FOUND)
set(INC_DIRS ${INC_DIRS} ${libuv_INCLUDE_DIRS})
set(LINK_LIBS ${LINK_LIBS} ${libuv_LIBS})
endif()
#usockets
if(usockets_FOUND)
set(INC_DIRS ${INC_DIRS} ${usockets_INCLUDE_DIRS})
set(LINK_LIBS ${LINK_LIBS} ${usockets_LIBS})
endif()
include_directories(${INC_DIRS})
add_executable(${PROJECT_NAME} main.cpp)
message("libs=${LINK_LIBS}")
target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
#output of message("${LINK_LIBS}")
C:/ProgramData/Miniconda3/Library/lib/z.lib;C:/Users/Sunway/.conan/data/libuv/1.41.0/_/_/package/9965605309592d7e617ec929633249a2031e4263/lib/libuv_a.a;C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/a24f5291464b4270092bce2e738cbf9f3cd53bb7/lib/libuSockets.a
I'm sure that ${LINK_LIBS} is correct, but it still doesn't work:
CMakeFiles/cmake-demo.dir/main.cpp.obj: In function `ZN3uWS15DeflationStreamD1Ev':
C:/Users/Sunway/.conan/data/uwebsockets/19.2.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/uWebSockets/PerMessageDeflate.h:186: undefined reference to `deflateEnd'
os: Windows10 x64
IDE: QtCreator4.14.2
compiler: MinGW 32-bit

The thing is, that you have to set the path to the library file as the target_link_libraries argument.
According to the documentation, if you want to link the library, each argument of target_link_libraries can be:
A library target name
A full path to a library file (e.g. /usr/lib/foo.so)
A plain library name (e.g. foo)
In your case I suggest you to add the complete path to the library.
I don't have all the code of your project, so I suggest you consider this minimal example:
add_executable(test main.cpp)
SET (ZLIB_ROOT "/tmp/zlib")
SET (ZLIB_INCLUDE_DIR "/tmp/zlib/include/")
SET (ZLIB_LIBRARY "/tmp/zlib/lib/libz.so.1.2.11")
FIND_PACKAGE (ZLIB REQUIRED)
MESSAGE (" zlib version major is " ${ZLIB_VERSION_MAJOR})
MESSAGE (" zlib version minor is " ${ZLIB_VERSION_MINOR})
MESSAGE (" zlib include is " ${ZLIB_INCLUDE_DIR})
MESSAGE (" zlib libraries are " ${ZLIB_LIBRARIES})
target_link_libraries(test ${ZLIB_LIBRARIES})
After downloading the latest zlib release and installing it in /tmp, everything works as expected.
Update: as #uilianries mentioned, since you are using conan, you have cmake_find_package generator that defines variables with all the necessary paths. So you don't need to set the paths in CMakeLists.txt manually.

It is because the libzlib.a is for x86_64 while the compiler is MinGW-32bit; I solved the problem by execute the command
$conan install .. --build=missing --pr=x86_32
the x86_64 is a profile(x86) generated by conan.

Related

mingw-g++ can't find include directory

I'm trying to compile my program for Windows, on Linux, so I installed the w64-mingw32 compiler via the Debian package manager. I made a separate cmakelists file where I chose x86_64-w64-mingw32-g++ as the compiler. When I try to run my build script, I get errors where it can't find the libraries that I use in my project. This is my cmake file:
cmake_minimum_required (VERSION 3.5)
if (POLICY CMP0072)
cmake_policy(SET CMP0072 NEW)
else (NOT POLICY CMP0072)
message(STATUS "Could not use CMP0072 policy")
endif(POLICY CMP0072)
project(opengl-test LANGUAGES CXX)
set(CMAKE_CXX_COMPILER "/usr/bin/x86_64-w64-mingw32-g++")
set(CMAKE_C_COMPILER "/usr/bin/x86_64-w64-mingw32-gcc")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(GNUInstallDirs)
set(CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32")
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set (source_dir "${PROJECT_SOURCE_DIR}/src/")
set (base_dir "${source_dir}/base/")
set (IMGUI_DIR "/usr/include/imgui")
set(GCC_COVERAGE_LINK_FLAGS "")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
file(GLOB source_files "${source_dir}/*.cpp")
file(GLOB_RECURSE base_files "${base_dir}/*.cpp")
file(GLOB imgui_files "${IMGUI_DIR}/*.cpp")
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
add_executable(${PROJECT_NAME} ${source_files} ${imgui_files} ${base_files})
#target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
message(STATUS ${OPENGL_LIBRARIES})
target_link_libraries(${PROJECT_NAME} PUBLIC ${GLFW_LIBRARIES} ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES})
A lot of the code in the cmakelists file doesn't do anything because I was trying to make it work but nothing was working. I left it in so you can see what I've tried and doesn't work.
I can run this and it compiles, but I get a linker error.
CMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.
-- /usr/lib/x86_64-linux-gnu/libOpenGL.so/usr/lib/x86_64-linux-gnu/libGLX.so/usr/lib/x86_64-linux-gnu/libGLU.so
-- Configuring done
CMake Warning at CMakeLists.txt:38 (add_executable):
Cannot generate a safe runtime search path for target opengl-test because
files in some directories may conflict with libraries in implicit
directories:
runtime library [libGLEW.so.2.1] in /usr/lib64 may be hidden by files in:
/usr/lib/x86_64-linux-gnu
Some of these libraries may not be found correctly.
-- Generating done
-- Build files have been written to: /home/user/Documents/CPP-Stuff/Scrap-Framework
[29/29] Linking CXX executable opengl-test
FAILED: opengl-test
: && /usr/bin/x86_64-w64-mingw32-g++ -g CMakeFiles/opengl-test.dir/src/main.cpp.o CMakeFiles/opengl-test.dir/usr/include/imgui/imgui.cpp.o CMakeFiles/opengl-test.dir/usr/include/imgui/imgui_demo.cpp.o CMakeFiles/opengl-test.dir/usr/include/imgui/imgui_draw.cpp.o CMakeFiles/opengl-test.dir/usr/include/imgui/imgui_impl_glfw.cpp.o CMakeFiles/opengl-test.dir/usr/include/imgui/imgui_impl_opengl3.cpp.o CMakeFiles/opengl-test.dir/usr/include/imgui/imgui_tables.cpp.o CMakeFiles/opengl-test.dir/usr/include/imgui/imgui_widgets.cpp.o CMakeFiles/opengl-test.dir/src/base/Application/Application.cpp.o CMakeFiles/opengl-test.dir/src/base/Application/Window.cpp.o CMakeFiles/opengl-test.dir/src/base/GL/Cubemap.cpp.o CMakeFiles/opengl-test.dir/src/base/GL/Texture.cpp.o CMakeFiles/opengl-test.dir/src/base/GL/UniformBuffer.cpp.o CMakeFiles/opengl-test.dir/src/base/GL/VertexBuffer.cpp.o CMakeFiles/opengl-test.dir/src/base/Input/Input.cpp.o CMakeFiles/opengl-test.dir/src/base/Model/Material.cpp.o CMakeFiles/opengl-test.dir/src/base/Model/Mesh.cpp.o CMakeFiles/opengl-test.dir/src/base/Model/Model.cpp.o CMakeFiles/opengl-test.dir/src/base/Model/ModelLoader.cpp.o CMakeFiles/opengl-test.dir/src/base/Renderer/FPSCamera.cpp.o CMakeFiles/opengl-test.dir/src/base/Renderer/MaterialManager.cpp.o CMakeFiles/opengl-test.dir/src/base/Renderer/Renderbuffer.cpp.o CMakeFiles/opengl-test.dir/src/base/Renderer/Renderer.cpp.o CMakeFiles/opengl-test.dir/src/base/Scene/Lights.cpp.o CMakeFiles/opengl-test.dir/src/base/Scene/Scene.cpp.o CMakeFiles/opengl-test.dir/src/base/Scene/Skybox.cpp.o CMakeFiles/opengl-test.dir/src/base/Shader/Shader.cpp.o CMakeFiles/opengl-test.dir/src/base/Shader/ShaderManager.cpp.o -o opengl-test -Wl,-rpath,/usr/lib/x86_64-linux-gnu -lglfw /usr/lib/x86_64-linux-gnu/libOpenGL.so /usr/lib/x86_64-linux-gnu/libGLX.so /usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib64/libGLEW.so && :
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lglfw
/usr/bin/x86_64-w64-mingw32-ld: /usr/lib/x86_64-linux-gnu/libOpenGL.so: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
The include files are located in /usr/include/, but I also put them in /usr/x86_64-w64-mingw32/include/.
Does anyone know how I can fix this, or a better way to compile for Windows on Linux?
You need to build the libraries you're using for Windows, or find prebuilt ones, e.g. in MSYS2 repositories. You also need to point CMake to those libraries.
I've made Quasi-MSYS2 to automate both.
Example usage:
# Install Clang, LLD, Wine. Then:
git clone https://github.com/holyblackcat/quasi-msys2
cd quasi-msys2/
make install _gcc _glfw _glew
env/shell.sh
# Build
cd your/project/location
mkdir build
cd build
cmake ..
make
# Run with Wine
./a.exe
Here is CMakeLists.txt I've used. I removed the cross-compilation stuff (which is handled automatically).
cmake_minimum_required (VERSION 3.5)
if (POLICY CMP0072)
cmake_policy(SET CMP0072 NEW)
else (NOT POLICY CMP0072)
message(STATUS "Could not use CMP0072 policy")
endif(POLICY CMP0072)
project(opengl-test LANGUAGES CXX)
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
add_executable(a 1.cpp)
message(STATUS ${OPENGL_LIBRARIES})
target_link_libraries(a PUBLIC ${GLFW_LIBRARIES} ${OPENGL_LIBRARIES} GLEW::GLEW)
I also put them in /usr/x86_64-w64-mingw32/include/
You shouldn't modify system include directories manually. Leave them to your package manager.

Encounter issue with `find_package` command in Visual Studio CMake

I'm operating under a new learning curve here with c++ and using CMake in Visual Studio. Here is the partial code up until the point where I receive the error:
project(libfranka
VERSION 0.8.0
LANGUAGES CXX
)
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(MSVC)
add_compile_options(/W0)
else()
add_compile_options(-Wall -Wextra)
endif()
set(THIRDPARTY_SOURCES_DIR "${CMAKE_SOURCE_DIR}/3rdparty" CACHE PATH
"Directory for third-party sources")
## Dependencies
find_package(Poco REQUIRED COMPONENTS Net Foundation)
find_package(Eigen3 REQUIRED)
Once it hits the first find_package is where I encounter the error:
Here is the code within FindPoco.cmake.
find_package(Poco COMPONENTS ${Poco_FIND_COMPONENTS} CONFIG QUIET)
if(Poco_FOUND)
return()
endif()
find_path(Poco_INCLUDE_DIR Poco/Poco.h)
mark_as_advanced(FORCE Poco_INCLUDE_DIR)
foreach(component ${Poco_FIND_COMPONENTS})
set(component_var "Poco_${component}_LIBRARY")
find_library(${component_var} Poco${component})
mark_as_advanced(FORCE ${component_var})
if(${component_var})
set(Poco_${component}_FOUND TRUE)
list(APPEND Poco_LIBRARIES ${component})
if(NOT TARGET Poco::${component})
add_library(Poco::${component} SHARED IMPORTED)
set_target_properties(Poco::${component} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${Poco_INCLUDE_DIR}
IMPORTED_LOCATION ${${component_var}}
)
endif()
endif()
endforeach()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Poco
FOUND_VAR Poco_FOUND
REQUIRED_VARS Poco_INCLUDE_DIR Poco_LIBRARIES
VERSION_VAR Poco_VERSION
HANDLE_COMPONENTS
)
I installed poco using vcpkg in a directory titled vcpkg. Within the vcpkg directory is the libfranka directory, which houses the CMakeLists.txt file that I compile in Visual Studio. Here is an image of that directory:
Finally, here is the tutorial that I am using: https://frankaemika.github.io/docs/installation_windows.html#building-from-source
EDIT:
Per the link I followed the instructions for solving the build dependencies and here is an image of that:
Then I ran the CMakeLists.txt again and in the CMake Settings this is what I see:
Note also that I ran through the install of poco again and I noticed this and am unsure if it could be the source of the problem or if it means nothing (again, this was the out put after running vcpkg install poco):
After this I still receive the same error.
Does anyone see what it is that I am doing incorrectly?
Thank you!

Linking external HDFql library in CMake

I have downloaded the HDFql library and put the whole lot in /usr/local/ in my linux system. I now wish to use this library in a ROS application, so I have tried to link it in my CMakeList, which looks as following:
cmake_minimum_required(VERSION 3.2)
project(data_generator)
add_compile_options(-std=c++11)
set(CMAKE_BUILD_TYPE Release) # Release, RelWithDebInfo
set(CMAKE_CXX_FLAGS "-std=c++11 -pthread ${CMAKE_CXX_FLAGS}")
find_package(catkin_simple REQUIRED)
catkin_simple(ALL_DEPS_REQUIRED)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
set(HDFQL_ROOT "/usr/local/hdfql-2.1.0")
include_directories(${HDFQL_ROOT}/include)
find_library(HDFQL_LIB HDFql)
if (HDFQL_LIB)
message("Library(HDFQL_LIB) found in ${HDFQL_LIB}")
else()
message(FATAL_ERROR "Library (HDFQL_LIB) not found")
endif()
cs_add_executable(
${PROJECT_NAME}
src/main.cpp
src/data_create.cpp
src/event_definitions.cpp
)
target_include_directories(${PROJECT_NAME}
PUBLIC "${HDFQL_ROOT}/include"
)
target_link_libraries(${PROJECT_NAME}
${OpenCV_LIBRARIES}
${HDFQL_LIB}
)
# CMake Indexing
FILE(GLOB_RECURSE LibFiles "include/*")
add_custom_target(headers SOURCES ${LibFiles})
cs_install()
cs_export()
When I build this, it works fine and outputs the message:
Library(HDFQL_LIB) found in /usr/local/hdfql-2.1.0/lib/libHDFql.so
with the following in my main.cpp file:
#include <HDFql.hpp>
....
std::cout <<"HDFql version: " << HDFql::Version << std::endl;
the output is: HDFql version: 2.1.0.
However, as soon as I try to actually use functions of the library - for example:
#include <HDFql.hpp>
....
std::cout <<"HDFql version: " << HDFql::Version << std::endl;
HDFql::execute("CREATE FILE /home/user/test.h5");
I get the error:
main.cpp:(.text+0x1858): undefined reference to `HDFql::execute(char const*)'
This suggests to me that while CMake has no issue with the includes, it is having trouble linking the actual library (ie including the libHDFql.a/libHDFql.so files). Can anyone tell me what I'm doing wrong here?
Many thanks!
The problem was that I needed to include the library /usr/local/hdfql-2.1.0/wrapper/cpp/libHDFql.so, where I was using /usr/local/hdfql-2.1.0/lib/libHDFql.so. It's pretty maddening, since the reference manual doesn't make any mention of this and I spent way too long figuring this out. Ohwell, I hope this helps anyone else with this problem.
For reference, here is a minimal catkin-style CMakeLists that will work:
cmake_minimum_required(VERSION 3.2)
project(project_name)
add_compile_options(-std=c++11)
find_package(catkin_simple REQUIRED)
catkin_simple(ALL_DEPS_REQUIRED)
set(HDFQL_ROOT "path/to/hdfql-2.1.0")
include_directories(${HDFQL_ROOT}/include)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS "-std=c++11 -pthread ${CMAKE_CXX_FLAGS}")
cs_add_executable(
${PROJECT_NAME}
# your source file 1
# your source file 2
# ...
)
target_include_directories(${PROJECT_NAME}
PUBLIC "${HDFQL_ROOT}/include"
)
target_link_libraries(
${PROJECT_NAME}
${OpenCV_LIBRARIES}
)
target_link_libraries(
${PROJECT_NAME}
"${HDFQL_ROOT}/wrapper/cpp/libHDFql.so"
)
Of course the absolute paths aren't very pretty, the alternative is to add /usr/local/hdfql-2.1.0/lib to the environment variable CMAKE_PREFIX_PATH (eg export CMAKE_PREFIX_PATH="/usr/local/hdfql-2.1.0/lib:$CMAKE_PREFIX_PATH").

Build Application using libpam0g-dev with cmake

I'm trying to build a C++ application which uses the library libpamg0-dev.
I installed it with the following command on my elementaryOS VM.
apt-get install libpam0g-dev
When I try to compile the application, the compiler spits out the following errors:
undefined reference to `pam_start`
undefined reference to `pam_authenticate`
undefined reference to `pam_end`
My CMakeLists.txt looks like this:
cmake_minimum_required(VERSION 3.10)
project(application)
set(CMAKE_CXX_STANDARD 11)
INCLUDE_DIRECTORIES(/home/dnagl/dev/libs/restbed/distribution/include /usr/include/security)
LINK_DIRECTORIES(/home/dnagl/dev/libs/restbed/distribution/library /usr/lib/x86_64-linux-gnu)
add_executable(application main.cpp Utils/Json/Json.cpp Utils/Json/Json.h Utils/Stringhelper/Stringhelper.cpp Utils/Stringhelper/Stringhelper.h Utils/File/Filehelper.cpp Utils/File/Filehelper.h Utils/System/SystemHelper.cpp Utils/System/SystemHelper.h Controller/Info/InfoController.cpp Controller/Info/InfoController.h Rest/ResourceHandler/ResourceHandler.cpp Rest/ResourceHandler/ResourceHandler.h Controller/System/SystemController.cpp Controller/System/SystemController.h Rest/Log/RequestLogger.cpp Rest/Log/RequestLogger.h Controller/Authentication/AuthenticationController.cpp Controller/Authentication/AuthenticationController.h Controller/Log/LogController.cpp Controller/Log/LogController.h)
target_link_libraries(application restbed)
Maybe one of you knows how to link the library in the right way.
I have found a nice solution with find_package option from CMake. CMake provides a way to find packages/libraries with specified FindModule.cmake file.
A really good news is that there are a lot of existing module files. You can use this version to find PAM package on Linux. Put it to cmake/modules/ in your project folder and update your CMakeLists.txt:
cmake_minimum_required(VERSION 3.10)
project(restbed)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Notify CMake that we have module files to find packages/libs.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
find_package(PAM REQUIRED)
# Check if we found PAM.
if (NOT PAM_FOUND)
message(FATAL_ERROR "PAM library was not found.")
endif ()
# Source configuration.
include_directories(
${PAM_INCLUDE_DIR}
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
set(EXECUTABLE_NAME "application")
# Add sources to this project's executable.
add_executable(${EXECUTABLE_NAME}
"main.cpp"
"Utils/Json/Json.cpp"
"Utils/Json/Json.h"
"Utils/Stringhelper/Stringhelper.cpp"
"Utils/Stringhelper/Stringhelper.h"
"Utils/File/Filehelper.cpp"
"Utils/File/Filehelper.h"
"Utils/System/SystemHelper.cpp"
"Utils/System/SystemHelper.h"
"Controller/Info/InfoController.cpp"
"Controller/Info/InfoController.h"
"Rest/ResourceHandler/ResourceHandler.cpp"
"Rest/ResourceHandler/ResourceHandler.h"
"Controller/System/SystemController.cpp"
"Controller/System/SystemController.h"
"Rest/Log/RequestLogger.cpp"
"Rest/Log/RequestLogger.h"
"Controller/Authentication/AuthenticationController.cpp"
"Controller/Authentication/AuthenticationController.h"
"Controller/Log/LogController.cpp"
"Controller/Log/LogController.h"
)
target_link_libraries(${EXECUTABLE_NAME}
${PAM_LIBRARIES}
)
set_target_properties(${EXECUTABLE_NAME} PROPERTIES LINKER_LANGUAGE CXX)
Hope this helps!

Linux: a C++ library fails to link after recompiling

I had a https://github.com/simongog/sdsl-lite library installed on a remote Linux server. What I did was to create lib, include directories inside my home directory and then run the script as ./install.sh /my/home/dir, as indeed explained on the above page. I was able to do it once and successfully linked it to my other programs by using a CMakeLists.txt file as the one similar to the following:
cmake_minimum_required(VERSION 2.8)
set (CMAKE_CXX_STANDARD 14)
macro(use_cxx14)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -mcmodel=large")
endif ()
else ()
set (CMAKE_CXX_STANDARD 14)
endif ()
endmacro(use_cxx14)
use_cxx14()
# Locate GTest
link_directories(/my/home/dir/)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /my/home/dir/)
list(APPEND CMAKE_PREFIX_PATH "/my/home/dir/")
list(APPEND CMAKE_LIBRARY_PATH /my/home/dir/lib/)
INCLUDE_DIRECTORIES(/my/home/dir/include)
LINK_DIRECTORIES(/my/home/dir/lib)
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
# Link runTests with what we want to test and the GTest and pthread library
add_executable(runTests rs_bitvector_test.cpp)
# SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
# SET(BUILD_SHARED_LIBRARIES OFF)
# SET(CMAKE_EXE_LINKER_FLAGS "-static")
target_link_libraries(runTests sdsl ${GTEST_LIBRARIES} pthread)
(the server was missing C++14 but the name remains, although really I use the C++11 option)
Now I've changed a source file inside the previously downloaded location of the library and recompiled it. And now linking stopped working. What could be the reason? During re-compilation, the remote server kept telling me about some "modification time in the future" and "build may be incomplete". Is that the reason? What can be done?
EDIT: based off the suggestions in the comments, I removed the build directory (analog of make clean) and replaced it with that from the directory of the original bundle. Now, the timstamps issue is gone, but the linking still fails.
Funnily, after noticing that sdsl detected g++ 7.3 during installation while cmake was compiling using 4.8, I used https://cmake.org/Wiki/CMake_FAQ#How_do_I_use_a_different_compiler.3F to set the compiler to g++ 7.3 (using Method 3 in the above link), and it finally worked (still some issues with GTest, but it is OK).