Click to See Complete Forum and Search --> : gcc command line compiling help


aewarnick
February 28th, 2006, 04:59 PM
I'm trying to make a batch file to build libbz2.a. Here is what I have so far, but I must be doing something wrong because when I try to link to libbz2.a I get a fatal error from the linker and it is killed.

"..\0_CodeBlocks\bin\gcc" -w -O1 -O2 -O3 -Os -c blocksort.c
"..\0_CodeBlocks\bin\gcc" -w -O1 -O2 -O3 -Os -c huffman.c
"..\0_CodeBlocks\bin\gcc" -w -O1 -O2 -O3 -Os -c crctable.c
"..\0_CodeBlocks\bin\gcc" -w -O1 -O2 -O3 -Os -c randtable.c
"..\0_CodeBlocks\bin\gcc" -w -O1 -O2 -O3 -Os -c compress.c
"..\0_CodeBlocks\bin\gcc" -w -O1 -O2 -O3 -Os -c decompress.c
"..\0_CodeBlocks\bin\gcc" -w -O1 -O2 -O3 -Os -c bzlib.c
"..\0_CodeBlocks\bin\gcc" -w -O1 -O2 -O3 -Os -c bzip2.c
"..\0_CodeBlocks\bin\gcc" -w -O1 -O2 -O3 -Os -c bzip2recover.c
"..\0_CodeBlocks\bin\gcc" -w -O1 -O2 -O3 -Os blocksort.o huffman.o crctable.o randtable.o compress.o decompress.o bzlib.o bzip2.o -o "Release\libbz2.a"
pause

MrViggy
February 28th, 2006, 05:13 PM
What is the error?

aewarnick
February 28th, 2006, 05:30 PM
It's not a compiler error, it's an unhandled exeption. It occurs when gcc tries to use ld.exe to access the file. Let me make this clear, the exception occurs AFTER the script above is done and I try to use the newly compiled lib file using CodeBlocks and gcc.

MrViggy
February 28th, 2006, 05:34 PM
Ahh, the linker itself is crashing. Got me. Have you tried re-installing it? Upgrading?

Viggy

aewarnick
February 28th, 2006, 06:20 PM
Nope, that's not the problem. Everything else builds and runs fine when I exclude that library (and the accompanying code to make it compile without the library).

kenrus
February 28th, 2006, 07:11 PM
I have never used gcc to build a static library. ar is the tool that we use.

After all the .o's are built, put them all in a .a file with ar.


-Kendall

Paul McKenzie
February 28th, 2006, 07:29 PM
Nope, that's not the problem. Everything else builds and runs fine when I exclude that library (and the accompanying code to make it compile without the library).You could try the Dev-C++ package which uses gcc and linker to compile and build libraries. If you create a project with the files, and it builds correctly, you can examine how Dev-C++ accomplished it by looking at the command line it invoked.

Regards,

Paul McKenzie