Hi,
i wish to understand what code habit i should take in order to develop indipendent application (i want to be able to just give the exe,without any other dependencies).
For example,I think that i have to use Static Library,and not rely on windows api,right? What other things should i consider?
I'm not sure what your question is. If you want a program that works on all platforms all you have to do is use standard c++ code. What is the actual problem here?
I think he wants to make an exe which would be working on it's own - in visual studio you have to install packages or give dll files manually to your client, without that you will have "dll missing" message box.
#include <iostream>
int main ()
{
std::cout << "aaaaaa" <<std::endl;
std::cin.get();
return 0;
}
don't run on a fresh windows install because some dll are not found. I need my program to run in a minimal windows enviroment. Something as a just formatted windows.
If you're using visual studio then as TheHardew says, that's probably why. If you compile that with codeblocks, then it can be run on any windows environment.
I compiled it with Code::blocks and the result is the same. If i take the exe and try to run it in a fresh windows installation it won't run because "[...] xxxx missing ".
It should work ok. The Win32 DLL's are part of the Windows installation and are always available. We are just trying to statically link GCC stuff to avoid dependencies.
Yeah! Linking statically in code::blocks worked fine! The only disadvantage is that the size of the exe increase dramatically when there are a lot of dependencies....to avoid this can i use the winapi dll (that are always avaible),loading them dynamically and use the windows api function instead of the standard c++ library ?
I really believe all the MinGW GCC releases link statically. I have specifically tested all my code going back for a lot of years produced even by the earliest MinGW releases, and I have never found an exe that wouldn't run 'standalone' on bare bones systems, i.e., OEM only installs, with no development products installed on the machine. If I'm wrong about this, I wish someone here would point out my error, because this issue is important to me also.
Now with Visual Studio one must be careful to link with the /MT option, or for sure you'll need to include runtimes with the exe.
In terms of program sizes, any inclusion of anything from the C++ Standard Library, particularly iostream or string, is going to cause tremendous code bloat. These are simply large amounts of library code. iostream is much easier to eliminate than string. In my case I never use iostream, and I have my own String Class which saves me quite a bit as compared to the C+ Standard Library's String Class. I realize this is a very idyosyncratic thing to do on my part and is not for most C++ coders.
The Mingw g++ versions from around 2008 or so produced tight code. I'm talking versions around 4.4 or so. The newer 4.7, 4.8, nd 4.9 versions really produce extreme bloat due to inclusion of C11 compatibility and pthreads.