I need the glog library (https://github.com/google/glog) for a C++ project (Windows 10, Qt 5.10) and try to build it from sources using CMake. The CMake configuration process was succesful, the path to gflags is also set correctly.
After configurating glog with CMake, I tried to compile it with MinGW (command mingw32-make in the build folder). After 64%, the building process stopped with an error:
[ 64%] Linking CXX executable utilities_unittest.exe
libglog.a(symbolize.cc.obj):symbolize.cc:(.text+0x15f): undefined reference to `_imp__SymFromAddr#20'
libglog.a(symbolize.cc.obj):symbolize.cc:(.text$_ZN6google14SymInitializerC1Ev[__ZN6google14SymInitializerC1Ev]+0x2f): undefined reference to `_imp__SymSetOptions#4'
libglog.a(symbolize.cc.obj):symbolize.cc:(.text$_ZN6google14SymInitializerC1Ev[__ZN6google14SymInitializerC1Ev]+0x51): undefined reference to `_imp__SymInitialize#12'
libglog.a(symbolize.cc.obj):symbolize.cc:(.text$_ZN6google14SymInitializerD1Ev[__ZN6google14SymInitializerD1Ev]+0x12): undefined reference to `_imp__SymCleanup#4' libglog.a(demangle.cc.obj):demangle.cc:(.text+0x9e): undefined reference to `_imp__UnDecorateSymbolName#16'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\utilities_unittest.dir\build.make:98: recipe for target 'utilities_unittest.exe' failed
mingw32-make[2]: *** [utilities_unittest.exe] Error 1
CMakeFiles\Makefile2:482: recipe for target 'CMakeFiles/utilities_unittest.dir/all' failed
mingw32-make[1]:
*** [CMakeFiles/utilities_unittest.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
Do you have any idea how to fix it?
I already tried to enable the
CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
option, but this did not solve the problem.
Thank you for your help!
Related
I'm trying to compile the AWS iot localproxy on an rPi (have tried 3 and 4 and getting the same issue). I follow the instructions here >> https://github.com/aws-samples/aws-iot-securetunneling-localproxy
I have been sucessful compiling on macOS and the binary works, but when building on an rPi I get the folowing error...
[ 4%] Linking CXX executable bin/localproxytest
/usr/bin/ld: /usr/local/lib/arm-linux-gnueabihf/libprotobuf-lite.a(arena.cc.o): in function `google::protobuf::internal::ThreadSafeArena::Init(bool)':
arena.cc:(.text+0xa60): undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/localproxytest.dir/build.make:292: bin/localproxytest] Error 1
make[1]: *** [CMakeFiles/Makefile2:97: CMakeFiles/localproxytest.dir/all] Error 2
make: *** [Makefile:103: all] Error 2
It seems to be a problem linking to '__atomic_fetch_add_8' or the atomic libs? Any clues on how to resolve? Anyone been successful building this on an rPi?
I believe there is an issue with CMake and the order of linking with ld.
In CMakeLists.txt
Moving atomic to be the last link command after all the sources fixed this for me
https://github.com/aws-samples/aws-iot-securetunneling-localproxy/blob/main/CMakeLists.txt#L94
if(NOT APPLE AND NOT MSVC) target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} atomic) target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} atomic) endif()
should be below
https://github.com/aws-samples/aws-iot-securetunneling-localproxy/blob/main/CMakeLists.txt#L111
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} ${Protobuf_LITE_STATIC_LIBRARY})
In this time, I want to use Freeopcua to create a library to use in other project.
I have install all the tools in debian.soft file and build with following command sudo sh build.sh, cmake ., make, sudo make install. Although, in directory /usr/local/include and /usr/local/lib, there are opc directory and libopc*.so respectively, when I create a new cmake project, there is an error. Hope someone can help me or give some suggest. Thanks everyone~~~
I have refer to Libraries in /usr/local/lib not found, but it doesn't work for me
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.12)
project(OPCUAIndependent)
include_directories(/usr/local/include/)
link_directories(/usr/local/lib/)
add_executable(sourceCode sourceCode.cpp)
target_link_libraries(sourceCode opc)
Error
[ 50%] Linking CXX executable sourceCode
/usr/bin/ld: cannot find -lopc
collect2: error: ld returned 1 exit status
CMakeFiles/sourceCode.dir/build.make:96: recipe for target 'sourceCode' failed
make[2]: *** [sourceCode] Error 1
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/sourceCode.dir/all' failed
make[1]: *** [CMakeFiles/sourceCode.dir/all] Error 2
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2
When I tried to compile example from Anvil framework for Vulkan I get following errors:
[ 97%] Linking CXX executable OutOfOrderRasterization
/usr/bin/ld: cannot find -lvulkan
collect2: error: ld returned 1 exit status
CMakeFiles/OutOfOrderRasterization.dir/build.make:126: recipe for target 'OutOfOrderRasterization' failed
make[2]: *** [OutOfOrderRasterization] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/OutOfOrderRasterization.dir/all' failed
make[1]: *** [CMakeFiles/OutOfOrderRasterization.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
How i need to configure Vulkan to resolve it? (Ubuntu)
Check you LIBRARY paths. You might need to download and install vulkan. There should a .so file in one your library paths(/usr/lib{,64},/lib{,64}, /usr/share/lib{,64}) named to the effect of libvulkan.numbers.so.
See this ask ubuntu question: https://askubuntu.com/questions/796442/ld-cannot-find-lvulkan
CMake versions 3.7 and later ship with a FindVulkan.cmake module that finds the Vulkan includes and library for you if you have a Vulkan SDK installed and the VULKAN_SDK environment variable set. The CMake module also finds the includes and library if you have installed a Vulkan package to your system directories. The Getting Started guide on the LunarXchange website has some additional detail.
I'm using the CLion IDE and need to put some OpenGL files in. In the JetBrains/CLion folder there's a bin and lib folder. In the lib folder theres jar files, do I put the header and dlls in here?
get this error:
CMakeFiles\GL.dir/objects.a(main.cpp.obj): In function `glutInit_ATEXIT_HACK':
c:/mingw/include/gl/glut.h:486: undefined reference to `__glutInitWithExit'
CMakeFiles\GL.dir/objects.a(main.cpp.obj): In function `glutCreateWindow_ATEXIT_HACK':
c:/mingw/include/gl/glut.h:503: undefined reference to `__glutCreateWindowWithExit'
CMakeFiles\GL.dir/objects.a(main.cpp.obj): In function `glutCreateMenu_ATEXIT_HACK':
c:/mingw/include/gl/glut.h:549: undefined reference to `__glutCreateMenuWithExit'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\GL.dir\build.make:86: recipe for target 'GL.exe' failed
mingw32-make.exe[3]: *** [GL.exe] Error 1
CMakeFiles\Makefile2:59: recipe for target 'CMakeFiles/GL.dir/all' failed
CMakeFiles\Makefile2:71: recipe for target 'CMakeFiles/GL.dir/rule' failed
mingw32-make.exe[2]: *** [CMakeFiles/GL.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/GL.dir/rule] Error 2
Makefile:109: recipe for target 'GL' failed
mingw32-make.exe: *** [GL] Error 2
From the FAQ here:
At present CLion supports GCC and Clang compilers and is guided by these two to get the libraries and headers paths.
So it depends on the compiler CLion is using where it looks for the header files.
I'm using mingw-w64 (4.8.0) + cmake to build shared libraries for yaml-cpp (0.5.1). The project has a few build targets in the CMakeLists.txt that comes with it: the main library yaml-cpp and some test programs e.g. parse, which links the library.
The library target yaml-cpp itself built without error but it is followed by this error when parse is built:
Linking CXX executable parse.exe
CMakeFiles\parse.dir/objects.a(parse.cpp.obj):parse.cpp:(.text+0x1a3): undefined reference to `YAML::Load(std::istream&)'
CMakeFiles\parse.dir/objects.a(parse.cpp.obj):parse.cpp:(.text+0x1b2): undefined reference to `YAML::operator<<(std::ostream&, YAML::Node const&)'
c:/work/mingw64-4.8/bin/../lib/gcc/x86_64-w64-mingw32/4.8.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\parse.dir/objects.a(parse.cpp.obj): bad reloc address 0x0 in section `.data'
collect2.exe: error: ld returned 1 exit status
util\CMakeFiles\parse.dir\build.make:90: recipe for target 'util/parse.exe' failed
mingw32-make[3]: *** [util/parse.exe] Error 1
CMakeFiles\Makefile2:228: recipe for target 'util/CMakeFiles/parse.dir/all' failed
mingw32-make[2]: *** [util/CMakeFiles/parse.dir/all] Error 2
CMakeFiles\Makefile2:240: recipe for target 'util/CMakeFiles/parse.dir/rule' failed
mingw32-make[1]: *** [util/CMakeFiles/parse.dir/rule] Error 2
makefile:211: recipe for target 'parse' failed
mingw32-make: *** [parse] Error 2
I run into similar errors when I try to write small test programs using the library, and I don't know what is wrong. What might be the issue here?
Jesse Beder's comment points to the exact issue causing the error described in the question. A quick fix while this gets fixed in a follow-up release is to apply the patch (https://code.google.com/p/yaml-cpp/issues/detail?id=216#c4) to a clean copy of yaml-cpp 0.5.1. There is also a line that declares std::string node_data::empty_scalar in the source file src/node_data.cpp that should be commented out. After making these changes, the shared libraries and utilities build without error.