问题
I am upgrading my preexisting CAD/CAM project (quite big one > 10MByte of code) and have to add some special measuring equipment. The problem is I have more than one supplier of the measuring system (although is already decided which one to use) and I want to configure them (using #define
in case vendor is changed in future) with code to use only selected device type. So I have something like:
#define use_vendor1
//#define use_vendor2
//#define use_vendor3
and some of the vendors APIs require their own DLLs so I need for example:
Project/Add to project/vendor1.lib
Project/Remove from project/unused_vendor.lib
if use_vendor1
is used ... That will be uncomfortable to add/remove each type reconfiguration of exe is required. I was wondering if there exist a way similar to this:
#ifdef use_vendor1
#pragme link "vendor1.lib"
#endif
That one does not work of coarse because DLL *.lib
is not compiled code as *.obj
...
Having all the libs in the project is an option but that would require shipping exe with all the DLL's which I would rather avoid.
Another option would be dynamic DLL link but I rather avoid it as that is more coding for me in it...
I am bound to old BDS2006 Turbo C++ Explorer IDE and compiler.
Also is it possible to statically link DLL in relative path to EXE ?
回答1:
You are looking for #pragma comment:
#ifdef use_vendor1
#pragma comment(lib, "vendor1.lib")
#endif
来源:https://stackoverflow.com/questions/57586957/is-static-link-of-dll-using-lib-possible-from-code-only-without-add-to-proj