我一直在努力与dlopen
和未定义的符号。C:处理共享对象中的未定义符号
我已经和到目前为止已经试过:与功能functionA()
libraryB.so这是使用functionA()
libraryA.a与功能functionA()
libraryA.so
执行能够加载libraryB.so与dlopen。
我得到的是:
undefined symbol: functionA
如何我构建:
LibraryA的:
gcc -std=gnu11 -O2 -g -Wall -Wstack-usage=2000 -Werror
-fdiagnostics-color -fPIC -pipe -fsigned-char -fno-asynchronous-unwind-tables
-fno-stack-protector -I../include/ libraryA.c -shared -o libraryA.so
libraryB:
gcc -std=gnu11 -O2 -g -Wall -Wstack-usage=2000 -Werror -fdiagnostics-color
-fPIC -pipe -fsigned-char -fno-asynchronous-unwind-tables
-fno-stack-protector -I../include/ libraryB.c -shared -o libraryB.so
建立可执行的:
-std=gnu99 -pipe -fno-strict-aliasing -fsigned-char -fno-asynchronous-unwind-tables
-fno-stack-protector -Wall -Wextra -Wundef -Wno-sign-compare -Wno-unused-parameter
-Wno-packed-bitfield-compat -Wno-misleading-indentation -fomit-frame-pointer
-maccumulate-outgoing-args -fPIC -m64 -g3 -gdwarf-2 -fno-common -Wstrict-prototypes
-Wimplicit -Wno-pointer-sign -c executable.c -o executable libraryA.a
打开libraryB在执行这样的位置:
void *handle = dlopen("libraryB.so", RTLD_LAZY);
if (handle == NULL) {
fprintf(stderr, "Load error (%s)!\n", dlerror());
return NULL;
}
我怎样才能解决这个问题?我也尝试过国旗-rdynamic没有成功。我也尝试了不同的dlopen标志,但也没有成功。
任何人都可以帮我吗?
这也是我用** - L **和** - l **选项尝试过的,但是我仍然有** libraryB中的未定义符号** – Elec
不,只是明确列出'libraryB.so'链接命令。 –
尚未解决。 'gcc -std = gnu11 -O2 -g -Wall -Wstack-usage = 2000 -Werror -fdiagnostics-color -fPIC -pipe -fsigned-char -fno-asynchronous-unwind-tables -fno-stack-protector -I ../ include/libraryA.so libraryB.c -shared -o libraryB.so' – Elec