静态库未包含在生成的 LLVM 可执行文件中
我正在尝试使用 LLVM 编译 ac 程序,但在获取一些静态库时遇到问题。我已经使用 LLVM 成功编译了这些静态库,例如,存在 libogg.a 和 ogg.l.bc。
但是,当我尝试构建最终程序时,它不包含静态 ogg 库。我尝试了各种编译器选项,其中最值得注意的是:
gcc oggvorbis.c -O3 -Wall -I$OV_DIR/include -l$OV_DIR/lib/libogg.a -l$OV_DIR/lib/libvorbis.a -o test.exe
这会产生以下输出(为简洁起见,缩短了目录):
$OV_DIR/include/vorbis/vorbisfile.h:75: warning: ‘OV_CALLBACKS_DEFAULT’ defined but not used
$OV_DIR/include/vorbis/vorbisfile.h:82: warning: ‘OV_CALLBACKS_NOCLOSE’ defined but not used
$OV_DIR/include/vorbis/vorbisfile.h:89: warning: ‘OV_CALLBACKS_STREAMONLY’ defined but not used
$OV_DIR/include/vorbis/vorbisfile.h:96: warning: ‘OV_CALLBACKS_STREAMONLY_NOCLOSE’ defined but not used
llvm-ld: warning: Cannot find library '$OV_DIR/lib/ogg.l.bc'
llvm-ld: warning: Cannot find library '$OV_DIR/lib/vorbis.l.bc'
WARNING: While resolving call to function 'main' arguments were dropped!
我发现这令人困惑,因为 $OV_DIR/lib/ogg.l.bc 确实存在,就像 vorbis.l 一样。 bc 并且它们都是每个人都可读的(它们的包含目录也是如此)。
有人知道我做错了什么吗?
谢谢,
马特
I am trying to compile a c program using LLVM and I am having trouble getting some static libraries included. I have successfully compiled those static libraries using LLVM and, for example, libogg.a is present, as is ogg.l.bc.
However, when I try to build the final program, it does not include the static ogg library. I've tried various compiler options with the most notable being:
gcc oggvorbis.c -O3 -Wall -I$OV_DIR/include -l$OV_DIR/lib/libogg.a -l$OV_DIR/lib/libvorbis.a -o test.exe
This results in the following output (directories shortened for brevity):
$OV_DIR/include/vorbis/vorbisfile.h:75: warning: ‘OV_CALLBACKS_DEFAULT’ defined but not used
$OV_DIR/include/vorbis/vorbisfile.h:82: warning: ‘OV_CALLBACKS_NOCLOSE’ defined but not used
$OV_DIR/include/vorbis/vorbisfile.h:89: warning: ‘OV_CALLBACKS_STREAMONLY’ defined but not used
$OV_DIR/include/vorbis/vorbisfile.h:96: warning: ‘OV_CALLBACKS_STREAMONLY_NOCLOSE’ defined but not used
llvm-ld: warning: Cannot find library '$OV_DIR/lib/ogg.l.bc'
llvm-ld: warning: Cannot find library '$OV_DIR/lib/vorbis.l.bc'
WARNING: While resolving call to function 'main' arguments were dropped!
I find this perplexing because $OV_DIR/lib/ogg.l.bc DOES exist, as does vorbis.l.bc and they are both readable (as are their containing directories) by everyone.
Does anyone have any idea with what I am doing wrong?
Thanks,
Matt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如放松所说,
-l 后跟库名称。
例如,在Linux库命名约定中,
如果库名为 libogg,
-logg 将在库目录中查找并选择*最佳匹配。
您可以将目录添加到列表中:
gcc 可能会找到名称与请求的库名称匹配的静态库文件和共享库文件。
例如,
这就是为什么有一个 gcc 选项 -static
如果您只想直接使用共享或静态库文件,就像目标文件一样,
然后给出他们的路径,没有任何选择,比如
As unwind said,
-l is followed by the library name.
For example, in linux library naming conventions,
if a library is named libogg,
-logg will find and choose the *best match in the library directories.
You can add a directory into the list:
gcc may find both static and shared library files whose name matches with the requested library name.
For example,
That's why there is a gcc option, -static
If you just want to use a shared or static library file - directly, just as an object file,
then give their path without any option, like
我不认为
-l
选项需要路径。您应该将它们分开,并使用-L
选项来设置路径,然后只需使用带有-l
的普通库名称:另请注意,像这样使用时,您不要包含库名称的“lib”和“.a”部分。
I don't think the
-l
option expects paths. You should split those out, and use the-L
option to set the paths, then just use plain library names with-l
:Also note that when used like this, you don't include the "lib" and ".a" parts of the library name.