C主项目中的C ++静态库

时间:2015-06-03 15:19:10

标签: c++ c visual-studio-2010

我的VS2010项目在C中有2个静态库。我想添加另一个,但是在C ++中。我的主要项目已经在C中,所以我的目标是尽可能地改变它。是否可以在C ++中添加另一个静态库?怎么样? 我已经链接了项目,只在#34; main.cpp"中包含了标题。但是我得到了这个错误:

"1>c:\program files (x86)\microsoft visual studio
10.0\vc\include\cmath(19): error C2061: syntax error : identifier 'acosf' 1>c:\program files (x86)\microsoft visual studio
10.0\vc\include\cmath(19): error C2059: syntax error : ';' 1>c:\program files (x86)\microsoft visual studio
10.0\vc\include\cmath(19): error C2061: syntax error : identifier 'asinf' 1>c:\program files (x86)\microsoft visual studio
10.0\vc\include\cmath(19): error C2059: syntax error : ';' 1>c:\program files (x86)\microsoft visual studio
10.0\vc\include\cmath(20): error C2061: syntax error : identifier 'atanf' 1>c:\program files (x86)\microsoft visual studio
10.0\vc\include\cmath(20): error C2059: syntax error : ';' 1>c:\program files (x86)\microsoft visual studio
10.0\vc\include\cmath(20): error C2061: syntax error : identifier 'atan2f' 1>c:\program files (x86)\microsoft visual studio
10.0\vc\include\cmath(20): error C2059: syntax error : ';'

我已经看到的解决方案告诉我用C ++编译主项目,我不能这样做。

1 个答案:

答案 0 :(得分:1)

如果你不能用C ++编译MainProject,你可以为C ++库编写一个包装器来处理你需要的功能。

基本上构建另一个链接在C ++库中的库。它应提供extern "C"的功能,您可以从C应用程序中调用它们。

点击此链接了解更多信息:http://www.teddy.ch/c++_library_in_c/