nana
nana copied to clipboard
Building shared library fails on Ubuntu 20.04
Using cmake, and gcc 9.3.0.
Version v1.7.4, when I enable shared libs on the makefie - the building fails. When I disable this and build Nana as a static library into the app - code compiles and works quite good.
set(BUILD_SHARED_LIBS ON)
FetchContent_Declare(
nana
GIT_REPOSITORY https://github.com/cnjinhao/nana
GIT_TAG v1.7.4 )
Error:
++ cmake --build cbuild --parallel
ninja: error: build.ninja:937: bad $-escape (literal $ must be written as $$)
Now, if I set the GIT_TAG
to develop-1.8
(tip is 4c90600e) I still build the static version. However the dynamic version still fails:
FAILED: bin/nanaide
: && /usr/bin/c++ CMakeFiles/nanaide.dir/main.cpp.o -o bin/nanaide -L/home/elcuco/.conan/data/libpng/1.6.37/_/_/package/f99afdbf2a1cc98ba2029817b35103455b6a9b77/lib -L/home/elcuco/.conan/data/libjpeg-turbo/2.0.6/_/_/package/e7773b05ee54f04d8eb4f54c2a51b03143ca5373/lib -L/home/elcuco/.conan/data/zlib/1.2.11/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib -Wl,-rpath,/home/elcuco/.conan/data/libpng/1.6.37/_/_/package/f99afdbf2a1cc98ba2029817b35103455b6a9b77/lib:/home/elcuco/.conan/data/libjpeg-turbo/2.0.6/_/_/package/e7773b05ee54f04d8eb4f54c2a51b03143ca5373/lib:/home/elcuco/.conan/data/zlib/1.2.11/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib:/home/elcuco/src/nana-ide/cbuild/lib lib/libnana.so -lpng16 -ljpeg -lturbojpeg -lz -lm /usr/lib/x86_64-linux-gnu/libSM.so /usr/lib/x86_64-linux-gnu/libICE.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libXext.so /usr/lib/x86_64-linux-gnu/libXft.so /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib/x86_64-linux-gnu/libfontconfig.so -static-libgcc -static-libstdc++ && :
/usr/bin/ld: lib/libnana.so: undefined reference to `XcursorLibraryLoadCursor'
/usr/bin/ld: lib/libnana.so: undefined reference to `XcursorFilenameLoadCursor'
collect2: error: ld returned 1 exit status
It seems the linking phase is missing -lXcursor
to finish the linking.
Solution on develop-1.8
-
diff --git a/build/cmake/shared_libs.cmake b/build/cmake/shared_libs.cmake
index a2200452..6d4cb561 100644
--- a/build/cmake/shared_libs.cmake
+++ b/build/cmake/shared_libs.cmake
@@ -34,6 +34,10 @@ if(BUILD_SHARED_LIBS) # todo test
"${CMAKE_CURRENT_BINARY_DIR}/libnana.lib" DESTINATION lib)
endif()
endif()
+
+ if(UNIX)
+ target_link_libraries(nana PUBLIC Xcursor)
+ endif()
endif()