我编译了一个动态库libmyapi.so
gcc -fPIC -shared -o libmyapi.so myapi.c
然后编译测试程序,测试程序和库在同一个目录
gcc -o test test.c -L. -lmyapi
返回提示:
ld: 0706-006 Cannot find or open library file: -l myapi
ldpen(): A file or directory in the path name does not exist.
collect2: ld returned 255 exit status
但是使用
gcc -o test test.c -L. libmyapi.so
就可以编译过,而且test也能正常运行
请高手指教,上面方式有何问题?
使用file/ld/ldd查看
$ ld libmyapi.so
ld: 0711-327 WARNING: Entry point not found: __start
ld: 0711-244 ERROR: No csects or exported symbols have been saved.
$ ldd libmyapi.so
libmyapi.so needs:
/usr/lib/libc.
/unix
/usr/lib/libcrypt.a
$file libmyapi.so
libmyapi.so:executable (RISC System/6000) or object module not stripped
------解决方案--------------------------------------------------------
设置下LD_LIBRARY_PATH
------解决方案--------------------------------------------------------
Re