thinkfan
thinkfan copied to clipboard
Problem with building thinkfan, DSO missing from command line
As thinkfan doesn't come prepackaged with Debian Bullseye, I'm trying to build it myself. I installed all the libraries as instructed in the README file, and followed the build instructions. Running cmake works fine, but then when I run make I get the following linker error that I cannot resolve no matter what I try (this is actually my first time building a project!):
/usr/bin/ld: CMakeFiles/thinkfan.dir/src/parser.cpp.o: undefined reference to symbol '_ZTVN10__cxxabiv121__vmi_class_type_infoE@@CXXABI_1.3'
/usr/bin/ld: /lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/thinkfan.dir/build.make:269: thinkfan] Error 1
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/thinkfan.dir/all] Error 2
make: *** [Makefile:149: all] Error 2
I'm not even sure what the error actually signifies, the missing symbol is encoded in a way so that I don't understand to which function it actually refers in parser.cpp. I also did apt-get install libstdc++6, and tried to set global LDFLAGS to link to it, but to no avail. I looked at the cmake file but couldn't find any specific linking instructions for standard libraries that I could try to fix (I guess cmake does that automatically for you then). And trying to read the cmake generated make file is too complicated for me!
I don't have the expertise (yet!) to know whether I screwed something up on my system or whether this is a genuine issue with thinkfan.
I would really appreciate any help!
Hm, from the log lines you posted I can't really tell what might have gone wrong. It looks like something is wrong with your gcc/g++ setup. If you post the full output of this we might find something:
make clean
VERBOSE=1 make
Thank-you so much for your help! OK, that was quite interesting! I see a potential issue, namely that cmake tries to use gcc for building, instead of g++. Maybe that doesn't work on my system? It doesn't explicitly link libstdc++6 either. (also, unrelated, where should I really have my build directory for thinkfan, now I just have a /build directory in /usr/local/src/thinkfan? this is not the place where thinkfan is installed, correct? just build? is there a designated place for temporary build files?).
See attachment for logs. log.txt
/usr/bin/cmake -S/usr/local/src/thinkfan -B/usr/local/src/thinkfan/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /usr/local/src/thinkfan/build/CMakeFiles /usr/local/src/thinkfan/build//CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/usr/local/src/thinkfan/build'
make -f CMakeFiles/thinkfan.dir/build.make CMakeFiles/thinkfan.dir/depend
make[2]: Entering directory '/usr/local/src/thinkfan/build'
cd /usr/local/src/thinkfan/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /usr/local/src/thinkfan /usr/local/src/thinkfan /usr/local/src/thinkfan/build /usr/local/src/thinkfan/build /usr/local/src/thinkfan/build/CMakeFiles/thinkfan.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/usr/local/src/thinkfan/build'
make -f CMakeFiles/thinkfan.dir/build.make CMakeFiles/thinkfan.dir/build
make[2]: Entering directory '/usr/local/src/thinkfan/build'
[ 7%] Building CXX object CMakeFiles/thinkfan.dir/src/thinkfan.cpp.o
/usr/bin/gcc -DHAVE_SYSTEMD -DPID_FILE=\"/run/thinkfan.pid\" -DUSE_LM_SENSORS -DUSE_NVML -DUSE_YAML -DVERSION=\"2.0.0\" -I/usr/local/src/thinkfan/include -O3 -DNDEBUG -Wall -std=gnu++17 -o CMakeFiles/thinkfan.dir/src/thinkfan.cpp.o -c /usr/local/src/thinkfan/src/thinkfan.cpp
[ 15%] Building CXX object CMakeFiles/thinkfan.dir/src/config.cpp.o
/usr/bin/gcc -DHAVE_SYSTEMD -DPID_FILE=\"/run/thinkfan.pid\" -DUSE_LM_SENSORS -DUSE_NVML -DUSE_YAML -DVERSION=\"2.0.0\" -I/usr/local/src/thinkfan/include -O3 -DNDEBUG -Wall -std=gnu++17 -o CMakeFiles/thinkfan.dir/src/config.cpp.o -c /usr/local/src/thinkfan/src/config.cpp
[ 23%] Building CXX object CMakeFiles/thinkfan.dir/src/fans.cpp.o
/usr/bin/gcc -DHAVE_SYSTEMD -DPID_FILE=\"/run/thinkfan.pid\" -DUSE_LM_SENSORS -DUSE_NVML -DUSE_YAML -DVERSION=\"2.0.0\" -I/usr/local/src/thinkfan/include -O3 -DNDEBUG -Wall -std=gnu++17 -o CMakeFiles/thinkfan.dir/src/fans.cpp.o -c /usr/local/src/thinkfan/src/fans.cpp
[ 30%] Building CXX object CMakeFiles/thinkfan.dir/src/sensors.cpp.o
/usr/bin/gcc -DHAVE_SYSTEMD -DPID_FILE=\"/run/thinkfan.pid\" -DUSE_LM_SENSORS -DUSE_NVML -DUSE_YAML -DVERSION=\"2.0.0\" -I/usr/local/src/thinkfan/include -O3 -DNDEBUG -Wall -std=gnu++17 -o CMakeFiles/thinkfan.dir/src/sensors.cpp.o -c /usr/local/src/thinkfan/src/sensors.cpp
[ 38%] Building CXX object CMakeFiles/thinkfan.dir/src/driver.cpp.o
/usr/bin/gcc -DHAVE_SYSTEMD -DPID_FILE=\"/run/thinkfan.pid\" -DUSE_LM_SENSORS -DUSE_NVML -DUSE_YAML -DVERSION=\"2.0.0\" -I/usr/local/src/thinkfan/include -O3 -DNDEBUG -Wall -std=gnu++17 -o CMakeFiles/thinkfan.dir/src/driver.cpp.o -c /usr/local/src/thinkfan/src/driver.cpp
[ 46%] Building CXX object CMakeFiles/thinkfan.dir/src/hwmon.cpp.o
/usr/bin/gcc -DHAVE_SYSTEMD -DPID_FILE=\"/run/thinkfan.pid\" -DUSE_LM_SENSORS -DUSE_NVML -DUSE_YAML -DVERSION=\"2.0.0\" -I/usr/local/src/thinkfan/include -O3 -DNDEBUG -Wall -std=gnu++17 -o CMakeFiles/thinkfan.dir/src/hwmon.cpp.o -c /usr/local/src/thinkfan/src/hwmon.cpp
[ 53%] Building CXX object CMakeFiles/thinkfan.dir/src/libsensors.cpp.o
/usr/bin/gcc -DHAVE_SYSTEMD -DPID_FILE=\"/run/thinkfan.pid\" -DUSE_LM_SENSORS -DUSE_NVML -DUSE_YAML -DVERSION=\"2.0.0\" -I/usr/local/src/thinkfan/include -O3 -DNDEBUG -Wall -std=gnu++17 -o CMakeFiles/thinkfan.dir/src/libsensors.cpp.o -c /usr/local/src/thinkfan/src/libsensors.cpp
[ 61%] Building CXX object CMakeFiles/thinkfan.dir/src/temperature_state.cpp.o
/usr/bin/gcc -DHAVE_SYSTEMD -DPID_FILE=\"/run/thinkfan.pid\" -DUSE_LM_SENSORS -DUSE_NVML -DUSE_YAML -DVERSION=\"2.0.0\" -I/usr/local/src/thinkfan/include -O3 -DNDEBUG -Wall -std=gnu++17 -o CMakeFiles/thinkfan.dir/src/temperature_state.cpp.o -c /usr/local/src/thinkfan/src/temperature_state.cpp
[ 69%] Building CXX object CMakeFiles/thinkfan.dir/src/message.cpp.o
/usr/bin/gcc -DHAVE_SYSTEMD -DPID_FILE=\"/run/thinkfan.pid\" -DUSE_LM_SENSORS -DUSE_NVML -DUSE_YAML -DVERSION=\"2.0.0\" -I/usr/local/src/thinkfan/include -O3 -DNDEBUG -Wall -std=gnu++17 -o CMakeFiles/thinkfan.dir/src/message.cpp.o -c /usr/local/src/thinkfan/src/message.cpp
[ 76%] Building CXX object CMakeFiles/thinkfan.dir/src/parser.cpp.o
/usr/bin/gcc -DHAVE_SYSTEMD -DPID_FILE=\"/run/thinkfan.pid\" -DUSE_LM_SENSORS -DUSE_NVML -DUSE_YAML -DVERSION=\"2.0.0\" -I/usr/local/src/thinkfan/include -O3 -DNDEBUG -Wall -std=gnu++17 -o CMakeFiles/thinkfan.dir/src/parser.cpp.o -c /usr/local/src/thinkfan/src/parser.cpp
[ 84%] Building CXX object CMakeFiles/thinkfan.dir/src/error.cpp.o
/usr/bin/gcc -DHAVE_SYSTEMD -DPID_FILE=\"/run/thinkfan.pid\" -DUSE_LM_SENSORS -DUSE_NVML -DUSE_YAML -DVERSION=\"2.0.0\" -I/usr/local/src/thinkfan/include -O3 -DNDEBUG -Wall -std=gnu++17 -o CMakeFiles/thinkfan.dir/src/error.cpp.o -c /usr/local/src/thinkfan/src/error.cpp
[ 92%] Building CXX object CMakeFiles/thinkfan.dir/src/yamlconfig.cpp.o
/usr/bin/gcc -DHAVE_SYSTEMD -DPID_FILE=\"/run/thinkfan.pid\" -DUSE_LM_SENSORS -DUSE_NVML -DUSE_YAML -DVERSION=\"2.0.0\" -I/usr/local/src/thinkfan/include -O3 -DNDEBUG -Wall -std=gnu++17 -o CMakeFiles/thinkfan.dir/src/yamlconfig.cpp.o -c /usr/local/src/thinkfan/src/yamlconfig.cpp
[100%] Linking CXX executable thinkfan
/usr/bin/cmake -E cmake_link_script CMakeFiles/thinkfan.dir/link.txt --verbose=1
/usr/bin/gcc -O3 -DNDEBUG -rdynamic CMakeFiles/thinkfan.dir/src/thinkfan.cpp.o CMakeFiles/thinkfan.dir/src/config.cpp.o CMakeFiles/thinkfan.dir/src/fans.cpp.o CMakeFiles/thinkfan.dir/src/sensors.cpp.o CMakeFiles/thinkfan.dir/src/driver.cpp.o CMakeFiles/thinkfan.dir/src/hwmon.cpp.o CMakeFiles/thinkfan.dir/src/libsensors.cpp.o CMakeFiles/thinkfan.dir/src/temperature_state.cpp.o CMakeFiles/thinkfan.dir/src/message.cpp.o CMakeFiles/thinkfan.dir/src/parser.cpp.o CMakeFiles/thinkfan.dir/src/error.cpp.o CMakeFiles/thinkfan.dir/src/yamlconfig.cpp.o -o thinkfan -lpthread -ldl -lsensors -lyaml-cpp
/usr/bin/ld: CMakeFiles/thinkfan.dir/src/parser.cpp.o: undefined reference to symbol '_ZTVN10__cxxabiv121__vmi_class_type_infoE@@CXXABI_1.3'
/usr/bin/ld: /lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/thinkfan.dir/build.make:269: thinkfan] Error 1
make[2]: Leaving directory '/usr/local/src/thinkfan/build'
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/thinkfan.dir/all] Error 2
make[1]: Leaving directory '/usr/local/src/thinkfan/build'
make: *** [Makefile:149: all] Error 2
I see a potential issue, namely that cmake tries to use gcc for building, instead of g++. Maybe that doesn't work on my system? It doesn't explicitly link libstdc++6 either.
You're exactly right.
(also, unrelated, where should I really have my build directory for thinkfan, now I just have a /build directory in /usr/local/src/thinkfan? this is not the place where thinkfan is installed, correct? just build? is there a designated place for temporary build files?).
thinkfan/build is fine. It puts all binaries there, ready to be installed to ${CMAKE_INSTALL_PREFIX} with make install.
Just updated the readme with some setup instructions for debian derivates.
Thanks! However, I had already installed g++ to be sure, and cmake still doesn't use it. Do you know how to force cmake to use it or why it isn't using it in the first place?
I'm not sure what is confusing cmake here. If I test it with a plain Debian Bullseye docker container where I install these exact packages it works correctly.
I've made a small change on the master branch that should tell CMake to use C++ for everything. Would be great if you could try and see if it helps.
Closing as it appears solved. Feel free to reopen if you observe this again.