Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

Please advice…thanks.

like image 813
no1mad Avatar asked May 23 '11 03:05

no1mad


1 Answers

This is one (rare) case where you shouldn't be using g++. Use ld directly:

ld -r -o combined.o foo.o bar.o libxyz.a
like image 103
Employed Russian Avatar answered Nov 15 '22 07:11

Employed Russian