This is my first question here even though I've been a member for some
time and am an avid CodeBlocks user.
I'm trying to learn how to do command line compiling with my Windows
CodeBlocks Installation of the GNU Compiler Collection; specifically
gcc and g++.
I have two installations of the GNU compilers on my computers; the one
installed when I installed Dev-C++ Version 4.9.9.2 which is a pretty old
version of the compilers, and the one installed when I installed
CodeBlocks within the last year.
Here are the locations of the installations:
Dev-C++ C:\Dev-Cpp
CodeBlocks C:\Program Files\CodeBlocks
I have been successful at command line compiling with the older Dev-C++
installed GNU compilers, but using the same techniques a successful
compile with the newer CodeBlocks compilers has eluded me. Now, to be
absolutely clear - I'm not talking about using the CodeBlocks IDE to
compile; that works wonderfully; I'm speaking of compiling at the
Windows Command Prompt.
When I do this sort of work I create a batch file containing a change
directory command to change the directory to wherever I have my source
code, followed by an invocation of cmd.exe. For example, here is my
batch file to start working with the older Dev-Cpp installed GNU
compilers for a Windows GUI template program of mine where the source is
in C:\Code\Dev-Cpp\Projects\Forms\Form1...
CD\
cd C:\Code\Dev-Cpp\Projects\Forms\Form1
C:\Windows\system32\cmd.exe
And if the source file is Main.cpp, here is my command line invocation
of g++ that successfully creates a Form1.exe file optimized for small
size...
C:\Dev-Cpp\bin\g++.exe Main.cpp -o"Form1.exe" -L"C:/Dev-Cpp/lib" -mwindows -s
However, using these same techniques using the CodeBlocks GNU binaries
totally fails. I have attempted executing various PATH statements before
the command line to help things along but I never get any further than an
error message to the effect that the compiler can't find ld - even when
I've executed a PATH statement before invoking the compiler which contained
the exact PATH to ld which is...
C:\Program Files\CodeBlocks\MinGW\bin\ld.exe
I'm a bit experienced with command line compiling with Linux and I have
the book "An Introduction To GCC For The GNU Compilers gcc And g++" by
Brian Gough, but because the book seems entirely Linux/Unix based I'm
having a hard time understanding how to interpret it with Windows.
The conclusion I've come to though is that there has been some internal
changes to the compilers from the Dev-Cpp version to the newer CodeBlocks
installed version, (that's a no-brainer) that is not allowing the build
sequence to complete without access to some external OS dependent
information perhaps contained in environment variables. Could someone help
me with this or provide information where I might learn how to set up my
environment in Windows 2000/XP to allow me to command line compile with
the CodeBlocks installed GNU compilers?
If I had to make a guess I suspect I have to add environment variables,
but I'm not entirely sure what they are or how to go about it.