Click to See Complete Forum and Search --> : How do I use ar?


MrNewbie
02-19-2001, 09:54 AM
For Borland's Turbo C to create libraries I just needed to do this:

tlib LIBNAME +objfile

To remove files from the Library I did this:

tlib LIBNAME -objfile

An thats all I have needed to do with tlib so far, but I want to do it using gcc and ar and the help for ar is not very good and I can't properly understand it. What is the command to create a new lib and add an object file to it, and the command to remove an object from the library?
Thanks
MrNewbie

Stuka
02-19-2001, 10:54 AM
ar rcs libxxx.a libxxx.o
Where r = insert (or update) files in archive
c = create archive if it doesn't exist
s = create/update link map.
(q is also available - it appends w/o checking for replacement). Hope this helps!
(BTW this is from Linux Programming Unleashed)

MrNewbie
02-19-2001, 11:19 AM
I tried it and get this error:

c:/djgpp/bin/ar.exe: libfuncs.a: rename: Not enough memory (ENOMEM)

(I'm using DJGPP the Win32 port of gcc.)
Do you know what could be wrong? I used this command to get that error:

ar rcs libfuncs.a cdate.o

Mikenell
02-19-2001, 01:42 PM
I want to know this too. I also use DJGPP in Windows and what Stuka said doesnt work for me either, although strangely it will create the lib, just not when I tell it to create it with a .o file.

Stuka
02-19-2001, 03:03 PM
Well gentlemen, I don't know what to say. Unfortunately I've not used this myself, I just ripped it from the book. I just checked the man pages, but they are a bit obtuse. If I find some good info, I'll make sure to pass it on. Sorry 'bout that! :(

Mikenell
02-19-2001, 03:25 PM
I asked someone else, that command is right, it also says at the DJGPP site the right command and that gives me the same error as you :(