Open Corin-EU opened 2 years ago
Hi,
most likely this is due to switch to C++ Lua library variant in 892a81ed369b0ae5d87a438ff77236e9c7f27949.
Linker errors are caused by Lua function declarations using C++ linkage when Lua library exports C style functions.
Debian based distributions have this patch: https://sources.debian.org/patches/lua5.4/5.4.2-2/0003-extern_C.patch/
Without this patch, all Lua header inclusions must be wrapped in extern "C" { }
block when used from C++ code. I will restore these blocks.
GCC 8.2 is too old and is missing some C++17 features. GCC 10 should work once Lua includes are fixed.
Should be fixed in a8bc29c60d57933d9e8e8cb930d8e06586e0d315
Thank you for looking at this problem.
opensuse 15.4 g++-10 (SUSE Linux) 10.4.0
latest gpick r.a8bc29c
I anticipated reporting back that all was now working, but I am still getting the same errors
[ 31%] Linking CXX executable tests
/usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/tests.dir/source/Converter.cpp.o: in function `Converter::serialize[abi:cxx11](ColorObject const&, ConverterSerializePosition const&)':
Converter.cpp:(.text+0x398): undefined reference to `lua_gettop'
/usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: Converter.cpp:(.text+0x3ed): undefined reference to `lua_createtable'
etc
So in the "build" sub-directory, I did a make VERBOSE=1
/usr/local/stow/Development/cmake-3.19.6/bin/cmake -E cmake_link_script CMakeFiles/tests.dir/link.txt --verbose=1
/usr/bin/g++-10 CMakeFiles/tests.dir/CMakeFiles/Version.cpp.o CMakeFiles/tests.dir/source/ColorList.cpp.o CMakeFiles/tests.dir/source/ColorObject.cpp.o CMakeFiles/tests.dir/source/Converter.cpp.o CMakeFiles/tests.dir/source/Converters.cpp.o CMakeFiles/tests.dir/source/ErrorCode.cpp.o CMakeFiles/tests.dir/source/EventBus.cpp.o CMakeFiles/tests.dir/source/FileFormat.cpp.o CMakeFiles/tests.dir/source/InternalConverters.cpp.o CMakeFiles/tests.dir/source/test/BinaryTreeQuantization.cpp.o CMakeFiles/tests.dir/source/test/Color.cpp.o CMakeFiles/tests.dir/source/test/Common.cpp.o CMakeFiles/tests.dir/source/test/Dynv.cpp.o CMakeFiles/tests.dir/source/test/DynvBinary.cpp.o CMakeFiles/tests.dir/source/test/EventBus.cpp.o CMakeFiles/tests.dir/source/test/FileFormat.cpp.o CMakeFiles/tests.dir/source/test/First.cpp.o CMakeFiles/tests.dir/source/test/Format.cpp.o CMakeFiles/tests.dir/source/test/InternalConverters.cpp.o CMakeFiles/tests.dir/source/test/Main.cpp.o CMakeFiles/tests.dir/source/test/Matrix.cpp.o CMakeFiles/tests.dir/source/test/OctreeColorQuantization.cpp.o CMakeFiles/tests.dir/source/test/Ref.cpp.o CMakeFiles/tests.dir/source/test/Result.cpp.o CMakeFiles/tests.dir/source/test/Scoped.cpp.o CMakeFiles/tests.dir/source/test/Script.cpp.o CMakeFiles/tests.dir/source/test/Span.cpp.o CMakeFiles/tests.dir/source/test/TextFileParser.cpp.o CMakeFiles/tests.dir/source/test/Vector.cpp.o CMakeFiles/gpick-color.dir/source/Color.cpp.o CMakeFiles/gpick-math.dir/source/math/BinaryTreeQuantization.cpp.o CMakeFiles/gpick-math.dir/source/math/Empty.cpp.o CMakeFiles/gpick-math.dir/source/math/OctreeColorQuantization.cpp.o CMakeFiles/gpick-dynv.dir/source/dynv/Binary.cpp.o CMakeFiles/gpick-dynv.dir/source/dynv/Map.cpp.o CMakeFiles/gpick-dynv.dir/source/dynv/Types.cpp.o CMakeFiles/gpick-dynv.dir/source/dynv/Variable.cpp.o CMakeFiles/gpick-dynv.dir/source/dynv/Xml.cpp.o CMakeFiles/gpick-lua.dir/source/lua/Color.cpp.o CMakeFiles/gpick-lua.dir/source/lua/ColorObject.cpp.o CMakeFiles/gpick-lua.dir/source/lua/Ref.cpp.o CMakeFiles/gpick-lua.dir/source/lua/Script.cpp.o CMakeFiles/gpick-parser.dir/source/parser/TextFile.cpp.o CMakeFiles/gpick-parser.dir/CMakeFiles/TextFileParser.cpp.o CMakeFiles/gpick-common.dir/source/common/Convert.cpp.o CMakeFiles/gpick-common.dir/source/common/Format.cpp.o CMakeFiles/gpick-common.dir/source/common/Ref.cpp.o CMakeFiles/gpick-common.dir/source/common/StringOrView.cpp.o -o tests /usr/lib64/libboost_unit_test_framework.so -lexpat -lm -pthread
which obviously gave the same error.
I then repeated the command and put a "-llua" at the very end, ie just after "-lm -pthread" and then there was no error and linking was successful.
So it would appear the error is somewhere in the CMakefile process and that the "lua" library dependency is not being added to the needed shared library link list for some reason (unlike back in v0.2.6).
On openSUSE 15.4, I can successfully build v0.2.6, and there are no errors.
If I try the same procedure with v0.3, cmake makes no complaints about lua depenencies
but linking of the tests fails with lots of error message about undefined references to lua functions
What has changed with version 0.3 to cause this problem and why did cmake not complain?
If I try to build the very latest revision r.46f826c, then cmake again makes no complaints, but building fails even sooner with
Since cmake checks the version of the C++ compiler should it not be spitting out an error if the wrong version is being used?
Setting the environmental variable CXX="g++-10" is of course the solution to this, and then compilation continues but the same linking problem of the tests and the build fails.
The version of lua on the system is 5.4.3 and as I stated at the top, v0.2.6 had no problem finding it and linking the tests with the lua library.