简体   繁体   中英

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 ?

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 (ie Debug, Release, etc.).

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在此处输入图片说明

  2. Additional Dependencies在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM