Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / December 2004

Tip: Looking for answers? Try searching our database.

Mixing Managed C and Unmanaged C - Big Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Marsden - 02 Dec 2004 11:27 GMT
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.aspx?scid=kb;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
Steve Marsden - 02 Dec 2004 13:17 GMT
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

> Hi
>
[quoted text clipped - 29 lines]
>
> Steve

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.