#### Archived

This topic is now archived and is closed to further replies.

# Problems installing GCC on Windows

This topic is 5713 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

The GNU team makes it very confusing for Windows users to install their stuff. I''ve used MingW until recently (which is the equivalent of GCC 2.95), but I''ve a few reasons to want to use GCC 3.0 or GCC 3.1(mainly better template support in C++). So I followed the instructions, installed cygwin (went over perfectly), and on attempting to install the new GCC tools (from inside the cygwin environment) I''ve just ran into error after dubious error trying to install it. I''ve looked on the web and have found very little help regarding this issue... If any of you wise people have managed to install GCC 3.0 or 3.1 on a windows system, I am in desperate need of your help.

##### Share on other sites
I haven''t setup any version of GCC except 2.95.x in Cygwin, but I''ll try next time I boot Windows (just so you know someone will eventually try to help you ).

##### Share on other sites
There''s a section dedicated to gcc 3.1 here.

##### Share on other sites
I just built GCC 3.0.4 (I chose that version since it was the same 3.x version that I''m used to using in Linux) in a almost default installation of Cygwin. I built every part except the Java part (since that can''t be built in Cygwin, according to the configure script). Maybe if you list the issues you''re having, we could help more, since now you know it is possible to build 3.x in Cygwin from multiple sources.

##### Share on other sites
My problems occur while trying to configure GCC before installation...

Under the cygwin console, I type

cd c:/gcc
c:/gcc_inst/configure

it detects the machine as i686-pc-cygwin(correct)

and it goes through the whole process for a minute or so until I get the message: "configure: error: *** unable to determine endianness"

##### Share on other sites
Okay, I did a tiny bit of research, and I concluded that GCC''s configure script does not use the Autoconf method of determining endianness. Instead, it checks the values in sys/param.h. So, open your sys/param.h file (it''ll be at /usr/include/sys/param.h) and search for the word ''endian''. If you can''t find any references to what looks like this, add it (comments clipped for space):
/* ... */#define BIG_ENDIAN	4321#define LITTLE_ENDIAN	1234/* ... */#define BYTE_ORDER	LITTLE_ENDIAN

Since I can pretty safely assume you''re using a little endian system (i686-pc-cygwin).

##### Share on other sites
Wow thanks a lot. I had to really mess around with my environment variables, and do the exact opposite of what the help file said (it said to run configure in a DIFFERENT directory than where you unpacked the files... i had to run configure from the same directory to get past the "can''t determine endianness" error, and then set some environment variables on where to find last version of gcc, change some other things for include and lib directories... but i got it to work!)... so now I got it installed fine, but it still can''t link properly to the c++ standard library.

I have a program like this:

  #include <iostream>int main() {    std::cout << "Print this properly, why don''t you?";    return 0;}

Which compiles, but does not link. It says that there''s an undefined reference to cout, I''m not quite sure what that means but I''ve tried changing the lib path to numerous possibilities with no success.

##### Share on other sites
Are you compiling with gcc as the name of the program, or g++? g++ is used to compile C++ code, while gcc compiles C code (in actuality, I believe g++ just calls gcc with all arguments neccesary to compile C++, but that can be ignored).

##### Share on other sites
quote:
Original post by SilentStrike
Are you compiling with gcc as the name of the program, or g++? g++ is used to compile C++ code, while gcc compiles C code (in actuality, I believe g++ just calls gcc with all arguments neccesary to compile C++, but that can be ignored).

Actually gcc is just a front-end. It looks at the file you are compiling and then calls the real compiler executable to compile that file, so gcc can be used to compile C, C++, Objective-C, and any other language in the GNU Compiler Collection (assuming of course that you've built GCC with support for the particular language).

g++ is also just a front-end. The actual C++ compiler is called cc1plus (and the actual C compiler is called cc1).

[edited by - Dactylos on June 28, 2002 11:26:12 PM]

##### Share on other sites
If you called gcc, add -lstdc++ to the command line.. and possibly the path to your c++ library if the LD_LIBRARY_PATH environment variable has not been set.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

##### Share on other sites
Ok, it turns out I had conflicting copies of the libstc++.a (and other libs) in my cygwin directory, and I had to specify which one I was using with the -L switch before it would recognize the proper one. I got it to work now, but the LD_LIBRARY_PATH environment variable seems to have no effect.

##### Share on other sites
quote:
Original post by Fruny
If you called gcc, add -lstdc++ to the command line.. and possibly the path to your c++ library if the LD_LIBRARY_PATH environment variable has not been set.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

You the man that fixed my hassles with GCC 3.1 as well (never needed that tag with 2.95 for some reason and never thought to use it)

##### Share on other sites
Ok, the tools are all working perfectly now... but I still have one thing I cannot figure out...

How do I compile my code into a .a file that I can use a lib include? I tried "-o libmylib.a" but it doens''t recognise this file as a library when I try to include it as a lib (using "-lmylib") in another file.

Anyone know how to do this?

##### Share on other sites
You build object files (.o) with the -static switch and then use ar rcs libname.a object files.

##### Share on other sites
Ok, now I have a new problem =/ I''m trynna compile a windows application (using the "-mwindows" option), and whenever I try to link my project, it tells me that it can''t find the Entry Point "_WinMainCRTStartup", the program still runs, but it runs through a console first, and messes up the command line options sent to the resulting program. Why can''t it find the proper entry point, what things have I missed here?

I''m sorry if these questions seem juvenile, but I really don''t know where else to turn here.

##### Share on other sites
You do have a WinMain entry point when using the ''-mwindows'' switch, right?

##### Share on other sites
Yep. Looks like this:

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
...
}

##### Share on other sites
Try explicitly linking with libmingw32.a (-lmingw32). I think that's where the 'real' entry point for WinMain is declared. Edit: I can't spell .

[edited by - Null and Void on June 29, 2002 6:32:00 PM]

##### Share on other sites
And if that doesn''t work, it''s probably a compatibility error between Mingw32 and GCC 3.whatever -- since Mingw and GCC are being developed by two different teams, it stands to reason that they won''t be always 100% compatible. Sorry I don''t have any suggestions if that does turn out to be the case.

Twilight Dragon
Win32 API Expert
www.freewebz.com/j-world