   Need help with ar...
  I asked a question here a few days ago and was pointed to the GNU ar binutil but am having some problems using it (my own stupidity no doubt).I can create my archive and put all my .a static libraries into a single file, but I can't seem to link it.I keep getting the following error:could not read symbols Archive has no index; run ranlib to add one  So I checked the ranlib docs to see how to use it and did that.But it still gave the same error. So I checked the ar docs again to see if I did something else wrong but couldn't find anything. I re-made my archive a couple of times with different options but nothing I tried worked.Does anyone know how I can fix this?Any and all help is greatly appreciated.[edited by - issch on July 31, 2003 5:46:54 PM]
  OK, you can''t add multiple .a files into another .a file, but you can use a simple script to extract all the files from each .a file, then add them all together into the .a file you want:(in unix notation, if you need DOS .bat I can help there too) AR=arLIBS=library.a library2.aTEMP_FILE=oTemp.tmpOUT=FinalLibrary   $(AR) -t $(LIBS) > $(TEMP_FILE)$(AR) -x $(LIBS) < $(TEMP_FILE)$(AR) rc lib$(OUT).a *.orm -f *.o $(TEMP_FILE)Hope that gives you an idea. ;  I created a new archive and added the .a's into the new one, but as I said, it didn't work.So, I change library.a and library2.a into the .a's I want to combine? and finallibrary to the one I want to create?And if you wouldn't mind a DOS version, also if you dont mind, could you explain what exactly the script does (what do all the symbols mean?) as its probably better to learn than to just use other peoples scripts without knowing what they actually do or mean. That would be great.Thanks heaps.   [edited by - issch on July 31, 2003 6:42:41 PM];  What you would do if you were to do it manually is to extract all the object files from each of the libraries you want to combine, then you would combine all the .o files into one .a file.  You cannot combine multiple .a files into one .a file.Here's the script as a DOS batch file, but I won't use environment variables, except the libraries you want to use and the input: @echo offREM ** call this file like this: CombineLib [output library] [libraries to combine]REM ** %1 is the 1st paramaterREM ** %2 is the second parameterREM ** shift makes the 2nd parameter become the 1st parameter and 3rd become the 2nd etc.REM ** check the batch file was called with the correct syntaxif "%2"=="" goto UsageREM ** the 1st parameter is the output librarySET OUTOUT_LIBRARY=%1shiftREM ** now loop through the input libraries and extract all the object files:Loopar -t %1 > temp.tmpREM ** now extract all the object files from the librariesar -x %1 < temp.tmpREM ** shift and check if there's more librariesshiftif not "%1"=="" goto LoopREM We've extracted all the .o object files, now add them to the output libraryar rc %OUTPUT_LIBRARY% *.oREM ** delete all the .o files and temp file and we're done del /q *.odel /q temp.tmpgoto Done:Usageecho Syntax: CombineLib [output library] [input libraries]:Done@echo onThis batch file will do what you want.  If you have 2 libraries named Graphics.a and Audio.a and you want to combine them into 1 library, you'd use the above bactch file and type:combinelib AudioAndGraphics.a Graphics.a Audio.aand it'd do it![/source]   [edited by - beernutts on July 31, 2003 11:19:36 PM];  Thank you man, I owe you one! 