Author Topic: adding object files to static lib project  (Read 3206 times)

Offline dfatcb

  • Multiple posting newcomer
  • *
  • Posts: 56
adding object files to static lib project
« on: September 26, 2011, 08:24:59 pm »
code::blocks doesn't seem to add the .o files I add to a project to the resulting library .a file.  Is there anyway to make it do that?  I'm using Code::Blocks in Linux, all the other IDEs I used in DOS/Windows have always added any .obj files added to the project the the resulting .lib created.

TIA!!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13071
    • Travis build status
Re: adding object files to static lib project
« Reply #1 on: September 26, 2011, 08:40:28 pm »
What is the type of your project?
If this is not a static library then you won't get a lib (.a)!
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline dfatcb

  • Multiple posting newcomer
  • *
  • Posts: 56
Re: adding object files to static lib project
« Reply #2 on: September 26, 2011, 08:59:21 pm »
it's a static lib.  I get the .a file for all the .c and .cpp source, just doesn't seem to know to add the .o files?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13071
    • Travis build status
Re: adding object files to static lib project
« Reply #3 on: September 26, 2011, 09:12:40 pm »
No .c or .cpp file is added to the .a files.
They are first compiled to .o files and the .o files are added to the lib (.a).
Is this step that is broken or do you have external .o files which you want to be added to the lib?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline dfatcb

  • Multiple posting newcomer
  • *
  • Posts: 56
Re: adding object files to static lib project
« Reply #4 on: September 26, 2011, 09:54:06 pm »
Yes, of course, external .o files added to the project that want to be added to the .a lib when built.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13071
    • Travis build status
Re: adding object files to static lib project
« Reply #5 on: September 26, 2011, 10:48:58 pm »
Have you tried to make the files link?

Right click on the file -> Properties -> Build -> Link file.

I don't know if this will help. If it doesn't you'll have to package the .o files yourself in a post build step.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline dfatcb

  • Multiple posting newcomer
  • *
  • Posts: 56
Re: adding object files to static lib project
« Reply #6 on: September 26, 2011, 10:52:46 pm »
yeah, they were set like that by default.  I'll have to do the post build step.  do you happen to know the linux command to add an .o file to a .a file?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13071
    • Travis build status
Re: adding object files to static lib project
« Reply #7 on: September 26, 2011, 10:59:17 pm »
I guess "man ar" should tell you the correct parameters.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]