• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

GCC + Windows = ???

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

JigPu

Inactive Pokémon Moderator
Joined
Jun 20, 2001
Location
Vancouver, WA
I need help setting up GCC in Windows. I'm trying to play around with SIMD, and the only free compiler I can seem to find that supports MMX/3DNow/SSE Intrinsics is GCC. However, I can't seem to get it working with Windows.

What's Happened So Far
1) Went to MinGW's website and downloaded the GCC Core (3.3.1)
2) Downloaded G++ (3.3.1)
3) Extracted both to C:\GCC
4) Added "C:\GCC\bin" to my PATH variable (so I can compile from anywhere)
5) Attempted to compile a simple program ("gcc sample.cpp").
6) GCC complained with the following error:
"gcc: installation problem, cannot exec `cc1plus': No such file or directory"
7) Added "C:\GCC\lib\gcc-lib\mingw32\3.3.1" to my PATH variable (so GCC can find cc1plus.exe)
8) Attempted to compile again
9) GCC reads through the code, can't find any libraries
10) Search online, find that I need a "CPLUS_INCLUDE_PATH" variable containing the path my my include files.
11) Create said variable, set path to "/gcc/include/c++/3.3.1"
12) Attempted to compile again
13) Generates zillions of errors, I believe complaining about bad code in the LIBRARIES THEMSELVES :confused: Example error:
"/gcc/include/c++/3.3.1/bits/char_traits.h:68: error: syntax error before `;' token


...And I'm completely stuck now. What did I do wrong, or not do? Any good step by step instructions on how to get this dang compiler to work under windows??? The lack of documentation scares me :rolleyes:

JigPu

What I did:
 
You may want to try a slightly easier method: install Dev-C++, a free IDE that uses gcc. I've done this several times and it has almost always worked without any strange problems. You can get Dev-C++ here:
http://sourceforge.net/projects/dev-cpp/

gcc will be installed with Dev-C++, and though I believe you can use it from the command line as well as within the IDE, I haven't tried that before.

BTW, I did have a look at the mingw documentation and it is rather, shall I say, not present. You might want to consult the documentation for gcc itself, here:
http://gcc.gnu.org/install/

The GNU project usually has very thorough, if a bit technical, documentation, though it may be geared for a Unix / Linux environment :-/

There is also Cygwin, a Unix-ish environemnt that runs under windows. I know that gcc works within it. ( www.cygwin.com )

Good luck :)
 
Awesome, thanks :) Dev-C++ installed fine and is working great.

However, my code seems to be running a LOT slower with GCC than Borland. Any optimization flags I should know about?

JigPu
 
If you're using the Dev-C++ Development Environment with MinGW (Windows GCC port, Dev-C++ ships with this by default) then there should be some optomization options under Tools > Compiler Options > Settings > Optomization. If you're using it from the command-line you should use -O3 for the best optomization (without understanding every GCC command line option). Also, if you are just using MinGW by itself, you need to set the path environmental variable to include the GCC bin directory (so GCC/G++ can find all the other programs it needs to compile stuff).
 
Grr, I told it to do all the optimizations and no decrease in time. I then digged around for a while finding a few command line arguments to pass to it, and they didn't help at all either.

To try to shed some light on stuff, I ran my program through AMD's CodeAnalyst (it runs executables and finds where they're spending their time). Apparently the GCC compiled version spends it's time (88% CPU) running a "msvcrt.dll". The Borland version by contrast spends a mere 0.02%!! I don't know even why this DLL is running, but I'm almost positive it's the source of my problem.


Any advice from those in the know?? :confused:
JigPu
 
Ermm... isn't msvrct.dll one of Microsoft's C libraries or something along those lines? Gcc probably generates code that relies on functions in it, while Borland prefers to implement the functionality themselves.
 
I dunno, I'm the GCC n00b :D It does appear to be from VC++ from google. But my main questions are the following:

1) Why is msvcrt.dll so dang slow??
2) Why is it (a display library) called by math.h??
3) Is there any way to tell GCC to NOT use it?? (forcing it to use some other library, or something?)


I'm sure I'll like GCC a lot better once I find out why it's doing this, and what I can do to fix it... :)
JigPu
 
It might be better to use a profile to find which function is taking up all that time. Once you figure out which function(s) are resulting in the use of that library, you may be able to use other library functions, or if necessary, implement the offending function yourself.
 
Back