AppImageCommunity / libappimage

Implements functionality for dealing with AppImage files
https://appimage.org
Other
46 stars 29 forks source link

Linking fails #147

Closed Mailaender closed 3 years ago

Mailaender commented 4 years ago

on @openSUSE Tumbleweed

[    8s] [100%] Linking CXX shared library libappimage.so
[    8s] cd /home/abuild/rpmbuild/BUILD/libappimage-1.0.3/build/src/libappimage && /usr/bin/cmake -E cmake_link_script CMakeFiles/libappimage.dir/link.txt --verbose=1
[    8s] /usr/bin/c++ -fPIC -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -DNDEBUG -O2 -g -DNDEBUG -flto=auto -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now -shared -Wl,-soname,libappimage.so.1.0 -o libappimage.so.1.0.3 CMakeFiles/libappimage.dir/libappimage.c.o CMakeFiles/libappimage.dir/libappimage.cpp.o CMakeFiles/libappimage.dir/libappimage_legacy.cpp.o core/CMakeFiles/core.dir/AppImage.cpp.o core/CMakeFiles/core.dir/Traversal.cpp.o core/CMakeFiles/core.dir/PayloadIterator.cpp.o core/CMakeFiles/core.dir/impl/TraversalType1.cpp.o core/CMakeFiles/core.dir/impl/TraversalType2.cpp.o core/CMakeFiles/core.dir/impl/StreambufType1.cpp.o core/CMakeFiles/core.dir/impl/StreambufType2.cpp.o utils/CMakeFiles/appimage_utils.dir/MagicBytesChecker.cpp.o utils/CMakeFiles/appimage_utils.dir/ElfFile.cpp.o utils/CMakeFiles/appimage_utils.dir/hashlib.cpp.o utils/CMakeFiles/appimage_utils.dir/UrlEncoder.cpp.o utils/CMakeFiles/appimage_utils.dir/IconHandle.cpp.o utils/CMakeFiles/appimage_utils.dir/Logger.cpp.o utils/CMakeFiles/appimage_utils.dir/path_utils.cpp.o utils/CMakeFiles/appimage_utils.dir/resources_extractor/ResourcesExtractor.cpp.o utils/CMakeFiles/appimage_utils.dir/resources_extractor/PayloadEntriesCache.cpp.o utils/CMakeFiles/appimage_utils.dir/StringSanitizer.cpp.o utils/CMakeFiles/appimage_utils.dir/IconHandleCairoRsvg.cpp.o desktop_integration/CMakeFiles/appimage_desktop_integration.dir/IntegrationManager.cpp.o desktop_integration/CMakeFiles/appimage_desktop_integration.dir/integrator/Integrator.cpp.o desktop_integration/CMakeFiles/appimage_desktop_integration.dir/integrator/DesktopEntryEditor.cpp.o desktop_integration/CMakeFiles/appimage_desktop_integration.dir/Thumbnailer.cpp.o   -L/usr/lib64/XdgUtils  -Wl,-rpath,/usr/lib64/XdgUtils: ../xdg-basedir/libxdg-basedir.a /usr/lib64/XdgUtils/libXdgUtilsDesktopEntry.so /usr/lib64/XdgUtils/libXdgUtilsBaseDir.so ../libappimage_hashlib/libappimage_hashlib.a /usr/lib64/libboost_filesystem.so.1.71.0 ../libappimage_shared/libappimage_shared.a -lpthread -ldl -larchive -lsquashfuse -llzo2 -llzma ../libappimage_hashlib/libappimage_hashlib.a -lz -lrsvg-2 -lm -lgio-2.0 -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lcairo 
[    8s] /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: desktop_integration/CMakeFiles/appimage_desktop_integration.dir/integrator/Integrator.cpp.o (symbol from plugin): in function `appimage::desktop_integration::integrator::Integrator::Integrator(appimage::core::AppImage const&, boost::filesystem::path const&)':
[    8s] (.text+0x0): multiple definition of `_ZGRN15StringSanitizer14pathSafeChars_E_'; utils/CMakeFiles/appimage_utils.dir/StringSanitizer.cpp.o (symbol from plugin):(.text+0x0): first defined here
[    8s] /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: desktop_integration/CMakeFiles/appimage_desktop_integration.dir/integrator/Integrator.cpp.o (symbol from plugin): in function `appimage::desktop_integration::integrator::Integrator::Integrator(appimage::core::AppImage const&, boost::filesystem::path const&)':
[    8s] (.text+0x0): multiple definition of `_ZGRN15StringSanitizer12asciiDigits_E_'; utils/CMakeFiles/appimage_utils.dir/StringSanitizer.cpp.o (symbol from plugin):(.text+0x0): first defined here
[    8s] /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: desktop_integration/CMakeFiles/appimage_desktop_integration.dir/integrator/Integrator.cpp.o (symbol from plugin): in function `appimage::desktop_integration::integrator::Integrator::Integrator(appimage::core::AppImage const&, boost::filesystem::path const&)':
[    8s] (.text+0x0): multiple definition of `_ZGRN15StringSanitizer13asciiLetters_E_'; utils/CMakeFiles/appimage_utils.dir/StringSanitizer.cpp.o (symbol from plugin):(.text+0x0): first defined here
[    8s] /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: desktop_integration/CMakeFiles/appimage_desktop_integration.dir/integrator/DesktopEntryEditor.cpp.o (symbol from plugin): in function `appimage::desktop_integration::integrator::DesktopEntryEditor::setAppImagePath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
[    8s] (.text+0x0): multiple definition of `_ZGRN15StringSanitizer14pathSafeChars_E_'; utils/CMakeFiles/appimage_utils.dir/StringSanitizer.cpp.o (symbol from plugin):(.text+0x0): first defined here
[    8s] /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: desktop_integration/CMakeFiles/appimage_desktop_integration.dir/integrator/DesktopEntryEditor.cpp.o (symbol from plugin): in function `appimage::desktop_integration::integrator::DesktopEntryEditor::setAppImagePath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
[    8s] (.text+0x0): multiple definition of `_ZGRN15StringSanitizer12asciiDigits_E_'; utils/CMakeFiles/appimage_utils.dir/StringSanitizer.cpp.o (symbol from plugin):(.text+0x0): first defined here
[    8s] /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: desktop_integration/CMakeFiles/appimage_desktop_integration.dir/integrator/DesktopEntryEditor.cpp.o (symbol from plugin): in function `appimage::desktop_integration::integrator::DesktopEntryEditor::setAppImagePath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
[    8s] (.text+0x0): multiple definition of `_ZGRN15StringSanitizer13asciiLetters_E_'; utils/CMakeFiles/appimage_utils.dir/StringSanitizer.cpp.o (symbol from plugin):(.text+0x0): first defined here
[    8s] /usr/bin/ranlib libappimage_static.a
[    8s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/libappimage-1.0.3/build'
[    8s] [100%] Built target libappimage_static
[   10s] collect2: error: ld returned 1 exit status
[   10s] make[2]: *** [src/libappimage/CMakeFiles/libappimage.dir/build.make:188: src/libappimage/libappimage.so.1.0.3] Error 1
[   10s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/libappimage-1.0.3/build'
[   10s] make[1]: *** [CMakeFiles/Makefile2:389: src/libappimage/CMakeFiles/libappimage.dir/all] Error 2
[   10s] make[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/libappimage-1.0.3/build'
[   10s] make: *** [Makefile:152: all] Error 2

Command line options

%cmake \
  -DUSE_SYSTEM_XZ=ON \
  -DUSE_SYSTEM_LIBARCHIVE=ON \
  -DUSE_SYSTEM_SQUASHFUSE=ON \
  -DUSE_SYSTEM_XDGUTILS=ON \
  -DUSE_SYSTEM_BOOST=ON

See https://build.opensuse.org/package/show/home:Mailaender:branches:system:packagemanager/libappimage for my failed attempts. I tried patching away the static library https://github.com/Mailaender/libappimage/tree/disable-static but that seems to make things worse.

hsitter commented 3 years ago

I feel like the code in src/libappimage/utils/StringSanitizer.h is not c++11 compliant. Specifically static constexpr in c++11 aren't implicitly inline (they are in c++17), hence the link problem because both translation units that use the header get their own definition.

Fixing this ought to be as trivial as prefixing the members with inline to make them explicitly inline.

TheAssassin commented 3 years ago

@apachelogger thanks, will push a fix soon.

@Mailaender I'll have a look at your problem afterwards.

TheAssassin commented 3 years ago

@apachelogger making those inline triggers a warning that inline variables were a C++17 extension.

src/libappimage/utils/StringSanitizer.h:14:76: warning: inline variables are only available with -std=c++1z or -std=gnu++1z
     static inline constexpr std::initializer_list<std::string::value_type> asciiLetters_ = {

Mind to share your version? Otherwise, we can also just make them const and initialize them in the .cpp file.

hsitter commented 3 years ago

Ah yes, best just make them const with a cpp definition. At a glance inline variables also were only adopted into the standard with c++17 :disappointed:

TheAssassin commented 3 years ago

@apachelogger your issue should be fixed, please open a new issue if the issue persists.

TheAssassin commented 3 years ago

@Mailaender your OBS setup seems to be broken:

screenshot_2020-09-17_19-21-42

I couldn't find any build logs there either. I'll try building it myself in a Tumbleweed container, with the options you provided.

TheAssassin commented 3 years ago

Couldn't find xdg-utils or squashfuse as libraries in Tumbleweed, so I built with cmake -DUSE_SYSTEM_XZ=ON -DUSE_SYSTEM_LIBARCHIVE=ON -DUSE_SYSTEM_SQUASHFUSE=OFF -DUSE_SYSTEM_XDGUTILS=OFF -DUSE_SYSTEM_BOOST=ON ... Build works fine there, cannot reproduce the issue...

Mailaender commented 3 years ago

I fixed the build for squashfuse in https://build.opensuse.org/request/show/823616

RossComputerGuy commented 3 years ago

I think we can close this now as the commit after the latest release fixes this. I've compiled libappimage myself and have had no linking issues.

Mailaender commented 3 years ago

Fix confirmed: https://build.opensuse.org/request/show/847938

TheAssassin commented 3 years ago

Should we make a new release then?

RogueScholar commented 3 years ago

Should we make a new release then?

It would be appreciated. I'm still tinkering with the automated build on Launchpad for this one, so it can then be slotted in as a Build-Dep for the AppImageLauncher PPAs and ideally obviate the madness where Debian/Ubuntu still ship v0.1.9 while other (less lazy? yes, packaging is hell but it only gets easier when effort is applied consistently...) distros like Neon do a much better job of keeping pace with upstream releases. Not a huge stumbling block, but dropping patches always feels very satisfying and lessens error potential. :mechanical_arm: