静态库问题 [英] static lib problem

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

问题描述

大家好,

我正在为普通的c编码创建一个静态的lib(sample.lib).我使用MSVC ++ 2005创建了静态库.在Visual Studio中,我在项目属性-> c/c ++-> Advanced-> compile as option中将编译器更改为编译为C代码(/TC)". br/>


如果我将此lib包含在另一个项目中(项目名称-示例).在示例项目中,我将编译选项更改为作为C ++代码编译".



对于静态lib文件中的所有功能,我得到了链接错误未解决的外部符号.对于选项默认",它也不起作用.我遇到了同样的错误.



如果更改,则将选项更改为编译为C代码".工作正常.我想使静态lib文件成为独立于编译器的文件.这个怎么做?请对此进行回复.



预先感谢您的答复.

Hi to everyone,

I''m creating a static lib(sample.lib) for ordinary c coding. I created the static lib using MSVC++ 2005. In the visual studio i changed the compiler as "Compile as C code (/TC)" in the project property->c/c++->Advanced->compile as option.



If i include this lib in another project(project name - sample). In the sample project, i changed the option in compile as to "Compile as C++ code".



I get linking error unresolved external symbol for all the function in the static lib file. It is also not working for the option "Default". I''m getting same error.



If the change the option to "Compile as C code". It''s working fine. I want to make the static lib file as compiler independent. How to do this? Please reply for this.



Thanks in advance for the replies.

推荐答案

您是否在下面的纯C标头声明中?
Do you have in your plain C header declaration below?

#ifdef __cplusplus
extern "C" {
#endif

....


#ifdef __cplusplus
}
#endif


这篇关于静态库问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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