469,903 Members | 2,056 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

Mixing Managed C and Unmanaged C - Big Problem

Hi

All the information I had read suggested that if you had an existing C
project that you wished to change to managed code all you had to do was use
the /clr switch and then over time you could convert/add managed code bit by
bit.

I have done this on my large C project and all compiles and links OK. So far
so good.

I have now added a managed C++ file to the project which needs to call some
of the existing code in the unmanaged C files. When I link this I get error
LNK1235.

This is referred to in
http://support.microsoft.com/default...b;en-us;822329
which says you cannot do this unless you compile the previous C code without
/clr.

As this is a large project I have turned off /clr on the project as a whole
and then set it on the new C++ managed file. Now I get a linker error
telling me there is an cannot find the external symbols of the functions I
am calling in the unmanaged C code and also if I try to add a Windows form
to the project (part of the purpose of doing all this), I get errors because
the project isn't set to use /clr.

Can ant one advise on the correct way if there is one of taking a large C
project and compiling/linking it so that I can add individual managed C+_
files and windows forms to it.

Thanks

Steve
Nov 17 '05 #1
1 1041
Hi

I have solved the problem. I needed to leave the properties for the project
to Use Managed Extensions under General for the Project but set all the
individual C files (which you can do by highlighting them as a block) to not
use Managed Extensions under General under C/C++.

I also needed to declare all my external functiosn and symbols as external
"C" so that I could see them from the C++ file

Steve

"Steve Marsden" <st***@conquest.ltd.uk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi

All the information I had read suggested that if you had an existing C
project that you wished to change to managed code all you had to do was
use the /clr switch and then over time you could convert/add managed code
bit by bit.

I have done this on my large C project and all compiles and links OK. So
far so good.

I have now added a managed C++ file to the project which needs to call
some of the existing code in the unmanaged C files. When I link this I get
error LNK1235.

This is referred to in
http://support.microsoft.com/default...b;en-us;822329
which says you cannot do this unless you compile the previous C code
without /clr.

As this is a large project I have turned off /clr on the project as a
whole and then set it on the new C++ managed file. Now I get a linker
error telling me there is an cannot find the external symbols of the
functions I am calling in the unmanaged C code and also if I try to add a
Windows form to the project (part of the purpose of doing all this), I get
errors because the project isn't set to use /clr.

Can ant one advise on the correct way if there is one of taking a large C
project and compiling/linking it so that I can add individual managed C+_
files and windows forms to it.

Thanks

Steve

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by kaalus | last post: by
4 posts views Thread by Daniel Lidström | last post: by
2 posts views Thread by quat | last post: by
3 posts views Thread by frank | last post: by
3 posts views Thread by frank | last post: by
2 posts views Thread by jraul | last post: by
2 posts views Thread by Jon Slaughter | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.