Discussion:
Porting code from Linux to Windows
(too old to reply)
Rayne
2009-11-20 09:41:56 UTC
Permalink
Hi all,

I'm using Visual Studio .NET 2003, and I'm trying to port code I've
written and compiled/run successfully in Linux GCC to Windows.

I'm a newbie when using VS. I've created a new project, and added all
the .c and .h files I have into the project by Project -> Add Existing
Items, then chose all the .c and .h files.

I'm not familiar with how exactly compilers and linkers etc work, but
is there a difference between how VS and gcc compile/link #include
files? My habit of programming in Linux has been to have one main.c
file, and #include all other .h or .c files that I need. Then I would
only compile the main.c file. But in VS, it seems as if the #include
files are not "seen" by the program, because I'm getting errors that
tell me certain structures or variables were not declared, even though
they are in my user-defined header files.

I'm also getting errors like DIR is an undeclared identifier. I've
included , so why can't it recognize DIR?

Thank you.

Regards,
Rayne
Gerry Hickman
2009-11-20 22:13:33 UTC
Permalink
Hi,

You should be able to write cross-platform code with GCC. Visual Studio
is very much "Windows Only" and especially if you even think about using
the .NET framework.

However, if you only want to port one way, it is possible to compile
pure ANSI C code with standard libraries from *NIX to Windows and you
can compile such code inside Visual Studio. The main reason it doesn't
usually work, is because someone has used *NIX system calls in the C
code which Windows does not understand.

If you want a detailed answer, the best thing to do, is create a small
*NIX program in GCC, then add the source files to a new VS project, then
compile, then make a note of the errors, then post the source code here.
You'll get a quick answer as to why it didn't work.
Post by Rayne
Hi all,
I'm using Visual Studio .NET 2003, and I'm trying to port code I've
written and compiled/run successfully in Linux GCC to Windows.
I'm a newbie when using VS. I've created a new project, and added all
the .c and .h files I have into the project by Project -> Add Existing
Items, then chose all the .c and .h files.
I'm not familiar with how exactly compilers and linkers etc work, but
is there a difference between how VS and gcc compile/link #include
files? My habit of programming in Linux has been to have one main.c
file, and #include all other .h or .c files that I need. Then I would
only compile the main.c file. But in VS, it seems as if the #include
files are not "seen" by the program, because I'm getting errors that
tell me certain structures or variables were not declared, even though
they are in my user-defined header files.
I'm also getting errors like DIR is an undeclared identifier. I've
included , so why can't it recognize DIR?
Thank you.
Regards,
Rayne
--
Gerry Hickman (London UK)
Loading...