VS2005 to gcc

This is a discussion on VS2005 to gcc within the C++ Programming forums, part of the General Programming Boards category; Hi, I have a simple C++ source file which works perfectly in Visual Studio 2005. Unfortunately I have to get ...

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    6

    VS2005 to gcc

    Hi, I have a simple C++ source file which works perfectly in Visual
    Studio 2005. Unfortunately I have to get it compiled for use on a
    remote linux machine. Using putty I get a zillion cryptic error
    messages that scroll off the putty screen making it impossible to see
    the first error messages. Is there a way to compile Linux executables
    on Windows or somehow get a more forgiving Linux compiler or a page
    with all the nonos in gcc that are acceptable in VS?

    edit when I use g++ instead of gcc all I get is an a.out file
    Last edited by Jarwulf; 06-19-2008 at 09:45 PM.

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    The a.out file is an executable and means that your code compiled correctly. You can specify the output binary file using the '-o' flag, i.e. 'g++ -o myprogram main.cpp'.

    Edit: gcc compiles your code as C by default, whereas g++ is the C++ compiler, which is why it worked under g++ but not gcc.
    Last edited by XSquared; 06-19-2008 at 10:07 PM.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    When you compile on the remote machine, do this
    gcc prog.c 2>errors.txt

    Then you can transfer all the errors back to your machine to see what you did wrong.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    The big question is, as already pointed out, why are you trying to compile your C++ code with a C compiler (gcc)?

    You need to use g++.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,047
    In order to run the a.out file that was generated by g++, or whatever you called your executable, use "./a.out" (or whatever).

    [edit] g++ is the C++ compiler that is still part of the GNU Compiler Collection (GCC). [/edit]
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    [edit] g++ is the C++ compiler that is still part of the GNU Compiler Collection (GCC). [/edit]
    Yes of course. I was referring to the actual command.

  7. #7
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Quote Originally Posted by Jarwulf View Post
    edit when I use g++ instead of gcc all I get is an a.out file
    Comments like these illustrate why you should understand what you're even doing before you run into it wildly.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. Replies: 4
    Last Post: 09-02-2007, 08:47 PM
  3. Compiles on gcc 3.3 but not on gcc 4.0.3
    By cunnus88 in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2007, 12:24 PM
  4. gcc configuration under linux advice needed
    By vart in forum Tech Board
    Replies: 9
    Last Post: 01-10-2007, 01:46 PM
  5. gcc
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 10-22-2003, 03:46 PM

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