c++makefileg++

Create a single .o file


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?


Solution

  • 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>