Application Fails if Lib not found, anyway to avoid this?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Application Fails if Lib not found, anyway to avoid this?
i was wondering if there is away to avoid application from closing if a specific library not found?
for example: if my application uses libPng and it wasn't found on the system running my app (binary and not source), is there anyway to just disable the part that uses png from my application?
thanks;
Click here to see the post LQ members have rated as the most helpful post in this thread.
It is kind of hard for us to tell you what libraries your application does or does not need. If your application doesn't need libpng, then don't link against it. If your code requires the functionality of libpng, then there isn't much you can do about it.
It is kind of hard for us to tell you what libraries your application does or does not need. If your application doesn't need libpng, then don't link against it. If your code requires the functionality of libpng, then there isn't much you can do about it.
Well, not quite. If the application can deal with other than PNG formats, and if the application is using dynamic libraries ( .so files under Linux), the the application can check library existence before using its functions:
man 3 dlopen
and friends, also look up
GNU libtool
which has convenient cross-platform wrappers and somewhat abstracts out linking.
@MS3FGX: i know what libraries it uses, but the problem is, if those libraries arent found on user pc the whole application wont start, im looking for away so it starts and just disable the part that uses this library
@Sergei Steshenko: are those dlopen and dlsym are like windows LoadLibrary and GetProcAddress? (Load a library and get its handle, and then find procedure addresses through this handle?
...
@Sergei Steshenko: are those dlopen and dlsym are like windows LoadLibrary and GetProcAddress? (Load a library and get its handle, and then find procedure addresses through this handle?
I don't know Windows programming; 'libtool' abstracts the details out, i.e. your code looks the same for both Windows and UNIXish systems, I think that even library file names can be forced to look the same rather than to have .so or .dll extensions.
i know its kinda late to post results, but, actually dlopen, dlsym, dlerror and all those require a library too :/ -ldl have to link dl library to that
is there anyway to avoid that? cause if it's not found, my app will still fail :S
I don't know what "-l command under gcc" means. As far as I know, gcc does not have a -l option. But graemef is referring to the -static option under gcc.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.