Hi, Draj!
If you can, I'd suggest the use of namespaces, and relative paths.
namespace prod1
{
#include "../prod1/file.h"
}
namespace prod2
{
#include "../prod2/file.h"
}
int main(int argc, char **argv)
{
prod1::function1(1, 2, 3);
prod2::function1(4, 5);
}
If the .LIB files conflict, this solution may not help you: that depends on your code.
You can wrap the .lib files in your own source:
int Function1V1(int a, int b, int c);
#include "../v1/file.h"
#pragma comment( lib, "../v1/file.lib" )
int Function1V1(int a, int b, int c)
{
return funtion1(a, b, c);
}
int Function1V2(int a, int b);
#include "../v2/file.h"
#pragma comment( lib, "../v2/file.lib" )
int Function1V2(int a, int b)
{
return funtion1(a, b);
}
Otherwise, assuming each of these products provides a DLL and not only a LIB, you'll have to use late binding (
LoadLibrary()
and
GetProcAddress()
).
If you only have static libraries, you can wrap each of them in a DLL of your own,
renaming the encapsulated functions, and refer to your own DLLs in your program.
See also
How to build an image (DLL/EXE) when two of its included libraries have the same symbol (say function/variable) using VC++[
^]
Hope this helps,
Pablo.