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