gcc command line compiling help
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
Re: gcc command line compiling help
Re: gcc command line compiling help
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.
Re: gcc command line compiling help
Ahh, the linker itself is crashing. Got me. Have you tried re-installing it? Upgrading?
Viggy
Re: gcc command line compiling help
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).
Re: gcc command line compiling help
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
Re: gcc command line compiling help
Quote:
Originally Posted by aewarnick
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