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
How to Redirect Cin and Cout to Files
How to Use Boost in Visual Studio 2010
Enum to String in Modern C++11/C++14/C++17 and Future C++20
Why Are Elementwise Additions Much Faster in Separate Loops Than in a Combined Loop
When Should I Make Explicit Use of the 'This' Pointer
Can Modern X86 Hardware Not Store a Single Byte to Memory
Unicode Encoding For String Literals in C++11
How to Implement the Factory Method Pattern in C++ Correctly
How to Track Down a "Double Free or Corruption" Error
Why Are Standard Iterator Ranges [Begin, End) Instead of [Begin, End]
How to Create a Generic Object Model For Use in Qml
When Do I Use a Dot, Arrow, or Double Colon to Refer to Members of a Class in C++
Why Does This C++ Snippet Compile (Non-Void Function Does Not Return a Value)
Forward Declaring an Enum in C++
Std::Unique_Ptr With an Incomplete Type Won't Compile
Returning a Reference to a Local or Temporary Variable
How to Pass a Unique_Ptr Argument to a Constructor or a Function