Good day.
I work with the libbotan library ( https://github.com/randombit/botan ). This library is not quite windows friends. To use it at the moment for my application, I have to store 2 sets of collected libs for linking (x86 and x64), besides, for the debug version, they come with the 'd' postfix. It turns out a set of 4 versions of liba.
At the moment, the connection is implemented through the .h file of the following type

// link_botan.h #ifdef WIN32 #ifdef _DEBUG #pragma comment (lib, "botand32d.lib") #else #pragma comment (lib, "botand32.lib") #endif #else #ifdef _DEBUG #pragma comment (lib, "botand64d.lib") #else #pragma comment (lib, "botand64.lib") #endif #endif 

What is the most correct way to implement linking with similar libs for easier use? (In addition to this method, you can still fence conditions in .vcxproj or use folders instead of postfixes)

  • Usually, in such cases, just in the project settings are added for each option and no one complains. - KoVadim

1 answer 1

There is an alternative way

 #ifdef _DEBUG #define DPREF "d" #else #define DPREF "" #endif #ifdef WIN32 #define PLAT "32" #else #define PLAT "64" #endif // link_botan.h #pragma comment (lib, "botand" PLAT DPREF ".lib") 

yes, for 64 bit it is better to check for _WIN64

Is this method easier - I do not know. But if you need to connect several libraries, then the definition of DPREF / PLAT can be placed in a separate file (and of course rename).