Question

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?

Was it helpful?

Solution 2

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

OTHER TIPS

enter image description hereWell, I really want to ask why but here's how to copy the file. Right-click the project and select Properties. Go the C/C++ Build section and under there select Settings. Then on the right panel click on the Build Steps tab. In the pre-build Command: box you'll want to issue a copy command something like the following (or you can also use relative paths and environment vars to specify the from and to.)

cp "C:\SourceDir\AdHocObject.o" "C:\DestDir\AdHocObject.o"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top