How to link an object file (* .o) and a static library file (* .a)

I have 2 object files ( *.o ) and one static library ( *.a ) using g ++ How do I link these files and become 1 object file ( *.o )?

I ask for advice ... thanks.

+4
source share
1 answer

This is one (rare) case when you should not use g++ . Use ld directly:

 ld -r -o combined.o foo.o bar.o libxyz.a 
+5
source

All Articles