link error: /usr/bin/ld: cannot find -lgtk-3
When linking poppler-glib-demo, I get a linker error: /usr/bin/ld: cannot find -lgtk-3
The CMakeLists.txt file only pulls in the libraries (-lgtk-3, etc.) without the paths to the
libraries (-L).
Here's a patch that fixes it:
--- poppler-0.81.0/glib/demo/CMakeLists.txt.orig 2019-10-09 21:27:03 UTC
+++ poppler-0.81.0/glib/demo/CMakeLists.txt
@@ -24,6 +24,9 @@
layers.c
selections.c
taggedstruct.c
)
poppler_add_test(poppler-glib-demo BUILD_GTK_TESTS ${poppler_glib_demo_SRCS})
-target_link_libraries(poppler-glib-demo ${CAIRO_LIBRARIES} poppler-glib ${GTK3_LIBRARIES})
+#target_link_libraries(poppler-glib-demo ${CAIRO_LIBRARIES} poppler-glib ${GTK3_LIBRARIES})
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(GTK3 REQUIRED IMPORTED_TARGET gtk+-3.0)
+target_link_libraries(poppler-glib-demo ${CAIRO_LIBRARIES} poppler-glib PkgConfig::GTK3)
Part of that could be applied to poppler-0.81.0/cmake/modules/FindGTK.cmake instead.
Note: hint for unintuitive cmake features obtained from a stackoverflow answer here: https://stackoverflow.com/questions/29191855/what-is-the-proper-way-to-use-pkg-config-from-cmake