this post was submitted on 29 Jun 2023
3 points (100.0% liked)

Linux Questions

31 readers
5 users here now

A place to ask Linux-related questions, post advice and suggestions, etc. Any questions pertaining to Linux from novice to greybeard level are welcome. ---- ### Asking Questions: Please provide enough info to for people to actually help you. While there are some things that are generally the same, there is no one "Linux" - every distro has some things they do different and you'll get better answers if you provide some info. And remember the people here are helping you purely out of their own good will - so be nice! If you are encountering a problem, please include: 1. Which distro you are using 2. A brief summary of the problem 3. Any steps you have attempted 4. Relevant details such as hardware specs (see below), application versions, etc. ---- ### Capturing System Specs In almost all cases, posting output from inxi -Fmz - either as in a code block, as a linked file, or as a screenshot - will be appreciated. Some distros may pre-install inxi but on others (such as Fedora), you may need to install it yourself. But we understand that there will be times when you are unable to provide this info (such as with boot problems). The output from inxi info should be safe (especially with the -z option)... But in general,**YOU SHOULD ALWAYS REVIEW OUTPUT AND REMOVE ANY PRIVATE DATA BEFORE POSTING ONLINE** (e.g. replace "Your Name" with `` or something similar - this helps in preventing doxxing, identity theft, and similar issues). - Some common graphical screenshot apps:gnome-screenshot, ksnip, shutter, and flameshot . There are also terminal-based ones like maim and scrot.

founded 1 year ago
 

Hello. I was wondering which command would allow me to know factually check which graphic library an application uses?

For instance, which UI library does telegram or firefox use? strace wouldn't work for that purpose as it deals with system calls, right? What about ltrace which works for library calls? I was able to find some gtk strings in the output of ltrace, but mostly strncmp(), strchr(), strlen(), memchr(), and one setenv(GTK_IM_MODULE, "gtk-im-context- simple"). Is that enough to conclude the process uses gtk?

It's a little verbose, so I wondered what about lsof to show open files. lsof -p <pid> shows me that the pid opens up libgtk-3.0.so... That seems conclusive enough, right? There wouldn't be any reason to open that libgtk-3.0.so shared object if it didn't use gtk?

Seems like lsof is better for getting this information rather than ltrace, right?

In the specific case of firefox, lsof does show that firefox uses libgtk-3.0.so as well as something called libmozgtk.so so I guess they don't fully use gtk, but their own thing as well?

In summary, what's the best and most reliable command to figure out which graphic library (QT, GTK, something else) an application uses? lsof?

Thanks

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 1 points 1 year ago (1 children)

Would ldd do what you want?

EDIT: Had more time to look, and found out this would not work, at least for my distro. Using ldd may not work depending on how Firefox was compiled -- it works only if the library you are interested in is dynamically linked.

For me, if I run command -v firefox, I get /usr/bin/firefox. Running ldd /usr/bin/firefox results in an error: not a dynamic executable. It turns out that, for me, /usr/bin/firefox is just a small script that calls /usr/lib/firefox/firefox. Running ldd on that file produces the following:

linux-vdso.so.1 (0x00007ffe4e2e7000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f75eb400000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f75eb318000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f75eb6ae000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f75eb131000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f75eb7ba000)

None of these look like a library of interest to you, so the library you want must have been statically linked.

(As a side note, don't use ldd on an untrusted executable b/c it may run the executable to get the information.)

In that case, if you really want to dig, you can try something like readelf to dump info about the executable. If you know what you're looking for (such as GTK), you might be able to grep for it. However, my version of Firefox has the symbol table stripped, so I don't think there's much else I can do.

And of course, if you have open-source software, you can always just go check the source code :)

[โ€“] [email protected] 1 points 1 year ago

Thanks a lot for your reply, learned a lot of things!

In Fedora /usr/bin/firefox also is a bash script so I ran into the same not a dynamic executable issue as well. readelf looks interesting, I'll have to play around with it.