Depending on the build type (debug, release) of my main executable, I want to link against the matching builds of my DLLs. What is the correct way to accomplish this using the C++Builder IDE?
Details: I am using Embarcadero C++Builder XE8 (trial, BCC64). My software consists of one executable and multiple libraries (.dll, Dynamic-link Library) loaded during program startup (not at runtime). Each library and executable has its own project and all projects are within the same project group.
To use the compiled libraries in the consuming projects, I have added the import files of the compiled DLLs (.a for BCC64) to the consuming project.
Excerpt from SerialPort.cbproj:
<LibFiles Include="..\..\Win64\Debug\Logger.a" Condition="'$(Platform)'=='Win64'">
<BuildOrder>3</BuildOrder>
<IgnorePath>true</IgnorePath>
</LibFiles>
Unfortunately, the output path for .dll/.a files depends on the variables $(Platform) and $(Config) and therefore the path to those files differs between debug and release builds. The IDE does not(!?) allow me to specify different DLL files to be used for debug and release builds.
I'd rather not resort to ugly hacks like putting the generated binaries for debug and release mode in the same folder just to have a single path to the import files for both builds. The following workaround seems to work, but gets overwritten by C++Builder when saving the project:
<LibFiles Include="..\..\Win64\Debug\Logger.a" Condition="('$(Platform)'=='Win64') And ('$(Config)'=='Debug')">
<BuildOrder>3</BuildOrder>
<IgnorePath>true</IgnorePath>
</LibFiles>
<LibFiles Include="..\..\Win64\Release\Logger.a" Condition="('$(Platform)'=='Win64') And ('$(Config)'=='Release')">
<BuildOrder>3</BuildOrder>
<IgnorePath>true</IgnorePath>
</LibFiles>
Is there a sane way to solve this problem?
$(Platform)and$(Config)variables as well. So if the DLLs, their import LIBs, and the EXE are all compiled into the same folder based on build configs, then everything should be working fine provided the DLLs/LIBs are using the same filename for each config. - Remy Lebeau#pragma linkmacros instead of adding the libraries to the project directly. That way you can control this with a simple#definewhich you could specify on the project configuration. - Rodrigo Gómez