Xilinx SDK中对dlopen.dlsym,dlclose的未定义引用

时间:2017-11-01 08:47:17

标签: c sdk linker shared-libraries dynamic-loading

我是Xilinx sdk的工作人员,我正在处理共享库,我使用了一个共享库( libhello.so )   aarch64-none-elf-gcc -shared -o libhello.so ../src/helloworld.o

在我的c文件中动态加载creatind库之后

void *handle;
void (*foo)(void);
handle = dlopen("/proj/ssw_xhd/boot/balakrish/workspace/hello_world/Debug/libhello.so", RTLD_GLOBAL);
foo = dlsym(handle,"foo");
if (foo){
    library_function();
}
dlclose(handle);

但我收到的错误如下

<artificial>:(.text.startup+0x18c): undefined reference to `dlopen'
<artificial>:(.text.startup+0x18c): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `dlopen'
<artificial>:(.text.startup+0x1a0): undefined reference to `dlsym'
<artificial>:(.text.startup+0x1a0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `dlsym'
<artificial>:(.text.startup+0x1a8): undefined reference to `library_function'
<artificial>:(.text.startup+0x1a8): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `library_function'
<artificial>:(.text.startup+0x1b0): undefined reference to `dlclose'
<artificial>:(.text.startup+0x1b0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `dlclose'
collect2: error: ld returned 1 exit status
make: *** [fsbl.elf] Error 1

此外,我尝试在 C / C ++ Build设置 - > ARM v8 gcc链接器 - &gt; libraries-&gt; libraries(dl) - &gt;库路径(/ usr / lib /或/ usr)中添加-ldl / lib64下/) 并且收到错误

Building target: fsbl.elf
Invoking: ARM v8 gcc linker
aarch64-none-elf-gcc -L"/proj/ssw_xhd/boot/balakrish/workspace/hello_world/Debug" -L/usr/lib64/ -L/usr/local/lib -Wl,-T -Wl,../src/lscript.ld -L../../fsbl_bsp/psu_cortexa53_0/lib -o "fsbl.elf"  ./src/psu_init.o ./src/xfsbl_authentication.o ./src/xfsbl_board.o ./src/xfsbl_bs.o ./src/xfsbl_csu_dma.o ./src/xfsbl_dfu_util.o ./src/xfsbl_exit.o ./src/xfsbl_handoff.o ./src/xfsbl_hooks.o ./src/xfsbl_image_header.o ./src/xfsbl_initialization.o ./src/xfsbl_main.o ./src/xfsbl_misc.o ./src/xfsbl_misc_drivers.o ./src/xfsbl_nand.o ./src/xfsbl_partition_load.o ./src/xfsbl_plpartition_valid.o ./src/xfsbl_qspi.o ./src/xfsbl_rsa_sha.o ./src/xfsbl_sd.o ./src/xfsbl_translation_table.o ./src/xfsbl_usb.o   -lhello -ldl -Wl,--start-group,-lxil,-lgcc,-lc,--end-group -Wl,--start-group,-lxilffs,-lxil,-lgcc,-lc,--end-group -Wl,--start-group,-lxilsecure,-lxil,-lgcc,-lc,--end-group -Wl,--start-group,-lxilpm,-lxil,-lgcc,-lc,--end-group -n
/wrk/released/2017.3/GA/2017.3_1005_1/installs/lin64/SDK/2017.3/gnu/aarch64/lin/aarch64-none/bin/../lib/gcc/aarch64-none-elf/6.2.1/../../../../aarch64-none-elf/bin/ld: cannot find -ldl
collect2: error: ld returned 1 exit status
make: *** [fsbl.elf] Error 1

14:08:01 Build Finished (took 5s.747ms)

1 个答案:

答案 0 :(得分:0)

如果你是从Linux(intel)交叉编译到arm,那么-L / usr / lib64 / -L / usr / local / lib 指向您的x86_64库而不是您的arm库