Created attachment 33091 [details] [review] darwin gtk link fix Using the Cmake way to build. The full error is multiple pages long, but this gives the idea: Linking CXX shared library libpoppler-glib.dylib ld warning: duplicate dylib /Library/Gentoo/lib/libz.dylib Undefined symbols: "_g_type_class_add_private", referenced from: poppler_attachment_class_init(_PopplerAttachmentClass*) in poppler-attachment.cc.o "_g_value_set_flags", referenced from: poppler_document_get_property(_GObject*, unsigned int, _GValue*, _GParamSpec*)in poppler-document.cc.o poppler_document_get_property(_GObject*, unsigned int, _GValue*, _GParamSpec*)in poppler-document.cc.o "_g_type_check_instance_is_a", referenced from: _poppler_ps_file_new in poppler-document.cc.o _poppler_document_has_attachments in poppler-document.cc.o _poppler_document_get_n_pages in poppler-document.cc.o _poppler_font_info_new in poppler-document.cc.o The _g_XXX symbols come from gtk, which libraries are not given to the linker when GTK is found. I will attach a patch which fixes this for me.
g_value_set_flags does not come from gtk, it comes from glib and we are already linking in glib, do your system is broken i'd say
% nm usr/lib/libglib-2.0.dylib | grep g_value_set_flags % nm usr/lib/libgobject-2.0.dylib | grep g_value_set_flags 00021d23 T _g_value_set_flags % gtk uses this symbol, and also properly links against libgobject. Since the problem only occurs when a GTK build is enabled, and the symbol can be found when the gtk libs are used, it felt like a logical fix to me. Notice that the Darwin linker is stricter in this respect than GNU binutils. I checked on Solaris, and couldn't find the g_value_set_flags symbol in the libglib-2.0.so library either.
Two questions: * Does the autotools based build work? * Does this patch help? diff --git a/glib/CMakeLists.txt b/glib/CMakeLists.txt index 6ed9523..392da66 100644 --- a/glib/CMakeLists.txt +++ b/glib/CMakeLists.txt @@ -112,6 +112,7 @@ if (GDK_FOUND) test-poppler-glib.cc ) poppler_add_test(test-poppler-glib BUILD_GTK_TESTS ${test_poppler_glib_SRCS}) + target_link_libraries(poppler-glib ${GDK2_LIBRARIES}) target_link_libraries(test-poppler-glib poppler-glib ${GDK2_LIBRARIES}) endif (GDK_FOUND)
(In reply to comment #3) > Two questions: > * Does the autotools based build work? Yes, it seems to use the GTK libs when linking, resulting in a successful compile. > * Does this patch help? > > diff --git a/glib/CMakeLists.txt b/glib/CMakeLists.txt > index 6ed9523..392da66 100644 > --- a/glib/CMakeLists.txt > +++ b/glib/CMakeLists.txt > @@ -112,6 +112,7 @@ if (GDK_FOUND) > test-poppler-glib.cc > ) > poppler_add_test(test-poppler-glib BUILD_GTK_TESTS > ${test_poppler_glib_SRCS}) > + target_link_libraries(poppler-glib ${GDK2_LIBRARIES}) > target_link_libraries(test-poppler-glib poppler-glib ${GDK2_LIBRARIES}) > endif (GDK_FOUND) > No, it fails in the same way as before.
/bin/bash ../libtool --tag=CXX --mode=link g++ -Wall -Wno-write-strings -Woverloaded-virtual -Wnon-virtual-dtor -ansi -g -O2 -version-info 4:0:0 -o libpoppler-glib.la -rpath /usr/local/lib poppler-enums.lo poppler-action.lo poppler-date.lo poppler-document.lo poppler-page.lo poppler-attachment.lo poppler-form-field.lo poppler-annot.lo poppler-layer.lo poppler.lo ../poppler/libpoppler.la ../poppler/libpoppler-cairo.la -lgobject-2.0 -lglib-2.0 -lcairo -lgdk-x11-2.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lgio-2.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lfreetype -lfontconfig I don't see any GTK lib here Can you post your autotools link line?
You have -lgobject-2.0, which has the required symbols. I don't have a compilation at hand, but I'd assume about the same libs to be there. I know that once GTK is enabled in the cmake build, it fails like this. Maybe GTK is the wrong word here and should it be GDK or something else instead. I haven't examined the code in detail (yet).
Well, ${GDK2_LIBRARIES} has gobject for me so my patch "works for me", if it doesn't for you, you need to work a bit more on this.
If I change my patch to use FOUND_GDK and GDK2_LIBRARIES instead of FOUND_GTK and GTK2_LIBRARIES it works still fine for me. Your patch somehow doesn't seem to reach the right linkline for the glib component, whereas mine does.
Wait, i just realized you are using 0.12.3, any chance you can try git master branch (with and without my patch)
Recently (after the 0.13.1 release) I did various improvements on the CMake build system. Can you try an unpatched compilation of master (or of poppler 0.13.2, when it is released)?
using CMake 2.8.1, git master branch of as of say an hour ago: ... [ 41%] Building CXX object utils/CMakeFiles/pdftoabw.dir/pdftoabw.cc.o Linking CXX executable pdftoabw Undefined symbols: "_xmlSaveFormatFileEnc", referenced from: _main in pdftoabw.cc.o "_xmlFreeDoc", referenced from: _main in pdftoabw.cc.o "_xmlNewDoc", referenced from: _main in pdftoabw.cc.o ld: symbol(s) not found collect2: ld returned 1 exit status probably missing -lxml2, so I disabled abiword support: [ 54%] Building CXX object glib/CMakeFiles/poppler-glib.dir/__/poppler/CairoRescaleBox.cc.o Linking CXX shared library libpoppler-glib.dylib Undefined symbols: "_FT_Done_Face", referenced from: _ft_done_face(void*) in CairoFontEngine.cc.o _ft_done_face_uncached(void*) in CairoFontEngine.cc.o "_FT_New_Face", referenced from: _ft_new_face_uncached(FT_LibraryRec_*, char const*, char*, int, FT_FaceRec_**, _cairo_font_face**)in CairoFontEngine.cc.o "_FT_Init_FreeType", referenced from: CairoOutputDev::CairoOutputDev()in CairoOutputDev.cc.o "_FT_New_Memory_Face", referenced from: _ft_new_face_uncached(FT_LibraryRec_*, char const*, char*, int, FT_FaceRec_**, _cairo_font_face**)in CairoFontEngine.cc.o _ft_new_face(FT_LibraryRec_*, char const*, char*, int, FT_FaceRec_**, _cairo_font_face**)in CairoFontEngine.cc.o "_FT_Library_Version", referenced from: CairoFontEngine::CairoFontEngine(FT_LibraryRec_*)in CairoFontEngine.cc.o "_FT_Get_Name_Index", referenced from: CairoFreeTypeFont::create(GfxFont*, XRef*, FT_LibraryRec_*, int) in CairoFontEngine.cc.o ld: symbol(s) not found collect2: ld returned 1 exit status yay! probably missing -lfreetype autoconf really isn't that bad guys :/
I can reproduce the link issue (though with another error message) of pdftoabw but not poppler-glib. Can you provide (at attachment) a build log done with `make -k VERBOSE=1`? Thanks
Created attachment 34254 [details] build.log here it is
Very useful, thanks. I pushed to master few commits which should fix the issues you faced, can you please test again? Thanks again
Linking CXX shared library libpoppler.dylib ld: unknown option: --as-needed I think you should revert your --as-needed git-commit as it's going to break more platforms. Better try to configure if it is supported by the linker, and only then use it, if you really want to.
Created attachment 34255 [details] [review] Check for existing link flags Can you please try this patch, and paste what cmake outputs for -- Performing Test GCC_HAS_AS_NEEDED and -- Performing Test GCC_HAS_NO_ADD_NEEDED ?
-- Performing Test GCC_HAS_AS_NEEDED -- Performing Test GCC_HAS_AS_NEEDED - Failed -- Performing Test GCC_HAS_NO_ADD_NEEDED -- Performing Test GCC_HAS_NO_ADD_NEEDED - Failed Linking now succeeds, thanks!
Pushed the patch to master, thanks for the report and the testing!
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.