Compiler & Portability

Why if I compile the same sourcecode on
> Dev-C++ it does not compile
> VC++ it compiles but on some computer the program does not run
> Code::Blocks it compiles and the program run on more computers
?
C++ is middle level programing language and it cannot be run on some platforms.
Some IDE's supports 'code optimization'. Enable it and your code will run on more computers.
Try to find option 'platform...' or etc.(I never used Dev-C++ and VC++) and choose platform.
Hope this helps.
+++
Platforms:
i386 - standart 32 bit PC.
i686 -64 bit PC
Last edited on
Thanks
I don't think that's entirely an accurate response.

You have to first understand what compiler you are actually using. Dec-C++ nor Code::Blocks are compilers. Both on Windows use the MingW compiler by default, although they can support other compilers.

If the code won't compile between compilers then it's either a difference in the implementation of the C++ standard, or you have used compiler specific code (Microsoft compiler is fill of it).

If you can compile, but cannot run the program on another computer then it's 1 of 2 things usually.
1) the other compiler doesn't have the required shared libraries (dlls)
2) You have used Visual Studio .NET and the other computer doesn't have the .NET framework installed.
I've tryed this simple program:
1
2
3
4
5
6
7
#include <iostream>
using namespace std;
int main()
{
     cout << "Hello World";
     return 0;
}

To see if was VC++ fault that a Win32 application did not run on a computer.
When tryed that, I got a message saying that application settings were wrong.
So I tryed compiling my Win32 program on Dev-C++ but it found many errors in my code and didn't compile.
Then I tryed Code::Blocks and it compiled and made the program running on the computer having problems
Last edited on
I can compile that fine in VC++ (Visual Studio 2005 with .NET 2.0 - Select Win32 Console Application).

Can also compile that fine with MingW (Eclipse + CDT).

VC++ Code:
1
2
3
4
5
6
7
8
#include "stdafx.h" // needed by VC++
#include <iostream>
using namespace std;
int main()
{
     cout << "Hello World";
     return 0;
}
Last edited on
I don't have problem in compiling with VC++, I've used it a lot and on "good" computers my programs work.
But on some computers if I use a program compiled with VC++ I get an error message like this:
Error in application settings.
Reinstalling the program could solve this problem

or something similar to that.
Last edited on
It's a problem with the installation of VC++. And I'd say its also a problem with your Dev-C++ installation.

There is no problem in the code you have provided. Nor the compilers. It'll be down to user configuration issues.
#include "stdafx.h" // needed by VC++

Not necessarily. If you use the Win32 console application template, this header file is included, but not really necessary.

I usually just start an empty project.
fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?


So you must have different project settings to me. I'm using Visual Studio Enterprise 2005 with .NET 2.0 project.
If you start from an empty project you won't get that error
(or at least I don't)
Ahhh ok :) CBF testing that. I only use VS for C# :)
Topic archived. No new replies allowed.