0.9.6 Fails to link with -DPODOFO_HAVE_GCC_SYMBOL_VISIBILITY
A PDF parsing, modification and creation library.
Brought to you by:
domseichter
Start from r1926 podofo can't build (precisely link) its testsuite anymore if built with -DPODOFO_HAVE_GCC_SYMBOL_VISIBILITY which causes -fvisibility=hidden to be passed to GCC.
...
[ 99%] Building CXX object test/unit/CMakeFiles/podofo-test.dir/DateTest.cpp.o
cd /build/libpodofo-0.9.6/obj-x86_64-linux-gnu/test/unit && /usr/lib/ccache/c++ -DPODOFO_HAVE_GCC_SYMBOL_VISIBILITY -I/build/libpodofo-0.9.6/obj-x86_64-linux-gnu -I/build/libpodofo-0.9.6 -I/usr/include/x86_64-linux-gnu -I/usr/include/cppunit -I/usr/include/lua5.1 -I/build/libpodofo-0.9.6/src -I/usr/include/freetype2 -I/src -I/src/os -g -O2 -fdebug-prefix-map=/build/libpodofo-0.9.6=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wall -Woverloaded-virtual -Wswitch-enum -Wcast-qual -Wwrite-strings -Wredundant-decls -Wreorder -Wno-deprecated-declarations -W -fvisibility=hidden -g -o CMakeFiles/podofo-test.dir/DateTest.cpp.o -c /build/libpodofo-0.9.6/test/unit/DateTest.cpp
[100%] Linking CXX executable podofo-test
cd /build/libpodofo-0.9.6/obj-x86_64-linux-gnu/test/unit && /usr/bin/cmake -E cmake_link_script CMakeFiles/podofo-test.dir/link.txt --verbose=1
/usr/lib/ccache/c++ -g -O2 -fdebug-prefix-map=/build/libpodofo-0.9.6=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wall -Woverloaded-virtual -Wswitch-enum -Wcast-qual -Wwrite-strings -Wredundant-decls -Wreorder -Wno-deprecated-declarations -Wl,-z,relro -Wl,-z,now -rdynamic CMakeFiles/podofo-test.dir/main.cpp.o CMakeFiles/podofo-test.dir/ColorTest.cpp.o CMakeFiles/podofo-test.dir/DeviceTest.cpp.o CMakeFiles/podofo-test.dir/ElementTest.cpp.o CMakeFiles/podofo-test.dir/EncodingTest.cpp.o CMakeFiles/podofo-test.dir/EncryptTest.cpp.o CMakeFiles/podofo-test.dir/FilterTest.cpp.o CMakeFiles/podofo-test.dir/FontTest.cpp.o CMakeFiles/podofo-test.dir/NameTest.cpp.o CMakeFiles/podofo-test.dir/PagesTreeTest.cpp.o CMakeFiles/podofo-test.dir/PageTest.cpp.o CMakeFiles/podofo-test.dir/PainterTest.cpp.o CMakeFiles/podofo-test.dir/ParserTest.cpp.o CMakeFiles/podofo-test.dir/TokenizerTest.cpp.o CMakeFiles/podofo-test.dir/StringTest.cpp.o CMakeFiles/podofo-test.dir/VariantTest.cpp.o CMakeFiles/podofo-test.dir/BasicTypeTest.cpp.o CMakeFiles/podofo-test.dir/TestUtils.cpp.o CMakeFiles/podofo-test.dir/DateTest.cpp.o -o podofo-test -L/build/libpodofo-0.9.6/obj-x86_64-linux-gnu/src -Wl,-rpath,/build/libpodofo-0.9.6/obj-x86_64-linux-gnu/src -lpodofo -lfontconfig -lfreetype -lz -lidn -lcrypto -lcrypto -lssl -ljpeg -lpthread -lfreetype -lpng -lz -ltiff -lunistring -lcppunit -lidn -lcrypto -lcrypto -lssl -ljpeg -lpthread -lfreetype -lpng -ltiff -lunistring -lcppunit
/usr/bin/ld: CMakeFiles/podofo-test.dir/ParserTest.cpp.o: in function `ParserTest::testReadXRefStreamContents()':
./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1202: undefined reference to `PoDoFo::PdfXRefStreamParserObject::PdfXRefStreamParserObject(PoDoFo::PdfVecObjects*, PoDoFo::PdfRefCountedInputDevice const&, PoDoFo::PdfRefCountedBuffer const&, std::vector<PoDoFo::PdfParser::TXRefEntry, std::allocator<PoDoFo::PdfParser::TXRefEntry> >*)'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1206: undefined reference to `PoDoFo::PdfXRefStreamParserObject::Parse()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1207: undefined reference to `PoDoFo::PdfXRefStreamParserObject::ReadXRefTable()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1202: undefined reference to `PoDoFo::PdfXRefStreamParserObject::~PdfXRefStreamParserObject()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1260: undefined reference to `PoDoFo::PdfXRefStreamParserObject::PdfXRefStreamParserObject(PoDoFo::PdfVecObjects*, PoDoFo::PdfRefCountedInputDevice const&, PoDoFo::PdfRefCountedBuffer const&, std::vector<PoDoFo::PdfParser::TXRefEntry, std::allocator<PoDoFo::PdfParser::TXRefEntry> >*)'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1264: undefined reference to `PoDoFo::PdfXRefStreamParserObject::Parse()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1265: undefined reference to `PoDoFo::PdfXRefStreamParserObject::ReadXRefTable()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1260: undefined reference to `PoDoFo::PdfXRefStreamParserObject::~PdfXRefStreamParserObject()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1317: undefined reference to `PoDoFo::PdfXRefStreamParserObject::PdfXRefStreamParserObject(PoDoFo::PdfVecObjects*, PoDoFo::PdfRefCountedInputDevice const&, PoDoFo::PdfRefCountedBuffer const&, std::vector<PoDoFo::PdfParser::TXRefEntry, std::allocator<PoDoFo::PdfParser::TXRefEntry> >*)'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1321: undefined reference to `PoDoFo::PdfXRefStreamParserObject::Parse()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1322: undefined reference to `PoDoFo::PdfXRefStreamParserObject::ReadXRefTable()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1374: undefined reference to `PoDoFo::PdfXRefStreamParserObject::PdfXRefStreamParserObject(PoDoFo::PdfVecObjects*, PoDoFo::PdfRefCountedInputDevice const&, PoDoFo::PdfRefCountedBuffer const&, std::vector<PoDoFo::PdfParser::TXRefEntry, std::allocator<PoDoFo::PdfParser::TXRefEntry> >*)'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1378: undefined reference to `PoDoFo::PdfXRefStreamParserObject::Parse()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1379: undefined reference to `PoDoFo::PdfXRefStreamParserObject::ReadXRefTable()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1428: undefined reference to `PoDoFo::PdfXRefStreamParserObject::PdfXRefStreamParserObject(PoDoFo::PdfVecObjects*, PoDoFo::PdfRefCountedInputDevice const&, PoDoFo::PdfRefCountedBuffer const&, std::vector<PoDoFo::PdfParser::TXRefEntry, std::allocator<PoDoFo::PdfParser::TXRefEntry> >*)'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1432: undefined reference to `PoDoFo::PdfXRefStreamParserObject::Parse()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1433: undefined reference to `PoDoFo::PdfXRefStreamParserObject::ReadXRefTable()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1484: undefined reference to `PoDoFo::PdfXRefStreamParserObject::PdfXRefStreamParserObject(PoDoFo::PdfVecObjects*, PoDoFo::PdfRefCountedInputDevice const&, PoDoFo::PdfRefCountedBuffer const&, std::vector<PoDoFo::PdfParser::TXRefEntry, std::allocator<PoDoFo::PdfParser::TXRefEntry> >*)'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1487: undefined reference to `PoDoFo::PdfXRefStreamParserObject::Parse()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1488: undefined reference to `PoDoFo::PdfXRefStreamParserObject::ReadXRefTable()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1484: undefined reference to `PoDoFo::PdfXRefStreamParserObject::~PdfXRefStreamParserObject()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1539: undefined reference to `PoDoFo::PdfXRefStreamParserObject::PdfXRefStreamParserObject(PoDoFo::PdfVecObjects*, PoDoFo::PdfRefCountedInputDevice const&, PoDoFo::PdfRefCountedBuffer const&, std::vector<PoDoFo::PdfParser::TXRefEntry, std::allocator<PoDoFo::PdfParser::TXRefEntry> >*)'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1542: undefined reference to `PoDoFo::PdfXRefStreamParserObject::Parse()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1543: undefined reference to `PoDoFo::PdfXRefStreamParserObject::ReadXRefTable()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1539: undefined reference to `PoDoFo::PdfXRefStreamParserObject::~PdfXRefStreamParserObject()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1594: undefined reference to `PoDoFo::PdfXRefStreamParserObject::PdfXRefStreamParserObject(PoDoFo::PdfVecObjects*, PoDoFo::PdfRefCountedInputDevice const&, PoDoFo::PdfRefCountedBuffer const&, std::vector<PoDoFo::PdfParser::TXRefEntry, std::allocator<PoDoFo::PdfParser::TXRefEntry> >*)'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1597: undefined reference to `PoDoFo::PdfXRefStreamParserObject::Parse()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1598: undefined reference to `PoDoFo::PdfXRefStreamParserObject::ReadXRefTable()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1594: undefined reference to `PoDoFo::PdfXRefStreamParserObject::~PdfXRefStreamParserObject()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1649: undefined reference to `PoDoFo::PdfXRefStreamParserObject::PdfXRefStreamParserObject(PoDoFo::PdfVecObjects*, PoDoFo::PdfRefCountedInputDevice const&, PoDoFo::PdfRefCountedBuffer const&, std::vector<PoDoFo::PdfParser::TXRefEntry, std::allocator<PoDoFo::PdfParser::TXRefEntry> >*)'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1652: undefined reference to `PoDoFo::PdfXRefStreamParserObject::Parse()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1653: undefined reference to `PoDoFo::PdfXRefStreamParserObject::ReadXRefTable()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1649: undefined reference to `PoDoFo::PdfXRefStreamParserObject::~PdfXRefStreamParserObject()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1704: undefined reference to `PoDoFo::PdfXRefStreamParserObject::PdfXRefStreamParserObject(PoDoFo::PdfVecObjects*, PoDoFo::PdfRefCountedInputDevice const&, PoDoFo::PdfRefCountedBuffer const&, std::vector<PoDoFo::PdfParser::TXRefEntry, std::allocator<PoDoFo::PdfParser::TXRefEntry> >*)'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1707: undefined reference to `PoDoFo::PdfXRefStreamParserObject::Parse()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1708: undefined reference to `PoDoFo::PdfXRefStreamParserObject::ReadXRefTable()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1704: undefined reference to `PoDoFo::PdfXRefStreamParserObject::~PdfXRefStreamParserObject()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1759: undefined reference to `PoDoFo::PdfXRefStreamParserObject::PdfXRefStreamParserObject(PoDoFo::PdfVecObjects*, PoDoFo::PdfRefCountedInputDevice const&, PoDoFo::PdfRefCountedBuffer const&, std::vector<PoDoFo::PdfParser::TXRefEntry, std::allocator<PoDoFo::PdfParser::TXRefEntry> >*)'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1762: undefined reference to `PoDoFo::PdfXRefStreamParserObject::Parse()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1763: undefined reference to `PoDoFo::PdfXRefStreamParserObject::ReadXRefTable()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1814: undefined reference to `PoDoFo::PdfXRefStreamParserObject::PdfXRefStreamParserObject(PoDoFo::PdfVecObjects*, PoDoFo::PdfRefCountedInputDevice const&, PoDoFo::PdfRefCountedBuffer const&, std::vector<PoDoFo::PdfParser::TXRefEntry, std::allocator<PoDoFo::PdfParser::TXRefEntry> >*)'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1817: undefined reference to `PoDoFo::PdfXRefStreamParserObject::Parse()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1818: undefined reference to `PoDoFo::PdfXRefStreamParserObject::ReadXRefTable()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1814: undefined reference to `PoDoFo::PdfXRefStreamParserObject::~PdfXRefStreamParserObject()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1759: undefined reference to `PoDoFo::PdfXRefStreamParserObject::~PdfXRefStreamParserObject()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1704: undefined reference to `PoDoFo::PdfXRefStreamParserObject::~PdfXRefStreamParserObject()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1649: undefined reference to `PoDoFo::PdfXRefStreamParserObject::~PdfXRefStreamParserObject()'
/usr/bin/ld: ./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1594: undefined reference to `PoDoFo::PdfXRefStreamParserObject::~PdfXRefStreamParserObject()'
/usr/bin/ld: CMakeFiles/podofo-test.dir/ParserTest.cpp.o:./obj-x86_64-linux-gnu/test/unit/./test/unit/ParserTest.cpp:1539: more undefined references to `PoDoFo::PdfXRefStreamParserObject::~PdfXRefStreamParserObject()' follow
collect2: error: ld returned 1 exit status
make[3]: *** [test/unit/CMakeFiles/podofo-test.dir/build.make:377: test/unit/podofo-test] Error 1
make[3]: Leaving directory '/build/libpodofo-0.9.6/obj-x86_64-linux-gnu'
make[2]: *** [CMakeFiles/Makefile2:832: test/unit/CMakeFiles/podofo-test.dir/all] Error 2
make[2]: Leaving directory '/build/libpodofo-0.9.6/obj-x86_64-linux-gnu'
make[1]: *** [Makefile:133: all] Error 2
make[1]: Leaving directory '/build/libpodofo-0.9.6/obj-x86_64-linux-gnu'
This is because PdfXRefStreamParserObject : public PdfParserObject from src/base/PdfXRefStreamParserObject.h is not considered part of the ABI, and is therefore not exported in the symbols table. A workaround consisting on marking that class as PODOFO_API is enough to make the build succeed, but it seems like this is not meant to be part of the API/ABI so it's also not appropriate.
Originally reported at https://sourceforge.net/p/podofo/mailman/message/36363656/
As this isn't library-internal but in a test, "internal" visibility (IIRC) can't be used, so my suggestion is to mark it both PODOFO_API and with the "
__deprecated__" attribute (and add to its Doxygen class documentation that it's only available publicly for the benefit of the tests, this is deprecated and therefore never to be relied on).I'll probably do these changes today and test them as is now usual for me then, and commit if I don't see any new warnings, where I'll run clang++ with -Wno-deprecated-declarations.
I've tested the changes in the meantime with GCC 4.8 and clang 3.8 but probably I should commit something more general (some compilers, like Microsoft's, don't support
__attribute__IIRC, which I've used here)?Last edit: Matthew Brincke 2019-05-19
yeah, MSVC doesn't support
__attribute__, it uses__declspecinstead. See src/base/podofoapi.h - it has a bunch of#defines to take care of this issue.I now have a tested a change to it (and the original file with the issue) with GCC 4.8 and clang 3.8 on some Debian 8 derivate, I'll testing them with GCC 7.4 and clang 7.0, probably tomorrow.
P. S. Do you also have a "Show deleted tickets" link in the ticket overview between the "Tickets" title and the drop-down for number of issues per page? Does it work for you?
I don't.
Last edit: Mattia Rizzolo 2019-05-21
Ah, then that link is very probably present for me because I'm a member of the PoDoFo project on here (full committer) and you (AFAIK) aren't. I tried out the link and saw the deleted issue #51 in the list (in red), clicked on it, then saw it's the same as issue #52 (IIRC) except for an attachment accidentally uploaded (I didn't download it).
The link doesn't fail anymore, and there are no new warnings, so the API must've been changed in the described way. Please don't close this as this is probably not what's intended (see my earlier post here for what should be done first IMHO).
Marking this "pending" as I have a patch I'd like to further test.
If you can share the patch, I'll happily test it and provide comments on it :)
I can share the patch: it's attached here. I didn't attach it to my post before because I thought I should test it more (with newer compilers I don't have installed here), but as you're volunteering, I now think "the sooner the patch is available for independent testing, the better".
Yep, looks sane to me. And I confirm it works :)
Thank you very much, which compiler (version) did you use? Can you also test with clang 7? If so, please do (I could do that only this evening at the earliest). I'd commit it then.
I'm not used to switch compiler, so that would be complex for me at this time. At any rate, I did my test using GCC 8 and binutils (for
ld) 2.31.1 (on current debian unstable).Thank you. I've still got binutils 2.25 (on a Debian 8 derivate), I think that such systems probably still abound, so testing also for them (as I'm already doing ;-) ) is important.
As this was already tested OK by Mattia Rizzolo, and IMHO any Windows or clang problems with the change, committed in svn r1992, should be discussed in new issues, I close this here (because the original link failure was fixed on Windows already in svn r1979 AFAICS).