I make most of my applications in Visual Studio 2012. The problem is, when I run one of that apps on another computer, it gives missing .dll's errors (msvcr110.dll and such). Is there a way to compile the program without needing that .dll's when running it? And why actually does the it need that .dll's?
He should install Visual C++ Redistributable Package. He can download it from Microsoft website.
He needs them because VS doesnt link standart libraries into exetuable but rather uses them as dll. This is greatly reduces exetuable file size but you cannot run your programs on a PC without said package.
The .dll is a class library that your current program is using.
Since you are using VS 2012, I am assuming you picked a template that automatically added some libraries. These will add themselves to the top on the Cpp file as well; typically #include <something> . So just remove anything you are not using and remove the Dll from the reference list.
If you are using any of the .Net libraries (C++/CLI basically managed C++), then your application will only work on Windows and they will need to have the framework your project is targeting. You can change the target Framework in the properties of your program, though some libraries will only work with newer Framework. Windows 7 is current to .Net 4 and Windows 8 is current to .Net 4.5, also anything lower then Win 7 cannot use .Net 4.5.
hm, okay. But can I also put the needed .dll's in the same directory as the .exe?
Probably not, because that same Dll will have other dependencies.
So thats only possible for programs written in C? Because when I try it, it get this errors:
1>LIBCMT.lib(crt0init.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1> Generating code
1> Finished generating code
1>msvcrt.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
1>msvcrt.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
1>msvcrt.lib(MSVCR110.dll) : error LNK2005: _exit already defined in LIBCMT.lib(crt0dat.obj)
1>msvcrt.lib(MSVCR110.dll) : error LNK2005: _strrchr already defined in LIBCMT.lib(strrchr.obj)
1>msvcrt.lib(MSVCR110.dll) : error LNK2005: ___iob_func already defined in LIBCMT.lib(_file.obj)
1>msvcrt.lib(MSVCR110.dll) : error LNK2005: _fclose already defined in LIBCMT.lib(fclose.obj)
1>msvcrt.lib(MSVCR110.dll) : error LNK2005: _atoi already defined in LIBCMT.lib(atox.obj)
1>msvcrt.lib(MSVCR110.dll) : error LNK2005: _isspace already defined in LIBCMT.lib(_ctype.obj)
1>C:\Users\eigenaar\Documents\Visual Studio 2012\Projects\SDL\Release\SDL.exe : fatal error LNK1169: one or more multiply defined symbols found
To use the static linking you should remove the dynamic linking with /NODEFAULTLIB:msvcrt on the linker's command line, via the Properties of your Project. But you should either specify your project requires Microsoft's Visual C++ RunTime Package, or check you are distributing the RELEASE build of your project. The DEBUG build of your project requires different DLLs, which are ONLY shipped with Microsoft's Visual Studio, or hand-shipped, which end with a 'd'.