Importing a C project into .NET, and book recommendations

H

Howard Kaikow

I have files to build a C project, including the makefile, what's the
easiest way to import the project into C and C# in VS .NET Professional? I
have both VS .NET 2002 and 2003.

I have nothing but VB .NET books.
I guess it's time to get a book for each of C++ and C# in .NET.
Any recommendations
 
N

Nicholas Paldino [.NET/C# MVP]

Howard,

C# is not the same as C/C++. While there are many similarities, you can
not take the files from one and compile them in another and it will work (in
some cases yes, but in many, no).

If you have a lot of functionality in C/C++, then you might want to
consider accessing that functionality through the P/Invoke layer (if you
have functions exported from DLLs), COM interop (if you have objects exposed
through COM), or creating managed wrappers using Managed Extensions for C++
(if you have class libraries that don't fit into either of the conditions
above). Of course, you can do a conversion to C# if you have the time as
well, but the first three will save you more time, if you are under that
constraint.

Hope this helps.
 
H

Howard Kaikow

Thanx.

Let me clarify.

The C code is not complex, just simple demonstrations of sorting algorithms.
It likely would not be difficult to start a C# or C++ project in .NET and
copy the code.
I was just hoping to find an easier way.

Should be someway to tell .NET to make a project from the makefile.

--
http://www.standards.com/; See Howard Kaikow's web site.
Nicholas Paldino said:
Howard,

C# is not the same as C/C++. While there are many similarities, you can
not take the files from one and compile them in another and it will work (in
some cases yes, but in many, no).

If you have a lot of functionality in C/C++, then you might want to
consider accessing that functionality through the P/Invoke layer (if you
have functions exported from DLLs), COM interop (if you have objects exposed
through COM), or creating managed wrappers using Managed Extensions for C++
(if you have class libraries that don't fit into either of the conditions
above). Of course, you can do a conversion to C# if you have the time as
well, but the first three will save you more time, if you are under that
constraint.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Howard Kaikow said:
I have files to build a C project, including the makefile, what's the
easiest way to import the project into C and C# in VS .NET
Professional?
 
N

Nicholas Paldino [.NET/C# MVP]

Howard,

You can compile C++ code in .NET, but you will have to make some
adjustments. For example, if it is not object oriented code, then you will
have to make it so that it is (using static methods instead of having
functions, for example).

Also, I don't believe that the IDE knows about makefiles. Rather, you
will have to create a project file and add your files to the project.

You can still use NMAKE to compile your files with the makefile.
However, this will give you just what you had before, an unmanaged dll.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Howard Kaikow said:
Thanx.

Let me clarify.

The C code is not complex, just simple demonstrations of sorting algorithms.
It likely would not be difficult to start a C# or C++ project in .NET and
copy the code.
I was just hoping to find an easier way.

Should be someway to tell .NET to make a project from the makefile.

--
http://www.standards.com/; See Howard Kaikow's web site.
message news:[email protected]...
Howard,

C# is not the same as C/C++. While there are many similarities, you can
not take the files from one and compile them in another and it will work (in
some cases yes, but in many, no).

If you have a lot of functionality in C/C++, then you might want to
consider accessing that functionality through the P/Invoke layer (if you
have functions exported from DLLs), COM interop (if you have objects exposed
through COM), or creating managed wrappers using Managed Extensions for C++
(if you have class libraries that don't fit into either of the conditions
above). Of course, you can do a conversion to C# if you have the time as
well, but the first three will save you more time, if you are under that
constraint.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Howard Kaikow said:
I have files to build a C project, including the makefile, what's the
easiest way to import the project into C and C# in VS .NET
Professional?
I
have both VS .NET 2002 and 2003.

I have nothing but VB .NET books.
I guess it's time to get a book for each of C++ and C# in .NET.
Any recommendations
 
H

Howard Kaikow

I found something in the online Help yesterday about using File | Open
Workspace, and the IDE did open the makefile, but then I could not figure
out what to do.

I spent a lot of time searching through the .NET Help to no avail.
Surely, the importing of the vast amount of extant code has to be a high
priority item.

But I've not been able to find out how to do the deed.

I do have an old copy of VS C/C++ 6 learning editions that came with books.
I could build a project there and then let .NET import the critter, but
there should be a more direct way.

--
http://www.standards.com/; See Howard Kaikow's web site.
Nicholas Paldino said:
Howard,

You can compile C++ code in .NET, but you will have to make some
adjustments. For example, if it is not object oriented code, then you will
have to make it so that it is (using static methods instead of having
functions, for example).

Also, I don't believe that the IDE knows about makefiles. Rather, you
will have to create a project file and add your files to the project.

You can still use NMAKE to compile your files with the makefile.
However, this will give you just what you had before, an unmanaged dll.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Howard Kaikow said:
Thanx.

Let me clarify.

The C code is not complex, just simple demonstrations of sorting algorithms.
It likely would not be difficult to start a C# or C++ project in .NET and
copy the code.
I was just hoping to find an easier way.

Should be someway to tell .NET to make a project from the makefile.

--
http://www.standards.com/; See Howard Kaikow's web site.
message news:[email protected]...
Howard,

C# is not the same as C/C++. While there are many similarities,
you
can
not take the files from one and compile them in another and it will
work
(in
some cases yes, but in many, no).

If you have a lot of functionality in C/C++, then you might want to
consider accessing that functionality through the P/Invoke layer (if you
have functions exported from DLLs), COM interop (if you have objects exposed
through COM), or creating managed wrappers using Managed Extensions
for
C++
(if you have class libraries that don't fit into either of the conditions
above). Of course, you can do a conversion to C# if you have the time as
well, but the first three will save you more time, if you are under that
constraint.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


I have files to build a C project, including the makefile, what's the
easiest way to import the project into C and C# in VS .NET Professional?
I
have both VS .NET 2002 and 2003.

I have nothing but VB .NET books.
I guess it's time to get a book for each of C++ and C# in .NET.
Any recommendations
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top