keshavbhatt / whatsie

Feature rich WhatsApp Client for Desktop Linux
MIT License
1.95k stars 58 forks source link

unneeded depends at build time #50

Open asarubbo opened 2 years ago

asarubbo commented 2 years ago

This is what I can see on my side at link time:

x86_64-pc-linux-gnu-g++ -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -Wl,-z,lazy -Wl,-rpath-link,/usr/lib64 -o whatsie singleapplication.o singleapplication_p.o SunClock.o about.o automatictheme.o dictionaries.o downloadmanagerwidget.o downloadwidget.o elidedlabel.o lock.o main.o mainwindow.o permissiondialog.o rateapp.o settingswidget.o utils.o webenginepage.o webview.o scrolltext.o qrc_icons.o moc_singleapplication.o moc_singleapplication_p.o moc_about.o moc_autolockeventfilter.o moc_automatictheme.o moc_dictionaries.o moc_downloadmanagerwidget.o moc_downloadwidget.o moc_elidedlabel.o moc_lock.o moc_mainwindow.o moc_notificationpopup.o moc_permissiondialog.o moc_rateapp.o moc_requestinterceptor.o moc_settingswidget.o moc_utils.o moc_webenginepage.o moc_webview.o moc_scrolltext.o   -L/usr/X11/lib -lX11 /usr/lib64/libQt5WebEngine.so /usr/lib64/libQt5WebEngineWidgets.so /usr/lib64/libQt5WebEngineCore.so /usr/lib64/libQt5Quick.so /usr/lib64/libQt5PrintSupport.so /usr/lib64/libQt5Widgets.so /usr/lib64/libQt5Gui.so /usr/lib64/libQt5QmlModels.so /usr/lib64/libQt5WebChannel.so /usr/lib64/libQt5Qml.so /usr/lib64/libQt5Network.so /usr/lib64/libQt5Xml.so /usr/lib64/libQt5Positioning.so /usr/lib64/libQt5Core.so -lGL -pthread

while scanelf -n reports:

$ scanelf -n /usr/bin/whatsie 
 TYPE   NEEDED FILE 
ET_EXEC libX11.so.6,libQt5WebEngineWidgets.so.5,libQt5WebEngineCore.so.5,libQt5Widgets.so.5,libQt5Gui.so.5,libQt5Network.so.5,libQt5Positioning.so.5,libQt5Core.so.5,libstdc++.so.6,libm.so.6,libgcc_s.so.1,libc.so.6 /usr/bin/whatsie 

So, in the practice it forces me to have /usr/lib64/libQt5QmlModels.so (there are more examples above), but in the practice whatsie is not linked against it.

If I don't have /usr/lib64/libQt5QmlModels.so at build time it fails (expected) in that way:

/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find /usr/lib64/libQt5QmlModels.so: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:445: whatsie] Error 1

While if I don't have it at runtime it works as expected.

You can test this behavior by temporarily move the affected libraries, e.g:

mkdir tmplib
cd tmplib
mv /usr/lib64/libQt5QmlModels.so* .

# to revert back
mv * /usr/lib64/
M0Rf30 commented 2 years ago

here scanelf returns

 TYPE   NEEDED FILE 
ET_DYN libX11.so.6,libQt5WebEngine.so.5,libQt5WebEngineWidgets.so.5,libQt5WebEngineCore.so.5,libQt5Quick.so.5,libQt5PrintSupport.so.5,libQt5Widgets.so.5,libQt5Gui.so.5,libQt5QmlModels.so.5,libQt5WebChannel.so.5,libQt5Qml.so.5,libQt5Network.so.5,libQt5Positioning.so.5,libQt5Xml.so.5,libQt5Core.so.5,libGL.so.1,libstdc++.so.6,libm.so.6,libgcc_s.so.1,libc.so.6,ld-linux-x86-64.so.2 /usr/bin/whatsie

as you can see /usr/lib/libQt5QmlModels.so is required. judging from you lib path you're on a debian based distro, I suppose. On top of this if I move that library like you suggest it will fail with

whatsie: error while loading shared libraries: libQt5QmlModels.so.5: cannot open shared object file: No such file or directory

So maybe it depends on compile flags used by the distro and related to Qt5 toolkit. For precaution I would leave as is

asarubbo commented 2 years ago

I'm on gentoo, not any debian-based distro.

as you can see /usr/lib/libQt5QmlModels.so is required.

Please forget for a second the scanelf output. Is the whatsie code using something from libQt5QmlModels.so ? I don't guess so because,if yes, I'd expect runtime problems on my side, but I may be wrong.

In the way it is atm, who wants to build whatsie needs to have a lot of depends that aren't really required and that's a bit a nosense.

asarubbo commented 2 years ago

From my understanding, those are the required libraries:

-lX11
/usr/lib64/libQt5WebEngineWidgets.so
/usr/lib64/libQt5WebEngineCore.so
/usr/lib64/libQt5Widgets.so
/usr/lib64/libQt5Gui.so
/usr/lib64/libQt5Network.so
/usr/lib64/libQt5Positioning.so
/usr/lib64/libQt5Core.so

In other words I'm able to link with only the mentioned libraries. If you remove one of them from the command line link, you will get undefined reference to.. because the code is using something provided by those libraries. If you remove the rest, you have a working whatsie ELF. Hope is clear now.

asarubbo commented 2 years ago

When it will be sorted out / fixed, I'll put it in the gentoo tree official repository.