gcc - 无法将 portaudio 库链接为静态库

标签 gcc linker arm portaudio

我需要将库(portaudio)链接为静态库。当我执行以下操作时

arm-none-linux-gnueabi-gcc -static -L/media/Data/lib/.libs -lportaudio prova.cpp

链接失败告诉我

/tmp/ccuoQi1J.o: In function `main':
prova.cpp:(.text+0x190): undefined reference to `Pa_Initialize'
prova.cpp:(.text+0x1bc): undefined reference to `Pa_GetDeviceCount'
prova.cpp:(.text+0x1d8): undefined reference to `Pa_GetDeviceInfo'
prova.cpp:(.text+0x248): undefined reference to `Pa_OpenDefaultStream'
prova.cpp:(.text+0x27c): undefined reference to `Pa_CloseStream'
prova.cpp:(.text+0x280): undefined reference to `Pa_Terminate'
collect2: ld returned 1 exit status

虽然没有 -static 选项,链接不会出现错误

arm-none-linux-gnueabi-g++ -L/media/Data/lib/.libs -lportaudio prova.cpp

我需要静态链接所有库,可能吗?

最佳答案

来自gcc linking options ,

-static

On systems that support dynamic linking, this prevents linking with the shared libraries. On other systems, this option has no effect.

在这里,所有 undefined symbol 都在 libportaudio 库中,这是一个共享库,您通过指定 -static 来阻止链接到它,因此会出现错误。 gcc 无法在指定的库路径 (/media/Data/lib/.libs) 中找到 libportaudio 的静态版本

为什么要静态链接该共享库?有什么具体原因吗?

您可能想阅读本文以了解有关 gcc 如何处理 shared and static libraries. 的更多信息

关于gcc - 无法将 portaudio 库链接为静态库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9992204/

相关文章:

c++ - 从 OSX 平台转换并使用 gcc 和 llvm 时构建失败

c++ - 获取错误 'char16_t and char32_t undeclared'

assembly - 如果目标文件定义了 _start 并且不使用任何库,为什么我仍然需要链接它才能执行它?

linux - ARM:禁用 MMU 并更新 PC

python - GCC 未编译 Cython 扩展

c - 如何在不使用 LD_LIBRARY_PATH 的情况下链接 makefile 中共享库的特定版本?

linux - 使用 UBUNTU 和 arm-linux-gnueabi-gcc 为 ARM linux 交叉编译 JamVM - 缺少 zlib

c++ - 为 arm 设置 visual studio express

iphone - iOS - 升级到 Xcode 4.5 后链接器错误,可能与 Core Plot 相关

c++ - 在 OSX 的 xcode 中查找 glfw 库文件?