473,321 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

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 1238
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: kaalus | last post by:
Hello I have problem mixing managed and unmanaged C++ code in VS.NET 2003. I want to create a windows forms application which uses some C++ code that is incompatible with managed extensions...
4
by: Daniel Lidström | last post by:
Hello, is it possible to ``use CS to code a class, and (M)C++ for the logic''? Sorry if this sounds vague, I'm not really sure myself what it means. Does anyone have any ideas? -- Daniel
14
by: Jon | last post by:
Whether I can compile a class or not, depends on the order of functions in my class. My question is (see example below): 1) Is it a bug that the class 'WillCompile' will compile and execute, or...
2
by: quat | last post by:
I am getting the error: error C4368: cannot define 'd3dPP' as a member of managed 'FormEx::Form1': mixed types are not supported I am trying to mixed managed and unmanaged code (d3dPP is...
3
by: frank | last post by:
Hi I've got aplication, which one is written in unmanaged c++ with stl, i've made for it gui in managed c++. Problem becomes when I'm starting to filling up for example datagrids, when I'm...
3
by: frank | last post by:
Hi I've got aplication, which one is written in unmanaged c++ with stl, i've made for it gui in managed c++. Problem becomes when I'm starting to filling up for example datagrids, when I'm...
0
by: HeroOfSpielburg | last post by:
Hello, I'm new to the realm of .NET application creation, so please forgive my ignorance. I have been tasked with debugging a problem that arises with using a DLL that contains managed and...
2
by: jraul | last post by:
Hi, This is probably a noobie question but: I just created a new C++/CLI project in VS 2005. It created an empty class: public ref class Class1 { // TODO: Add your methods for this class...
2
by: Jon Slaughter | last post by:
How difficult is it for one to integrate unmanaged C++ into C#? I know for functions one can use DLLimport but how does one go about doing it for classes? Do I have to completely reimplement the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.