Bazel无法包含外部静态库.a [英] Bazel failed to include a external static library .a

查看:532
本文介绍了Bazel无法包含外部静态库.a的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-问题已解决-

此问题已解决.感谢您的所有帮助!

This question is solved. Thanks for all the help!

此问题及其原因在以后向其他读者简要说明:

The problem and the reason is briefly stated as following for other readers in the future:

[环境]

Ubuntu 14.04,Bazel,C ++

Ubuntu 14.04, Bazel, C++

[问题]

我想包含一个外部库.因此,我下载了源文件,并将其作为静态lib .a.

I want to include an external library. So I download the source file and make it as as a static lib .a.

我正确设置了BUILD,WORKSPACE和相关文件.但是,在编译时,它会提示错误:

I correctly set the BUILD, WORKSPACE and related files. However, when compile, it alerts the error:

Linking of rule '//main' failed (Exit 1)
main: error: undefined reference to 'void ex_lib::compute(double*, double const*, double const*)'
collect2: error: ld returned 1 exit status

我在这里尝试了.lo和alwayslink方法,但是不起作用.

I tried with the .lo and alwayslink method here but doesn't work.

替换为`--whole-archive`"淡褐色

[原因]

这是因为外部库源文件包含重复的头文件.所以我解决了头文件的问题.再次输入.a.然后一切正常.

It is because that the external library source files contains duplicate header files. So I fix the header file problem. Make the .a again. Then everything works.

因此挡板没有任何问题.是库本身引起了问题.但是错误信息令人困惑,我认为这是由淡色引起的.

So nothing wrong with the bazel. It is the library itself that cause the problem. But the error information is confusing and I think it is caused by bazel.

推荐答案

问题已解决.特别感谢mhlopko.

The problem is solved. Special thanks to mhlopko.

主要是因为lib源文件存在错误.因此,我使用的.a文件包含错误.现在,bazel可以与新的lib文件一起正常工作了.

It is mainly because there is errors with the lib source file. Thus .a file I use contains errors. Now the bazel works fine with the new lib file.

顺便说一句,现在bazel与我生成的.a或.so文件都可以正常工作.

By the way, now bazel works fine with both .a or .so file that I generated.

这篇关于Bazel无法包含外部静态库.a的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆