AppImageCommunity / libappimage

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

libappimage_static.a: why is it generated and how come it does not work. #172

Closed gholmann16 closed 2 years ago

gholmann16 commented 2 years ago

When I use your script to generate libappimage, it also generates a lib called libappimage_static.a. When I try to swap the shared library for this static lib it does not even work. Is this .a file even supposed to be usable or not? If not, why is it even generated.

TheAssassin commented 2 years ago

I have no idea what you are talking about or trying to accomplish. "It does not work" doesn't work as a bug report. Please read https://www.chiark.greenend.org.uk/~sgtatham/bugs.html and provide more details afterwards.

gholmann16 commented 2 years ago

When I built your libappimage library, looking through the files I found one called libappimage_static.a. Found under: (path of build folder)/build/src/libappimage/libappimage_static.a When I tried to swap this in for the standard shared library in order to make my own binary static, I got many errors. My original compilation line was: gcc src/main.c -lappimage. Once I changed this to gcc src/main.c ../libappimage/build/src/libappimage/libappimage_static.a, I got a ton of undefined references. I realized this library was written in C++, so then I changed to g++. But alas I still get a ton of undefined references, which I'm guessing means this library still needs all its dependencies. I had thought that it had packaged all the dependencies with it because it claimed to be static and is twice the size of the standard so. This leaves me wondering if I'm doing something wrong of if there is another use to this libarary of if it is just an accident.

TheAssassin commented 2 years ago

That's completely normal behavior. You're not supposed to manually link the binary like that. This cannot work. You need to use CMake. Using the static library without CMake is a completely unsupported scenario.

(When using a static library, you'd have to pass all the dependencies again on the CLI, since static libraries never link any dependencies, that is by design. CMake can automate this for you.)

gholmann16 commented 2 years ago

I can completely get behind that, and I could see the use for it. From what I understand you're telling me that it is essentially the same, dependent library, just without all the dynamic links. I'm just wondering why its almost double the size. For reference, the static library is 4.7 megabytes whereas the dynamically linked one is 2.2 megabytes alone (the standalone static libs both weigh under 20 kB).