I have two precompiled library: X.a
and Y.a
and a test.cpp (without main function) source code use these two libraries.
I compiled the C++ using:
g++ -c test.cpp
and I got 'test.o'.
Now how can I link these three together to generate a .a
file because test.cpp use some function in X.a and Y.a and other GCC libraries?
BTW, I am doing these under Windows using MinGW. Can I rename this .a file to .lib and use this .lib in VC?
Thanks!
Now how can I link these three together to generate a .a file because test.cpp use some function in X.a and Y.a and other GCC libraries?
.a
is nothing more then ar
archive containg all object files (.o
files)
Can I rename this .a file to .lib and use this .lib in VC?
Yes, but it requires little trick to work. See: http://opensees.berkeley.edu/community/viewtopic.php?t=2267
In order to add your object file to the static library you have to use the following command:
ar rcs X.a test.o
But if you are provided with X.a and Y.a I suppose you are not the author of X and Y, therefore I'm not sure you really want to join them!
You may decide to link every object file into a single executable instead, but you need the main
function for it!
EDIT: Also I suggest you to read this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With