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
  • 7,964
  • 14
  • 77
  • 126

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ᵩ
  • 154,489
  • 17
  • 222
  • 296
Bart van Ingen Schenau
  • 15,018
  • 4
  • 30
  • 41
  • "*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