Search code examples
c++visual-studio-2010static-librariesstatic-linking

How to compile a static library? ("-static-lib..." equivalent?)


I am using VS2010 and I have a C++ project that is referencing and using an external C library (dll) by having various entries in the VC++ Directories and Linker sections of the project properties.

Right now my project is building but when it starts, a message box appears :

The program can't start because ExternalCLibrary.dll is missing from your computer. [...]


I would like to know how to do in Visual Studio 2010 the the equivalent of

adding "-static-libgcc -static-libstdc++" to your compiler flags.

It seems to be the solution according to: The program can't start because libgcc_s_dw2-1.dll is missing


Solution

    1. Load your project in Visual Studio.
    2. Right click your project and choose Properties.
    3. Locate the "Linker" portion of the tree on the left.
    4. Choose All Configurations and All Platforms from the drop down menus at the top of the dialog.
    5. Put your additional static library dependencies in the Input -> Additional Dependencies field, semicolon delimited.
    6. If the libs are not on your lib search path, make appropriate entries in the General -> Additional Library Directories field, semicolon delimited.
    7. Apply, save, compile, run.