如何在visual studio中链接.a lib文件 [英] how to link with .a lib file in visual studio

查看:954
本文介绍了如何在visual studio中链接.a lib文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将.a库文件添加到我的视觉中工作室项目。我已经包含了项目属性的路径。但它没有认识到这些课程。
我知道.lib文件在windows中工作。有没有办法在Visual Studio中使用.a文件?

解决方案

这可能有几个原因。


两个明显的例子是.a文件是用于动态链接库(.dll.a),那么GCC / binutils使用的格式与Microsoft使用的格式不同。


其次,既然你提到了类,那么如果这是一个C ++项目,那么GCC项目命名的方式与微软命名它们的方式不同。这意味着,当您在Visual Studio项目中使用它们时,编译器期望以
命名的一种方式,当它为函数调用生成代码时,它将使用这些名称。但是当链接器尝试将所有内容链接在一起时,它无法在库中找到这些名称。


至少对于C ++,名称修改不是标准化的,这就是使用C的原因函数名称是尝试执行此操作时使用的函数。


您必须提供有关您尝试执行的操作的更多信息,但通常有解决方法。


I am trying to add an .a library file to my visual studio project. I have included the path from project properties. But it is not recognizing the classes. I know .lib files work in windows. Is there any way to use .a files with visual studio?

解决方案

There could be a couple of reasons for this.

The two obvious ones are if the .a file is for a dynamic link library (.dll.a) then the format that GCC/binutils uses is different from what Microsoft uses.

Secondly, since you mentioned classes, if this is a C++ project then the way the GCC project names things is different from how Microsoft names them. This means, when you use them in your Visual Studio project, the compiler is expecting one way of naming things and when it generates code for the function calls, it will use those names. But when the linker tries to link everything together it isn't able to find those names in the libraries.

For C++ at least, name mangling isn't standardised, which is why using C function names is what is used when trying to do this.

You will have to provide more information on what you are trying to do though, but there are generally ways around this.


这篇关于如何在visual studio中链接.a lib文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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