Adding additional library and include paths when compiling from command line

前端 未结 2 577
耶瑟儿~
耶瑟儿~ 2020-12-15 08:25

I\'m trying to add additional paths to be used by my project group during compilation. Since C++ Builder 2010 uses msbuild I have tried looking at the docu

相关标签:
2条回答
  • 2020-12-15 08:42

    In C++Builder 10 Seattle (current version as of 2016), I was able to solve this problem (i.e. add custom library paths in automated build) by putting additional library paths into environment variable ILink_LibraryPath before running msbuild. This has to be done by set ILink_LibraryPath=..., not by passing property as /p:... to msbuild.

    This achieves additional paths in automated build environment, without replacing existing paths already set in .cbproj files, and doesn't require any hacks in Embarcadero-supplied files.

    The only problem with this approach is that the sequence in which individual paths are checked is not guaranteed - i.e. custom paths supplied via environment variable are appended to .cbproj paths or possibly put in the middle, depending on project setup, and are not necessarily put in front, so you need to be careful to not have conflicting libraries in other directories mentioned in project files.

    0 讨论(0)
  • 2020-12-15 08:43

    For VS2013, just define environment variables before running msbuild:

    set "INCLUDE=%additional_include_path%;%INCLUDE%"
    set "LIB=%additional_lib_path%;%LIB%"
    REM use environment variables for INCLUDE and LIB values
    set UseEnv=true
    

    Reference: MSBuild/Microsoft.Cpp/v4.0/V120/Microsoft.Cpp.targets

    <Target Name="SetBuildDefaultEnvironmentVariables"
            Condition="'$(UseEnv)' != 'true'">
    ...
        <SetEnv Name   ="INCLUDE"
            Value  ="$(IncludePath)"
            Prefix ="false" >
           <Output TaskParameter="OutputEnvironmentVariable"             PropertyName="INCLUDE"/>
        </SetEnv>
    

    But looks like the INCLUDE and LIB appended behind additional include/lib directories specified in project properties.

    0 讨论(0)
提交回复
热议问题