开发者

Using /clr and noclr libraries in one project

开发者 https://www.devze.com 2023-01-21 00:36 出处:网络
I am e开发者_C百科ncountering some issues with one project. I need to use two libraries but one needs to be compiled with the /clr switch as the other cannot be compiled with this switch.

I am e开发者_C百科ncountering some issues with one project. I need to use two libraries but one needs to be compiled with the /clr switch as the other cannot be compiled with this switch.

Would there be a way to use at the same time those two libraries in one project? Currently it's compiled with /clr and I got linking errors with the noclr library.

If there is no solution I can still launch the noclr library in batchmode but I'd like to avoid it...

My project is in Managed C++, the library tetgen - which needs /clr - is in native C++ and cannot be compiled without the /clr switch, as I get this error

error C3381: 'tetgenio' : assembly access specifiers are only available in code compiled with a /clr option

The other library triangle is in C. I am on Visual Studio 2008 and the project is compiled in 32 bits.


We could use more details, but using managed C++ you can certainly use a mix of managed and unmanaged code. (Microsoft calls their managed c++ code C++/CLI.)

EDIT:

Ok, your compiler error helped. Apparently you have specified a native class, but using public private, or some other access specifier on the name of the native class. From the MSDN docs:

The following sample generates C3381:

// C3381.cpp
**public** class A {   // C3381. Remove public or make the class
managed. }; 
int main() { }

so get rid of the public keyword, and then try compiling again.


You can have multiple projects in a single solution. Right click on the solution in the eolution explorer and add -> existing/new project. Each library project can be added that way and have their own clr settings.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号