Search code examples
eclipsegccobject-files

Copying or keeping a .o file in Debug/Release Output with Eclipse and GCC


I have a library project which includes a object (.o) file. I have the following post build command to make sure the file is included in the build:

ar -r libProject.a AdHocObject.o

However, that means I have to manually copy my AdHocObject.o file in Debug and Release, and I can never clean the project, or I need to start over and copy AdHocObject.o in Debug and Release.

This becomes even more a hassle when I have a second project which uses the library (as an Include) and rebuilds it, making sure AdHocObject.o is erased first.

I'm a bit lost here. I'm thinking there could be various ways, but I can't find them. I could:

  • Make the second project not rebuild the library, but I don't know how;
  • Make the library keep AdHocObject.o in Debug and Release, but I don't know how;
  • Add a pre-build command to copy AdHocObject.o to the output folder (Debug or Release), but... you guessed it.

Are any of these actions possible, and if more than one, what is the recommended approach?


Solution

  • I got it, I just needed to point to the right place, put the o file with the sources and adjust the post build command thus:

    ar -r libProject.a ..\AdHocObject.o