c++ - Mac Lion 无法使用 'ar'、 'no symbols' 创建库

标签 c++ macos symbols unix-ar

我在 IO.h 和 IO.cpp 中有 C++ 源代码,想制作一个静态库 libvcf.a 。 然后我使用以下命令:

g++ -c IO.cpp

没问题。

但是,

ar -r libvcf.a IO.o

/usr/bin/ranlib: file: libvcf.a(IO.o) has no symbols

我现在使用的是 Mac OSX Lion,g++ 版本如下:

g++ -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.1~1/src/configure --disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.1~1/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)

看起来我可以在 Linux 上使用相同的命令,但不能在 Mac 上使用。 我也用谷歌搜索但没有运气。 这里有什么建议吗?谢谢。

最佳答案

我认为完整的命令应该是:

ar rcs libvcf.a IO.o

c 表示“创建存档”。

关于c++ - Mac Lion 无法使用 'ar'、 'no symbols' 创建库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8221608/

相关文章:

c++ - 如何获取放置在 MFC 对话框中的控件的大小和位置?

c++ - 二叉搜索树数组实现 C++

objective-c - NSWindow 不会在 OSStatus 事件处理程序方法中显示

javascript - Switch 语句如何与符号一起使用?

ruby - 符号的使用和符号表

c++ - strspn C++ 下的奇怪行为,为什么?

c++ - 如何避免写入核心文件并加速回溯生成

macos - Golang JSON 时间默认布局因平台而异?

macos - 在Xcode中使用FreeImage

c++ - 符号可见性和命名空间