简体   繁体   English

C Main Project中的C ++静态库

[英]C++ Static Library in C Main Project

My VS2010 project has 2 Static Libraries in C. I want to add another one, but in C++. 我的VS2010项目在C中有2个静态库。我想添加另一个,但是在C ++中。 My main project is already in C, so my objective is to change it the minimum possible. 我的主要项目已经在C语言中,因此我的目标是尽可能地对其进行更改。 Is it possible to add another static library in C++? 是否可以在C ++中添加另一个静态库? How? 怎么样? I already link the projects and only include the header in "main.cpp". 我已经链接了项目,并且仅在“ main.cpp”中包含标题。 But I get this error: 但是我得到这个错误:

"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 : ';'

The solutions that I already see, tell me to compile the main project in C++, which I can't do. 我已经看到的解决方案告诉我用C ++编译主项目,而我做不到。

If you can't compile the MainProject in C++ you could write a wrapper for your C++ Library to handle the functionality you need. 如果您不能用C ++编译MainProject,则可以为C ++库编写包装器以处理所需的功能。

Basically build another library which links in the C++ library. 基本上建立另一个链接到C ++库的库。 It shall provide the functions as extern "C" and you can call them from your C application. 它应提供作为extern "C"的功能,您可以从C应用程序中调用它们。

Check this link for more Information: http://www.teddy.ch/c++_library_in_c/ 检查此链接以获取更多信息: http : //www.teddy.ch/c++_library_in_c/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM