Thread: VC++ porting issues

  1. #1
    Registered User Chris87's Avatar
    Join Date
    Dec 2007
    Posts
    139

    VC++ porting issues

    Well, the other day I was trying to find a way to make a program in Visual C++ Express 2008 that doesn't require additional files. I know it's possible because I have some third-party installations whose binaries were compiled in VC++.

    Anyway, to test it I typed up one file of source code and in VC++ chose "New Project from Existing Files", selecting that one file. I'm aiming to do cross-platform work and the cross-platform, open-source projects I've used in VC++ didn't have the junk MSVC++ Express puts in the project like stdafx.h, or targetver.h by default.

    So yeah, I made a new project out of that "Hello World" source code file (main() within) and in Properties->Code Generation, I changed "Multi-Threaded DLL" to "Multi-Threaded" to make it independent of the C runtime DLL (slightly larger binary, but no worry). It built successfully under Vista Ultimate SP1, although with the usual warnings about unsafe functions, and a warning about the option Wp64 being deprecated.

    After it built I ran it successfully under VU-SP1, but then figured it might be detecting a runtime that came with MSVC++Exp, so I transferred it to another computer running XP Prof-SP2 and attempted to run it, but it returned an error about "invalid executable format".

    I'd really appreciate some help. Again, I'm trying to make executables that can be run by 2000/XP/Vista without the CRT DLL, not just on my computer.

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Well, the warnings about deprecated features are an hint you are not using the proper compiler settings. Create an empty C++ console Project and remove the Precompiled Header option from the project wizard.

    Once created the project, create a source file to have access to the compiler options. Go to Project -> projectname Properties and set the following options:

    Configuration Properties->C/C++->General: Warning Level 4
    Configuration Properties->C/C++->Language: Disable Language Extensions: Yes(/Za)
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Peculiar. Are you sure the project wasn't Managed?

    Create a Win32 Project and check the Empty Project checkbox. Then import your source there. That's the best way to get a project as clean as possible.

    Vista embeds manifests in executables, but the result should be backward compatible. If not, check the linker options if there is anything suspicious there.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User Chris87's Avatar
    Join Date
    Dec 2007
    Posts
    139
    Ah ok, and for regular applications, the same as well?

  5. #5
    Registered User Chris87's Avatar
    Join Date
    Dec 2007
    Posts
    139
    Quote Originally Posted by CornedBee View Post
    Peculiar. Are you sure the project wasn't Managed?

    Create a Win32 Project and check the Empty Project checkbox. Then import your source there. That's the best way to get a project as clean as possible.

    Vista embeds manifests in executables, but the result should be backward compatible. If not, check the linker options if there is anything suspicious there.
    Possibly. I made sure CLR stuff was off (AFAIK)

  6. #6
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    cross-platform work and the cross-platform, open-source projects
    I suggest GCC for the project. It's nice being able to work with the same compiler on all platforms.

    For any larger sized project, maintaining compatibility with more than one compiler is quite some extra work.

    We all know that in an ideal world standard compliant programs should all work on all standard compliant compilers... but this is not a practical expectation.

  7. #7
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Hmm... You have no problems compiling VC++ projects in MinGW or GCC as long as you don't write compiler specific code. If you do, you aren't even guaranteed gcc and MinGW are compatible. In fact, the term "cross-platform" should extend to the best of your abilities to compilers, in that you should manage to support as many compilers as possible.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. makefile exported by vc 6.0 doesn't work
    By wow in forum Windows Programming
    Replies: 7
    Last Post: 03-24-2006, 04:20 PM
  2. Porting code from VC++6 to VC .NET??
    By dug in forum C++ Programming
    Replies: 10
    Last Post: 01-31-2005, 11:42 AM
  3. Porting to FreeBSD
    By Beastie in forum Linux Programming
    Replies: 1
    Last Post: 06-15-2003, 07:37 PM
  4. Can't compile this with VC 6.0
    By uriel2013 in forum C++ Programming
    Replies: 4
    Last Post: 05-31-2003, 07:43 PM
  5. Why VC?
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 04-15-2002, 05:24 AM