Rajeshwar
Rajeshwar

Reputation: 11681

Building a stand alone C++ exe. Linking statically with msbuild

I currently have a C++ project that is built using msbuild. Once the project is built I get an exe along with multiple dll files. Is there a way to tell msbuild to link to those libraries statically ? I cannot open the project in visual studio but I can make changes to the vcxproj. Any suggestions on how I can accomplish that ?

Upvotes: 0

Views: 941

Answers (2)

Dylan
Dylan

Reputation: 582

I tried to add a lib file into a clean project, and the modification of vcxproj file are below, hope it can help you:

  1. Library Paths and Include Directories enter image description here

  2. Additional Dependencies enter image description here

Upvotes: 0

ChrisMM
ChrisMM

Reputation: 10103

In the vcxproj files, change:

<ConfigurationType>DynamicLibrary</ConfigurationType>

To

<ConfigurationType>StaticLibrary</ConfigurationType>

Also, in the PreprocessorDefinitions section(s), remove xxx_EXPORTS (where xxx is the name of the project) and _USRDLL, and replace with _LIB

Note: each of these (including ConfigurationType) will appear once for each Configuration you have (i.e. Debug, Release, etc.).

Upvotes: 1

Related Questions