Thread: Compiling Visual C++ code using a different compiler

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    67

    Compiling Visual C++ code using a different compiler

    I have a system of C++ code that was written using Visual C++ 2008 Express Edition. I need to run this code on a high-performance cluster that doesn't allow compilation with Visual C++; instead, the following compilers are available:

    Gnu compilers 4.1
    Intel compilers 11.1.056
    PGI compilers 10.5
    Java-1.6.0 -openjdk
    Python 2.7.1

    I was advised to check my code for any dependencies on the Visual C++ compiler, so that I can instead one of the above compilers. However, I'm not sure what to look for, that would indicate a Visual C++ dependency. Any suggestions?

    Also, from the list above, is there one specific compiler that would be the best choice, if I'm switching from Visual C++ code to a new compiler?

    Thanks! (I can post a more detailed description of my code system, if more specifics are needed.)

  2. #2
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    Posts
    426
    A good start might be to add /Za as a compiler option (or Project Properties -> C/C++ -> Language -> Disable Language Extensions:Yes).
    Consider this post signed

  3. #3
    Registered User
    Join Date
    Jun 2010
    Posts
    67
    Thanks for the suggestion, bernt. I made this change, and recompiled the code; it worked! That's definitely a good sign. I suppose that my next step is to try compiling the code on the cluster, using one of the other compilers.

    Does anyone have input about which of the compilers I listed in my OP would be my best choice, or are they all basically equivalent?

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Is Gnu compilers GCC? If so, then yes. GCC is very good.
    Intel is supposed to be good, too, at least on the optimizing part.
    The rest, I don't know.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    It's probably more important that you pick one, Kate. The choice between the first three really depend on what license terms you need. Whichever ones you choose, you will need to exercise test cases to confirm that the program is still working as intended. Even if code compiles with multiple compilers/systems there are still things (such as binary I/O) that may work with one compiler but not another. So you need to confirm that the program works when recompiled, not just assume it.

    openjdk and Python are not C++ compilers.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  6. #6
    Registered User
    Join Date
    Jun 2010
    Posts
    67
    Thanks for your input, Elysia & grumpy. Yes, the Gnu compilers include GCC. I think I'm going to give the GCC a try, and I'll be sure to confirm that the code remains functional with the new compiler.

  7. #7
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    Note that the Intel compiler, while generating code that sometimes runs a bit faster (than GCC output) on Intel CPUs, arguably intentionally generates much worse code for non-Intel CPUs.

    Agner`s CPU blog - Intel's "cripple AMD" function

  8. #8
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    Quote Originally Posted by cyberfish View Post
    Note that the Intel compiler, while generating code that sometimes runs a bit faster (than GCC output) on Intel CPUs, arguably intentionally generates much worse code for non-Intel CPUs.

    Agner`s CPU blog - Intel's "cripple AMD" function
    much more likely they are able to perform undocumented optimisation routines for Intel CPUs but not for 3rd party CPUs, making the compilation unit perform better on Intel than other platforms.
    I seriously doubt Intel would put their corporate reputation at stake by deliberately generating compilation units so as to perform poorly on non-Intel hardware.

  9. #9
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    much more likely they are able to perform undocumented optimisation routines for Intel CPUs but not for 3rd party CPUs, making the compilation unit perform better on Intel than other platforms.
    I seriously doubt Intel would put their corporate reputation at stake by deliberately generating compilation units so as to perform poorly on non-Intel hardware.
    It has nothing to do with undocumented optimizations. The article linked has a good explanation of what they did.

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by jwenting View Post
    much more likely they are able to perform undocumented optimisation routines for Intel CPUs but not for 3rd party CPUs, making the compilation unit perform better on Intel than other platforms.
    I seriously doubt Intel would put their corporate reputation at stake by deliberately generating compilation units so as to perform poorly on non-Intel hardware.
    You obviously don't know Intel as well as you think you do. I'd recommend you read that article and google a little on anti-trust complaints against Intel. They have tried to use illegal or poor business practices before.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Registered User
    Join Date
    Mar 2009
    Posts
    344
    Note that there are several versions of GCC available for Windows systems. Look up cygwin or mingw for specifics. Installing them would allow you to compile & debug the code on your windows system before you had to move it over to another system. There's never a guarantee, but if it works on GCC w/ Windows there's at least a better chance of it porting over to GCC w/ whatever cleanly.

  12. #12
    Registered User
    Join Date
    Jun 2010
    Posts
    67
    Thanks for the additional input. Given my previous good experiences with GCC, and cyberfish's caution about the Intel compiler, I'm planning to stick with the GCC compiler. I just learned that one of my colleagues has had experience with making the switch from Visual C++ to GCC, and recommended that instead of using numerous individual files, I should simply replace all of the "include" statements in main.cpp, with the actual files' contents -- he's able to compile on GCC using this method (and hasn't discovered any simpler way to do it that works).

  13. #13
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    What? You mean replacing all include statements with the actual files contents?
    That's silly. You don't need to do that with any compiler.
    Just compile all the .cpp files. Any good IDE will be able to do that for you. Code::Blocks, for example, works with GCC.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #14
    Registered User
    Join Date
    Jun 2010
    Posts
    67
    What? You mean replacing all include statements with the actual files contents?
    That's silly. You don't need to do that with any compiler.
    Just compile all the .cpp files. Any good IDE will be able to do that for you. Code::Blocks, for example, works with GCC.
    When you say, "just compile all the .cpp files": if the statement that works to compile the single main.cpp file is:

    gcc main.cpp -o myExecutable

    ...what would your suggested alternative compile statement look like?

  15. #15
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Actually, RTFM.
    Last edited by Elysia; 11-07-2011 at 11:59 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling preprocesed code in Visual Studio 2008
    By SolidSnake745 in forum C Programming
    Replies: 7
    Last Post: 02-23-2011, 10:19 AM
  2. compiling C code at visual C++ 6.0
    By hattusili in forum C Programming
    Replies: 7
    Last Post: 02-10-2008, 01:26 PM
  3. Replies: 2
    Last Post: 02-04-2008, 02:34 AM
  4. compiling c code in c++ compiler..???Noob
    By roalme00 in forum C Programming
    Replies: 2
    Last Post: 06-30-2007, 07:25 AM
  5. Compiling in Unix vs Visual C++
    By stimpyzu in forum C++ Programming
    Replies: 2
    Last Post: 09-30-2002, 06:41 AM

Tags for this Thread