Re: Porting code from Linux to Windows

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.

Rayne wrote:
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)
.



Relevant Pages

  • Re: BUG: simulink 7.6 (r2010b) and visual c++ 2010 compiler
    ... I have 64-bit Windows 7 and MATLAB R2010b. ... I could compile yprime.c into a mexw64 file and run it. ... I tried to compile simulink code using the VC++ 2008 complier, ...
    (comp.soft-sys.matlab)
  • Re: GNAT on MinGW
    ... Once I have a successfull compile I update the page. ... and b) general unfitness of the Windows port of gcc 4. ...
    (comp.lang.ada)
  • Re: how to force a .net application to use .net 2.0 ?
    ... Once you get through the compile errors and deploy it, ... Hitchhiker's Guide to Visual Studio and SQL Server ... and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook) ... this windows service is about 4 years old and im pretty sure is using ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: problem running executable created using g++ on windows
    ... I am a newbie to gcc. ... I am using ARM Toolchain 4.0.0 on windows xp. ... You must compile your code using the ...
    (comp.programming)
  • Re: undefined reference to `link
    ... gcc f77split.c ... Does it mean I missing something on my Windows XP with MinGW/gcc 4.6.1? ... Is it possible to compile the code on Windows? ...
    (comp.lang.c)