Hello! I've seen a thousand dicsussion about how to make an .exe file from your .cpp source code, but none of it seems to help me: since I have the .exe file, I just can't run it on any other computer. Can anybody help me out, what libraries should I copy with it, what can I change about it?

I assume you mean MS-Windows operating system. It all depends on the program, compiler and libraries you used. When you try to run the program on another computer does the os give you some errors, such as missing DLLs? Some compilers let you statically link all libraries so that it doesn't require any DLLs other than standard win32 api functions. We have to know a lot more about your program and compiler.

Microsoft Windows, yes. Btw I think I should mention that it is a very basic program performing some calculations, only one program, no header files or anything that complicated. The only error message I get on xp is that the program cannot be executed; on Vista it mentioned something like side-by-side configuration is incorrect. I work in Microsoft Visual Studio 2008. Libraries I used, i think you mean the #include <> thing, I only used iostream. If there's anything more I should tell, let me know (maybe the way I can find out the answer as well... ) Thanks for the eager response :)

What kind of project are you using? Is it a standard win32 console app or are you using something differently?

Does your code contain any pointers? It may be possible that if you don't initialise them, they'll just point at a random value, which may happen to be system protected, however I doubt that. Could you post your code? It would be much better that way.

Something you should try is using the "Run as administrator" and "Compatibility Mode" features. Also try to move only the cpp and recompile it there, if it works, then it's probably the compiler.

You want to make sure that you are NOT trying to execute the DEBUG version of your executable on machines not having Visual Studio (2008) installed, i.e. build and use the RELEASE version on such machines.

commented: good suggestion :) +14
Member Avatar for misi

I work in Microsoft Visual Studio 2008

Here is a link For MS VS 2010 how to make an exe file which works on other computers as well:

http://www.youtube.com/watch?v=AvrjQtFBJvk

MS VS 2008 should be similar.

It's working :) Thanks for the help. The problem was (as the video explained as well) that the program was depending on the .dll files, so I just had to change something in the properties. Though I still have a problem with it, with the useful part of the program. It is supposed to choose a value from a list of values, the closest bigger value to its value. Can you please check the code, maybe you notice where is the mistake. Sometimes it works and chooses the value, other times it just won't. I think There may be something wrong with the declarations, but I'm not sure.
`for(i=1;i<=n;i++)

        if(I[i]<=km[0][0])
            ksz[i]=KSz[0];
        else
        {
            for(j=0;j<=18;j++)
                if (I[i]>km[0][j] && I[i]<=km[0][j+1])   
                ksz[i]=KSz[j+1];
        }

`
This is what I am trying to use, km[][] is declared as set of values from km[0][0] to km[0][16], and km[3][16]. km[][] is declared as double, having values with 1 decimal precision.

Is the data in ascending sorted order? If not then the program can't work.

why does the loop counter i start at 1 instead of 0?

ksz[i]=KSz[0];

Don't name your arrays like that because you will do nothing more than confuse yourself (and others) when read later. name kSz something else and make the name meaningful for what data it represents.

for(j=0;j<=18;j++)

That is reaching beyond the bounds of the array. The array only has 16 elsmenets, not 19. The loop counter should be: for(j=0;j<14;j++) (14 because of the j+1 in the next statement)

How to make EXE file of my program which can run on others computer as well

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.