Object and Library Files and LD

Programming, for all ages and all languages.
Post Reply
PlayOS

Object and Library Files and LD

Post by PlayOS »

Hi,

I am having problems with linking .o and .lib files using LD. If I have a bunch of .o files and I want to put them all in a .lib file it compiles the .lib file properly, but when I try and link it with some code it says that some of the functions are undefined, I know for a fact that they are in the library because I open it in a text editor and check, I have the functions prototyped and it just will not work. If however the .o file is linked directly, everything works properly. It even works if I make the .lib file out of the single .o file, but as soon as I add more than 1 .o file it will not work.

Is there something that I am doing wrong?

thanks.
PlayOS

Re:Object and Library Files and LD

Post by PlayOS »

OK, I have narrowed it down to this, if I create all of my .o files with gcc (ie: c sources) everything goes well, however when I create some with nasm (ie: asm sources) it fails.

So I guess there is a compatability problem between gcc and nasm, has anyone heard of this before, or does any one know where I can find a fix.

Thanks.
Tom

Re:Object and Library Files and LD

Post by Tom »

there was something I read about loading staticly and dynamicly compiled .lib files need to be supported in your kernel :S :-X
grey wolf

Re:Object and Library Files and LD

Post by grey wolf »

LD prefers getting its input object files in the same formats, i think. if you used binutils to convert all of them to COFF or ELF, i doubt LD would complain at all.
PlayOS

Re:Object and Library Files and LD

Post by PlayOS »

Hi,

What are the binutils, I have heard of them but I am not sure if I have them, I have Mingw32 so do you know if that comes with it, I dont have a directory called binutils or anything like that so I am not sure.

What particular program actually does this conversion?
grey wolf

Re:Object and Library Files and LD

Post by grey wolf »

the command "objcopy", among other things, is included in binutils and comes with MinGW and most other GCC distributions.

i was referring to using the objcopy command to convert a file:
objcopy -I <in type> -O <out type> <in file> <out file>

type simply "objcopy" to get a full list of available command switches.
Post Reply