0

Possible Duplicate:
Howto compile a static library in linux

I'm trying to compile a library that will be used further.

For each cpp file, of this library, is generating a .o file. How can I make the same compilation with only one .o file?

Community
  • 1
  • 1
Victor
  • 8,309
  • 14
  • 80
  • 129

1 Answers1

2

You can not build a single .o file from multiple C++ source files. Compilers just can't handle that.

If the library comes with a proper build infrastructure (like Makefiles), that should make a libXXX.a or libXXX.so file that you can reference from your own project.

If the library does not create a lib-file by itself, you can create one with

ar -r libXXX.a <list of .o files>
Robᵩ
  • 163,533
  • 20
  • 239
  • 308
Bart van Ingen Schenau
  • 15,488
  • 4
  • 32
  • 41
  • 1
    "*You can not build a single .o file from multiple C++ source files.*" -- Actually, he **can**, he just doesn't want to. As you correctly observe, he wants to build a `.a` library. – Robᵩ Jan 07 '13 at 19:03