Dlopen Linux Dynamic Library failure Reason and solution summary

Source: Internet
Author: User

1, Dlopen Dynamic Library failure reasons, I met mainly the following points (after encountering new problems, then perfect, first hit a point)
① Dynamic Library Location There is no lil bit place, Dlopen can not find the dynamic library you want to operate
Workaround: Drop to the specified directory.
② header file does not have a full package, there are unrecognized functions or identifiers
Workaround: Add a print message, the program will run here, the output unrecognized identifier.

if((handle = dlopen(myso, RTLD_NOW)) == NULL) {          printf("dlopen - %sn", dlerror());          exit(-1);      }  

or with LDD (see Compiler cross-chain, here is a dynamic library written in GCC, other cross-compilation chain depending on the situation).
③makefile Writing problems
① does not specify the-fpic compilation option (position-independent code is location independent);
② does not specify-shared external programs to access this dynamic library.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Dlopen Linux Dynamic Library failure Reason and solution summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.