gpt4 book ai didi

c - Xilinx SDK 中对 dlopen.dlsym、dlclose 的 undefined reference

转载 作者:行者123 更新时间:2023-11-30 16:39:27 31 4
gpt4 key购买 nike

我正在 Xilinx sdk 中工作,我正在研究共享库,并且我使用以下方法创建了一个共享库(libhello.so)
aarch64-none-elf-gcc -shared -o libhello.so ../src/helloworld.o

创建库后,我动态加载到我的 c 文件中

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链接器->库->库(dl)->库路径(/usr/lib/或/usr/lib64/)中添加-ldl 并得到错误为

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)

最佳答案

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

关于c - Xilinx SDK 中对 dlopen.dlsym、dlclose 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47051104/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com