cmake ..
make
then failed to build.
the error message is as follows:
[ 96%] Building C object src/gui/curses/CMakeFiles/weechat-curses.dir/gui-curses-color.o
[ 97%] Building C object src/gui/curses/CMakeFiles/weechat-curses.dir/gui-curses-key.o
[ 97%] Building C object src/gui/curses/CMakeFiles/weechat-curses.dir/gui-curses-main.o
[ 98%] Building C object src/gui/curses/CMakeFiles/weechat-curses.dir/gui-curses-mouse.o
[ 99%] Building C object src/gui/curses/CMakeFiles/weechat-curses.dir/gui-curses-term.o
[100%] Building C object src/gui/curses/CMakeFiles/weechat-curses.dir/gui-curses-window.o
Linking C executable weechat-curses
../../core/libweechat_core.a(wee-network.o): In function `network_init':
wee-network.c:(.text+0x1c): undefined reference to `gcry_check_version'
wee-network.c:(.text+0x30): undefined reference to `gcry_control'
wee-network.c:(.text+0x44): undefined reference to `gcry_control'
collect2: ld returned 1 exit status
make[2]: *** [src/gui/curses/weechat-curses] Error 1
make[1]: *** [src/gui/curses/CMakeFiles/weechat-curses.dir/all] Error 2
make: *** [all] Error 2
my os is centos 5.3, which package i should in stall in order to build this software successfully?
Apparently you are trying to link an executable, missing libgcrypt library.
See http://www.gnu.org/software/libgcrypt/
I had the same issue and found this. Since I'm using Code Blocks I found:
Go to Settings> Compiler and Debugger
Linker Settings
Since the libraries are already installed --> Add the following Link Libraries:
/usr/local/lib/libgpg-error.so
/usr/local/lib/libgcrypt.so
This fixed the compiler errors. :)
On Ubuntu 15.04, with libgcrypt.h installed in /usr/include (by the repository package), I only had to change the compiler settings. This should work with Ubuntu 14.04/14.10, and probably w/ other Debians.
I'm on Code::Blocks, so my instructions are for that. See the documentation for more information.
Go to Settings -> Compiler... -> Global compiler settings
On the "Compiler settings" tab, click "Other options", and AT THE TOP of that, put 'libgcrypt-config --cflags\' (the ' should actually be a backtick, but SO has odd formatting...)
On the "Linker settings" tab, under "Other linker options:", AT THE TOP put 'libgcrypt-config --libs\' (again, with backticks instead of ').
Click OK and compile your project.
Related
I am trying to build a C++ library(https://github.com/ipkn/crow) on macOS 12.0.1(Monterey).
Since I am learning C++ since yesterday, I have no clue what to do next with error message like this:
ld: warning: dylib (/usr/local/lib/libboost_system-mt.dylib) was built for newer macOS version (12.0) than being linked (11.3)
ld: warning: dylib (/usr/local/lib/libboost_thread-mt.dylib) was built for newer macOS version (12.0) than being linked (11.3)
[ 19%] Built target example_chat
Consolidate compiler generated dependencies of target example_ssl
[ 23%] Building CXX object examples/CMakeFiles/example_ssl.dir/ssl/example_ssl.cpp.o
make[2]: *** No rule to make target `/usr/bin/openssl/lib', needed by `examples/example_ssl'. Stop.
make[1]: *** [examples/CMakeFiles/example_ssl.dir/all] Error 2
make: *** [all] Error 2
/usr/bin/openssl is actually the result when which openssl is executed
My question: As a toddler in C++, how to debug an error message like this? What I have to learn as prerequisites ?
I am using CMake to compile an application which uses the HSImage library on github. After installing with pip, the HSI library generates a shared library file, in my case it is created at /usr/src/HSI/HSI.cpython-36m-aarch64-linux-gnu.so
I am trying to link this library to my application with CMake, but the CMake find_library method is having some trouble finding the library. Here is the relevant part of my CMakeLists.txt file:
CMakeLists.txt
set(HSI_DIR /usr/src/HSI)
find_library(HSI_LIB HSI.cpython-36m-aarch64-linux-gnu PATHS ${HSI_DIR})
message(STATUS "HSI: ${HSI_LIB}") # outputs /usr/src/HSI/HSI.cpython-36m-aarch64-linux-gnu.so
add_executable(${TARGET_NAME} <sources...>)
target_link_directories(${TARGET_NAME} PUBLIC ${HSI_DIR})
target_link_libraries(${TARGET_NAME}
${HSI_LIB}
<other libs...>
-Wl,--unresolved-symbols=ignore-in-shared-libs
)
When building, this produces the following error message:
cd /home/nvidia/projects/HsiInference/build;/usr/local/bin/cmake --build "/home/nvidia/projects/HsiInference/build" --target hsi_inference_onnx -- ;
Scanning dependencies of target hsi_inference_onnx
[ 14%] Building CXX object CMakeFiles/hsi_inference_onnx.dir/targets/HsiInferenceOnnx/main_onnx.cpp.o
[ 28%] Building CXX object CMakeFiles/hsi_inference_onnx.dir/targets/HsiInferenceOnnx/HsiInferenceOnnx.cpp.o
[ 42%] Building CXX object CMakeFiles/hsi_inference_onnx.dir/src/ftpnano.cpp.o
[ 57%] Building CXX object CMakeFiles/hsi_inference_onnx.dir/src/getOptions.cpp.o
[ 71%] Building CXX object CMakeFiles/hsi_inference_onnx.dir/src/logger.cpp.o
[ 85%] Building CXX object CMakeFiles/hsi_inference_onnx.dir/src/utils.cpp.o
[100%] Linking CXX executable hsi_inference_onnx_debug
CMakeFiles/hsi_inference_onnx.dir/build.make:245: recipe for target 'hsi_inference_onnx_debug' failed
CMakeFiles/Makefile2:123: recipe for target 'CMakeFiles/hsi_inference_onnx.dir/all' failed
**/usr/bin/ld: cannot find -lHSI.cpython-36m-aarch64-linux-gnu**
**collect2: error: ld returned 1 exit status**
make[3]: *** [hsi_inference_onnx_debug] Error 1
make[2]: *** [CMakeFiles/hsi_inference_onnx.dir/all] Error 2
CMakeFiles/Makefile2:130: recipe for target 'CMakeFiles/hsi_inference_onnx.dir/rule' failed
make[1]: *** [CMakeFiles/hsi_inference_onnx.dir/rule] Error 2
Makefile:196: recipe for target 'hsi_inference_onnx' failed
make: *** [hsi_inference_onnx] Error 2
Build failed.
The important part:
/usr/bin/ld: cannot find -lHSI.cpython-36m-aarch64-linux-gnu
collect2: error: ld returned 1 exit status
From what I have gathered, target_link_libraries simply adds -l<library_name> to the link command, and -l<library_name> assumes that there is a file called lib<library_name>.so to link, which is not the case here. How can I get CMake to link the library properly despite the weird filename?
NOTE:
I am able to get the project to build by doing the following:
Delete the project's build directory to clear CMake caches
Rename the file or create a symbolic link to libhsi.so
Change CMakeLists.txt to find_library(HSI_LIB hsi PATHS ${HSI_DIR})
This changes the link command to -lhsi instead, which is able to find the renamed/soft-linked library file. HOWEVER, this is not ideal for me and the original question remains unanswered :)
For libraries with weird filename you should add : before the filename. Be careful, like mentioned in https://linux.die.net/man/1/ld : If namespec is of the form :filename, ld will search the library path for a file called filename, otherwise it will search the library path for a file called libnamespec.a (namespec is what comes after -l).
For your example you should replace ${HSI_LIB} in target_link_libraries by :${HSI_LIB}.so.
I'm currently having trouble in the following setup:
My main project has a subdirector that is a library. This library depends on a system library "triangle" (installed from source). The main project does use a file from the subdirectory.
Cmake of the main project (and the library) work fine.
Building the library works just fine.
(Either in it's own directory or after cmake in the main directory with
make subdir_lib compiles without problems)
This is where the problems starts.
Building the main project with make project fails. It happens during linking:
subdir/libsubdir_lib.a(Test.cpp.o): In function `Test::run()':
/home/mimre/workspace/tmp/cmake-problem/subdir/files/Test.cpp:34: undefined reference to `triangle_context_create'
/home/mimre/workspace/tmp/cmake-problem/subdir/files/Test.cpp:35: undefined reference to `triangle_context_options'
/home/mimre/workspace/tmp/cmake-problem/subdir/files/Test.cpp:42: undefined reference to `triangle_mesh_create'
/home/mimre/workspace/tmp/cmake-problem/subdir/files/Test.cpp:50: undefined reference to `triangle_context_destroy'
collect2: error: ld returned 1 exit status
CMakeFiles/cmake_problem.dir/build.make:95: recipe for target 'cmake_problem' failed
make[3]: *** [cmake_problem] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/cmake_problem.dir/all' failed
make[2]: *** [CMakeFiles/cmake_problem.dir/all] Error 2
CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/cmake_problem.dir/rule' failed
make[1]: *** [CMakeFiles/cmake_problem.dir/rule] Error 2
Makefile:118: recipe for target 'cmake_problem' failed
make: *** [cmake_problem] Error 2
To avoid having a wall of code in here, I uploaded a minimal example onto github: https://github.com/mimre25/cmake_problem
Also, this is the library I'm using, installed with cmake & sudo make install: https://github.com/wo80/Triangle
I've tried the solutions from various similar threads but to no avail.
Thanks in advance for any help!
I would have written this as a comment but I don't have enough reputation for that. Is this a situation where you need to use this Triangle (https://github.com/wo80/Triangle), rather than the original Triangle (https://www.cs.cmu.edu/~quake/triangle.html)? If you can use the latter, I know from experience that its is very easy to link to. I just put it in a subdirectory in my code with this CMakeLists.txt.
## This only works for linux. Use an if statement to handle all architectures.
SET(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -O -DLINUX -DTRILIBRARY -w -DANSI_DECLARATORS"
)
SET(FILES_SOURCE
triangle.h triangle.c
)
ADD_LIBRARY( my_local_name_for_triangle_library STATIC ${FILES_SOURCE} )
And then I can link to the triangle library I have created like this:
include_directories(my_local_triangle_dir)
target_link_libraries(my_local_name_for_triangle_library)
However, some of the #define macros are missing in triangle.h, so you need to copy them from triangle.c to triangle.h.
It seems that you tried to link a library that doesn't exist (where CMake can find it).
You either need to create a find_library, or when you link to triangle, give a full path with name.
Alternatively, you can leave the source in a sub directory which you can call then link to the name.
Try compile. Get error. What his need?
[ 62%] Linking CXX shared library ....\bin\libopencv_superres310d.dll
Info: resolving vtable for cv::ParallelLoopBody by linking to __imp___ZTVN2cv16P
arallelLoopBodyE (auto-import)
Info: resolving vtable for cv::VideoCapture by linking to __imp___ZTVN2cv12Video
CaptureE (auto-import)
Creating library file: ....\lib\libopencv_superres310d.dll.a
c:/qt/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../../mingw32/bin/ld.e
xe: warning: auto-importing has been activated without --enable-auto-import spec
ified on the command line.
This should work unless it involves constant data structures referencing symbols
from auto-imported DLLs.
Cannot export _ZN2cv3Mat3ptrIN12_GLOBAL__N_18_Point4fEEEPT_i: symbol not found
collect2: ld returned 1 exit status
mingw32-make[2]: * [bin/libopencv_superres310d.dll] Error 1
mingw32-make[1]: * [modules/superres/CMakeFiles/opencv_superres.dir/all] Error
2
mingw32-make: *** [all] Error 2
the first problem is your function with computer when you use opencv3. 1, opencv3. 1 Newest operating systems are supported: Windows 10 and OSX 10.11 (Visual Studio 2015 and XCode 7.1.1), the function can't use old computer try with old version opencv
While compiling a project i get the following error as
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find lwxmsw28
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/MinGW-Windows/libRegistration.dll] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
I am using wxwidgets libraries however when i ran a command in cmd as
wx-config --libs
i could not see lwxmsw28 either let me know if it is downloadable from somewhere or any workaround to resolve this issue.
Thanks
This is a linker error, rather than a compilation error.
"lwxmsw28" looks to me like a wxwidgets v2.8 microsoft windows library. Should the linker be looking for this? Since you are using mingw, I would think you should NOT be linking to msw libraries. However, I am not familiar with mingw, so maybe this is the name used for mingw libraries.
If this is the correct library, then the next question is: have you built the wxWidgets libraries? The libraries are NOT "downloadable from somewhere" - you must download the source and build the libraries yourself.
A simple test to find out if you have built the libraries - try to build one of the sample projects.