我正在尝试添加更多的路径,以供我的项目组在编译期间使用。由于C++ Builder2010使用msbuild,所以我尝试查看相关文档,根据我可以找到的内容,AdditionalLibPaths应该可以作为一个属性通过。i.e
msbuild /p:AdditionalLibPaths=C:\FooBar\Libs /t:build foo.groupproj但它似乎没有使用我添加的路径。我以前已经注意到,VC++和C++ Builder在传递给msbuild时,有一些属性名不同,并且不知道C++ Builder是否可以使用其他属性名来添加附加的lib和包含文件夹?
我不想替换项目中定义的现有路径,而是附加其他路径。这样做的理由是,当项目构建在我们的构建服务器上时,一些库驻留在一个标准化的地方,这可能与它安装在开发机器上的位置不同。
msbuild调用msbuild文件,该脚本文件反过来调用其他脚本,包括使用标记的.groupproj脚本。我知道在使用标记时会创建msbuild的一个新实例,所以我知道在脚本中运行该任务时必须添加该属性。
<MSBuild Targets="Build" Projects="..\Foo.groupproj" Properties="Config=Debug (property to add additional paths here!)" />更新:
C++生成器似乎在使用IncludePath和ILINK_LibraryPath,但是设置这些设置会覆盖项目文件中已经定义的路径。因为这个文件是由IDE创建和维护的,所以任何使其附加而不是覆盖的更改都会被IDE覆盖。这有点奇怪,因为它看起来确实应该附加这些值。
<IncludePath>..\FooBar\;$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;Common Components;..\Config\Config32;$(IncludePath)</IncludePath>更新2:
在CodeGear.Cpp.Targets中,我将自己的属性AdditionalIncludePaths添加到处理包含路径的PropertyGroup中。
环绕251线
<PropertyGroup>
<BCC_NoLink>true</BCC_NoLink>
<ILINK_OSVersion Condition="'$(ILINK_OSVersion)'=='' And '$(NoVCL)'!='true'">5.0</ILINK_OSVersion>
<DCC_GenerateCppFiles>true</DCC_GenerateCppFiles>
<ShowStdOut Condition="'$(ShowStdOut)'==''">$(ShowGeneralMessages)</ShowStdOut>
<!-- _TCHAR mapping for Uni^H^H^H character selection -->
<StartupObj Condition="'$(_TCHARMapping)'=='wchar_t'">$(StartupObj)w</StartupObj>
<ILINK_StartupObjs Condition="'$(ILINK_StartupObjs)'==''">$(StartupObj)</ILINK_StartupObjs>
<BCC_GenerateUnicode Condition="'$(_TCHARMapping)'=='wchar_t'">true</BCC_GenerateUnicode>
<!-- Include Paths -->
<Win32LibraryPath Condition="'$(Win32LibraryPath)'==''">$(BDS)\lib</Win32LibraryPath>
<IncludePath Condition="'$(CBuilderIncludePath)'!=''">$(IncludePath);$(CBuilderIncludePath)</IncludePath>
<IncludePath Condition="'$(AdditionalIncludePath)'!=''">$(IncludePath);$(AdditionalIncludePath)</IncludePath>
<BCC_IncludePath Condition="'$(BCC_IncludePath)'!=''">$(BCC_IncludePath);$(IncludePath)</BCC_IncludePath>
<BCC_IncludePath Condition="'$(BCC_IncludePath)'==''">$(IncludePath)</BCC_IncludePath>
<BRCC_IncludePath Condition="'$(BRCC_IncludePath)'!=''">$(BRCC_IncludePath);$(IncludePath)</BRCC_IncludePath>
<BRCC_IncludePath Condition="'$(BRCC_IncludePath)'==''">$(IncludePath)</BRCC_IncludePath>
<DCC_IncludePath Condition="'$(DCC_IncludePath)'!=''">$(DCC_IncludePath);$(IncludePath)</DCC_IncludePath>
<DCC_IncludePath Condition="'$(DCC_IncludePath)'==''">$(IncludePath)</DCC_IncludePath>
<DCC_UnitSearchPath>$(DCC_IncludePath);$(Win32LibraryPath)</DCC_UnitSearchPath>
<DCC_ResourcePath>$(DCC_IncludePath)</DCC_ResourcePath>
<DCC_ObjPath>$(DCC_IncludePath)</DCC_ObjPath>
<TASM_IncludePath Condition="'$(TASM_IncludePath)'!=''">$(TASM_IncludePath);$(IncludePath)</TASM_IncludePath>
<TASM_IncludePath Condition="'$(TASM_IncludePath)'==''">$(IncludePath)</TASM_IncludePath>然后我可以打电话
msbuild /t:build /p:AdditionalIncludePaths=C:\Foo\Include foo.groupproj这很好,我想做什么就做什么。我只需要对库路径做同样的处理。但我不想黑其中一个Embarcaderos提供的文件像这样。太荒谬了:P.没有为添加包含路径和库路径设置任何正式属性吗?
发布于 2015-01-23 05:37:09
对于VS2013,只需在运行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参考资料: 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>但是看起来像在项目属性中指定的额外的include/lib目录后面附加的INCLUDE和LIB。
发布于 2021-05-05 06:13:26
对于附加词include on VS2019,请使用开关/p:IncludePath=C:\Foo
若要包含多个路径,请在开关上使用双引号和分号:
/p:IncludePath="C:\Foo;C:\Bar;C:\Another;$(IncludePath)"发布于 2016-02-03 20:41:50
在C++Builder 10西雅图(2016年的最新版本)中,我能够解决这个问题(即在自动构建中添加自定义库路径),方法是在运行msbuild之前在环境变量ILink_LibraryPath中添加额外的库路径。这必须由set ILink_LibraryPath=...来完成,而不是将属性作为/p:...传递给msbuild。
这在自动构建环境中实现了额外的路径,而无需替换.cbproj文件中已经设置的现有路径,并且不需要在Embarcadero提供的文件中进行任何黑客攻击。
这种方法的唯一问题是无法保证检查单个路径的顺序--即通过环境变量提供的自定义路径被附加到.cbproj路径,或者可能被放在中间,这取决于项目设置,并且不一定放在前面,因此您需要小心地避免在项目文件中提到的其他目录中有冲突的库。
https://stackoverflow.com/questions/15654002
复制相似问题