How to Make a Fully Statically Linked .Exe With Visual Studio Express 2005

How do I make a fully statically linked .exe with Visual Studio Express 2005?

For the C-runtime go to the project settings, choose C/C++ then 'Code Generation'. Change the 'runtime library' setting to 'multithreaded' instead of 'multithreaded dll'.

If you are using any other libraries you may need to tell the linker to ignore the dynamically linked CRT explicitly.

Static Runtime Library Linking for Visual C++ Express 2008

Sorry, I do not have VC++ Express to test, but in Standard edition I use Project Properties -> Configuration Properties -> C/C++ -> Code Generation -> Runtime Library. Dll and Dll Debug are for dynamic linking.

How to statically link using link.exe

You have to define POCO_STATIC on the command line and link with both PocoFoundationmt and PocoNetmt.lib:

C:\test>cl /MD /WX /nologo /EHsc /DPOCO_STATIC /DUNICODE /D_UNICODE /I..\poco\Foundation\include /I ..\poco\Net\include /c exp.cpp

exp.cpp

C:\test>link /libpath:..\poco\lib /WX /nologo exp.obj PocoNetmt.lib PocoFoundationmt.lib

[UPDATE]
If you compile with /DPOCO_STATIC, then it isn't necessary to specify the POCO libraries on the linker command line. The header files contain #pragma comment(lib, "PocoXXXmt.lib") statements that should ensure that all the necessary libraries will be linked in.

If you don't compile with /DPOCO_STATIC, then the DLL import libraries will be automatically linked instead.
[/UPDATE]

Visual Studio C++ 2010. Run exe without redristibutable

You cannot run a program without parts of the runtime library which is inside the redistributable. However, you can statically link the redist into the exe. See here: C++ executable - MSVCR100.dll not found error

Visual Studio opencv project build

As far as I'm concerned you have two options:

1, It is possible using static linking, but usually OpenCV doesn't distribute the compiled static libraries. You will have to compile your own .lib and link against those to create a standalone executable.

2, You could use Dependency Walker tool to find dlls your program depends on. Then find the dlls on your system, and copy them to your program distribution (to folder that contains executable file).



Related Topics



Leave a reply



Submit