Compile my code for Linux?

This is a discussion on Compile my code for Linux? within the Linux Programming forums, part of the Platform Specific Boards category; I've got some code I wrote in MSVC++ 6 and I'd like to run it in Linux. Can I compile ...

  1. #1
    Registered User CompiledMonkey's Avatar
    Join Date
    Feb 2002
    Location
    Richmond, VA
    Posts
    438

    Compile my code for Linux?

    I've got some code I wrote in MSVC++ 6 and I'd like to run it in Linux. Can I compile my code for Linux?

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    Code that complies to standard ANSI C should work. Code that relies on OS specific functionality will not. POSIX compliant code should compile aswell. My guess is that your code will need altleast alittle bit of work before it compiles correctly in *NIX.

  3. #3
    Registered User CompiledMonkey's Avatar
    Join Date
    Feb 2002
    Location
    Richmond, VA
    Posts
    438
    It's just a basic app that is in the console. I'll try the above command and get back.

  4. #4
    Registered User CompiledMonkey's Avatar
    Join Date
    Feb 2002
    Location
    Richmond, VA
    Posts
    438
    This is the output I got during compile.

    Code:
    [Chris@Jupiter Chris]$ g++ Condition.c -o binary
    Condition.c:27:1: warning: no newline at end of file
    /tmp/ccKQfdh4.o: In function `testCondition(void)':
    /tmp/ccKQfdh4.o(.text+0x48): the `gets' function is dangerous and should not be used.
    Everything still worked and the app ran fine in the command line. Should I be worried about the given output?

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    Should you be worried about there not being a new line at the end of the file? Eh... depends. It doesn't really harm your code at all, but the syntax checker likes it there.

    Should you be worried about the gets function? Oh, but definitely. Look up fgets() instead; it basically does the same thing, but is a "safe" version of it. basically, fgets() will only read in a specifically designated number of chars at a time, and so you can prevent it from reading more data than your buffer can hold.

    starX
    www.axisoftime.com

  6. #6
    Registered User unixOZ's Avatar
    Join Date
    Feb 2002
    Posts
    91

    Unhappy

    If its for console you might have to change some things (like conio.h functions), it its Windows API, sorry, but you probably have to code it again

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code won't compile
    By monkles in forum C Programming
    Replies: 3
    Last Post: 05-28-2009, 01:45 PM
  2. Compile Errors in my Code. Can anyone help?
    By DGLaurynP in forum C Programming
    Replies: 1
    Last Post: 10-06-2008, 09:36 AM
  3. This code won't compile in Red Hat Linux 9
    By array in forum Linux Programming
    Replies: 7
    Last Post: 04-27-2004, 06:30 AM
  4. << !! Posting Code? Read this First !! >>
    By kermi3 in forum Linux Programming
    Replies: 0
    Last Post: 10-14-2002, 01:30 PM
  5. How do they compile code for an OS ?
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 49
    Last Post: 03-27-2002, 11:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21