c – ldd表示编译完成后找不到库

前端之家收集整理的这篇文章主要介绍了c – ldd表示编译完成后找不到库前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试编译项目.它编译成功.我的make命令以状态代码0退出,并且没有显示错误.

但是,该项目不起作用,当我运行ldd -d< file>它表明我有两个未找到的库.

>ldd -d output_file.so
    linux-gate.so.1 =>  (0xf77e0000)
    libvstdlib_srv.so => not found
    libtier0_srv.so => not found
    libm.so.6 => /lib/libm.so.6 (0xf7760000)
    libdl.so.2 => /lib/libdl.so.2 (0xf775b000)
    libc.so.6 => /lib/libc.so.6 (0xf75a9000)
    /lib/ld-linux.so.2 (0x46e4a000)
undefined symbol: pfVectorNormalize     (output_file.so)
undefined symbol: _Z12VectorAnglesRK6VectorR6QAngle     (output_file.so)
undefined symbol: pfSqrt       (output_file.so)
undefined symbol: __cxa_guard_acquire   (output_file.so)
undefined symbol: __cxa_guard_release   (output_file.so)
undefined symbol: _Z6ConMsgPKcz (output_file.so)
undefined symbol: Warning      (output_file.so)
undefined symbol: __dynamic_cast        (output_file.so)
undefined symbol: _Z11ConColorMsgRK5ColorPKcz   (output_file.so)
undefined symbol: Error (output_file.so)
undefined symbol: AssertValidStringPtr  (output_file.so)
undefined symbol: _AssertValidWritePtr  (output_file.so)
undefined symbol: _AssertValidReadPtr   (output_file.so)
undefined symbol: _ZTVN10__cxxabiv121__vmi_class_type_infoE     (output_file.so)
undefined symbol: _ZTVN10__cxxabiv120__si_class_type_infoE      (output_file.so)
undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE (output_file.so)
undefined symbol: __gxx_personality_v0  (output_file.so)

这两个库被设置为指向文件实际位置的符号链接

...
lrwxrwxrwx 1 Andy Andy    62 May  2 12:30 libtier0_srv.so -> /home/dev/sdks/hl2sdk-ob-valve/lib/linux/libtier0_srv.so
lrwxrwxrwx 1 Andy Andy    64 May  2 12:30 libvstdlib_srv.so -> /home/dev/sdks/hl2sdk-ob-valve/lib/linux/libvstdlib_srv.so
-rw-r--r-- 1 Andy Andy  5444 May  2 11:53 Makefile
...

正在运行的gcc命令是

gcc -I / home / dev / sdks / hl2sdk-ob-valve / public / game / server -I. -I .. -ICEntity -Isdk -I / home / dev / project1 / hl2sdk-ob-valve / public -I / home / dev / sdks / hl2sdk-ob-valve / public / engine -I / home / dev / sdks / hl2sdk-ob-valve / public / tier0 -I / home / dev / sdks / hl2sdk-ob-valve / public / tier1 -I / home / dev / sdks / hl2sdk-ob-valve / public / mathlib -I / home / dev / project1 / mmsource-central / core -I / home / dev / project1 / mmsource-central / core / sourcehook -I / home / dev / project1 / sourcemod-central / public -I / home / dev / project1 / sourcemod -central / public / sourcepawn -I / home / dev / project1 / sourcemod-central / core project1_output / sdk / smsdk_ext.o project1_output / extension.o project1_output / CTrackingProjectile.o project1_output / CSentryRocket.o project1_output / CProjectileRocket.o project1_output / CProjectileArrow .o project1_output / CProjectileFlare.o project1_output / CProjectilePipe.o project1_output / CProjectileSyringe.o project1_output / CEntity / CEntity.o project1_output / CEntity / CEntityManager.o project1_output / CEntity / CPlayer.o / home / dev / project1 / hl2sdk-ob-valve /lib/linux/tier1_i486.a libvstdlib_srv.so libtier0_srv .so -m32 -lm -ldl -static-libgcc -shared -o project1_output / output_file.so

我的问题是:
1.)为什么即使它们符号链接也找不到这两个库?
2.)未定义的符号是mathlib包的一部分,它包含在gcc命令中. -I / home / dev / sdks / hl2sdk-ob-valve / public / mathlib为什么这些是未定义的,尽管被包括在内?

c不是我选择的语言,我对Makefile有足够的了解是危险的,但并不是真的要解决任何问题,所以如果这些信息不够,我会道歉.我可以根据需要提供更多.

解决方法

文件是共享对象,这意味着它们在运行时才会被解析.为了让ldd找到它们(假设Linux或其他Unix变体),你需要将库的路径添加到LD_LIBRARY_PATH(还有另一个可以使用的路径env,但我现在想不到它)然后ldd应该能够找到库.

猜你在找的C&C++相关文章