Question

I have a C++ project that can be compiled with -D UNICODE.

When I compile it without that Define, it creates a bunch of object files which I then add to a .a archive file using the command: ar.exe rcs Cpplib.a *.o

Then I compile it with that define and archive the objects using: ar.exe rcs CpplibU.a *.o

where the U states that the archive is a Unicode one.

Is there a way I can combine both .a files into ONE archive so that I can link to that instead of having to link to:

Cpplib_x32.a Cpplib_x64.a Cpplib_x32U.a Cpplib_x64U.a

Now I don't mind linking to x32 and x64 separately but having to link to 2 x64's and 2 x32's is kinda annoying.

I want to know if there is a way I can either combine the x32 and x64 archives OR combine the Non-Unicode and Unicode archives. I don't need both. Either, Or.

Any ideas or am I stuck having to link to all 4?

Was it helpful?

Solution

If the symbol names and object filenames are different, then you can have at least all the 32-bit code and all the 64-bit code in a library of it's own. And of course, a makefile can easily create an object file called xxA.o and xxU.o or something like that for the ASCII vs. UNICODE variant.

If the symbol names are the same (which they will be for functions that, for example, don't take a parameter and have the same return type, or extern "C" functions, as they are not name-mangled based on parameters), then you can't use this method [or have multiple libraries that supply that function, so supplying a whole long list of libraries also won't work].

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top