WilliamKF
WilliamKF

Reputation: 43179

How can I create a single Visual Studio project that mixes C and C++ using CLR?

I am working on porting code that builds on GCC on Unix to windows using Visual Studio 2008. I would like to create a single executable that does not depend on any dll(s) of my own creation and only built in ones to the Windows operating system.

My code includes zlib which itself includes C files which I can build and link fine into my Unix executable.

In my beginning attempts to build, the first error I hit is that the C code from zlib cannot be built with CLR since it is not C++.

I see some suggesting to break this out into a separate DLL which would be linked into my executable but I'd like to avoid the complexity of shared libraries if possible. (Perhaps this avoidance is even more complex?)

Is there a way to mix my C++ with the C code of zlib into a single executable with CLR?

My current build error is the following:

1>cl : Command line error D8045 : cannot compile C file '..\src\zlib-1.2.5\zutil.c' with the /clr option

Upvotes: 4

Views: 1484

Answers (1)

µBio
µBio

Reputation: 10758

You could change it to cpp to get it compiled by the C++ compiler (and fix any compile errors that introduces). That may be more difficult than just using a shared library (dll).

Upvotes: 3

Related Questions