We help IT Professionals succeed at work.

Compiling C c99 on Windows 7 x64

jeffiepoo used Ask the Experts™
Hey everyone, I have a C assignment, and it is for optimizing matrix multiplication algorithms.

I have Ubuntu 10 running on VMware, and it runs fine, but I want to see how fast it runs without the extra level of abstraction that the virtual machine adds. Is there anything good that anyone knows about that compiles C with the "gcc std=c99" standard on a Windows 7 x64 operating system I can use?

Any help would be great!

Thanks Experts!

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi jeffiepoo,

I was going to suggest Cygwin (which you can download on Windows 7 -
                 http://cygwin.com/faq/faq-nochunks.html#faq.what.supported )
but two things:
1) You should check to see whether the Cygwin C99 support is sufficient for your needs. Here is a google search results:

2) I wanted to verify that Cygwin was comparable in performance with Visual Studio 2008 Express. So, I took a profile C program and ran it on my system using both compilers to get timings (resolution to 1 second).

The results were very good. So, I can recommend Cygwin when compared with VS 2008 Express.

I ran a cygwin command on my system:
$ gcc -std=c99 -O2 c_profile.c
$ ./a
**** Begin TEST 1 with 2 Loops ***
 deltaTime = 7.000000
sum = 1279147008

**** BEGIN TEST 2 with 1 Loop and Sentinel ****
 deltaTime = 7.000000
sum = 1279147008

VISUAL STUDIO 2008 EXPRESS RESULTS (compiled in Release mode)
**** Begin TEST 1 with 2 Loops ***
 deltaTime = 7.000000
sum = 1279147008

**** BEGIN TEST 2 with 1 Loop and Sentinel ****
 deltaTime = 9.000000
sum = 1279147008

I ran it a 2nd time, and both times deltaTime was 8 seconds for both TEST 1 and TEST 2.

So, I can safely say that using the -std=c99 -O2 gcc options resulted in favorable performance comparisons.
Hmm, I skimmed over the fine print in that FAQ:
   "As far as we know no one is working on a native 64 bit version of Cygwin."
 -- you could be the first :(

So, never mind. Sorry.
But the 32 bit version should still work on a Windows 7 64-bit architecture, I believe.
But from the official cygwin information and download site:

"The Cygwin DLL currently works with all recent, commercially released x86 32 bit and 64 bit versions of Windows, with the exception of Windows CE."

So, never mind the previous "never mind".
Top Expert 2009

I've used Cygwin and MinGW succesfully on a Windows 7 x64 box. No issues. Both are nice ways of having a gcc compiler on a Windows system.

Cygwin works on 64 bit windows as a 32 bit program.  It is the same with Visual Studio, VMWare and anything installed on the Program Files (x86) directory.  There are lots of programs that many people think are 64 bit.  It is where it gets installed that tells you what it actually is.


Ok, I'll work on getting Cygwin -- it looks as if you can just run a command line like you do in UNIX.

At the moment, I did get a free copy of Microsoft Visual Studio 2008 from the CS department at school, but I can't figure out how to run it on there. It seems to me you have to make it a project, and when I say new project, it only gives me 3 options:  Visual C++, Visual Basic, Visual C#. The only one that kinda made sense was the Visual C++, but it didn't even come close to compiling correctly.

Any ideas how to use a gcc std=99 compiler on Visual Studio until I can get my hands on a copy of CYGWIN for free?

Top Expert 2009

Cygwin IS free. Just download it here :


and install it ;)


So I click on the Arizona mirror: http://cygwin.lilengine.com/

And it shows me a directory of all of the files I need (I assume). How do I download them all at once?
Top Expert 2009

It's easier to use the setup executable :


It will download everything that's needed for you.

If you wish to use visual studio, get express from http://www.microsoft.com/express/Downloads/#2010-Visual-CPP.  Note that it is still C89: not C99.


Infinity08, phoffric, I got the cygwin installed. Thanks for the help. However, I've never used it. Instead of searching the internet I'll just post here cause I'm lazy and I want to close this post soon.

I copied my c program into C:/cygwin/bin  and typed gcc -std=c99 Matrices.c into the cygwin terminal and I got a error message: "bash: gcc: command not found" --?? I also got the same error when I didn't use the c99 flag.

Thanks for any help guys.


Type echo $PATH
Is gcc in one of those directories specified?  If it isn't, add it to one of the directories on the path.
When I do echo $PATH, I see:


$ which gcc

$ which cc

$ which g++

$ whereis gcc
gcc: /bin/gcc.exe /usr/bin/gcc.exe /lib/gcc /usr/lib/gcc /usr/share/man/man1/gcc.1.gz

$ whereis cc
cc: /bin/cc.exe /usr/bin/cc.exe /usr/share/man/man1/cc.1.gz

$ whereis g++
g++: /bin/g++.exe /usr/bin/g++.exe /usr/share/man/man1/g++.1.gz


Run setup.exe again and get to the "Cygwin Setup" window. In my expansion of "Devel" I see "Keep" for:

gdb (debugger)
ddd (Gui debugger - uses gdb)


xyz@MATH /usr/bin
$ ls -al gc* cc g++
lrwxrwxrwx 1 Admin None      20 2009-12-25 19:42 cc -> /etc/alternatives/cc
lrwxrwxrwx 1 Admin None      21 2009-12-25 19:42 g++ -> /etc/alternatives/g++
-rwxr-xr-x 2 Admin root   94741 2009-02-25 05:14 gcc-3.exe
-rwxr-xr-x 3 Admin root 1223182 2009-12-11 03:24 gcc-4.exe
lrwxrwxrwx 1 Admin None      21 2009-12-25 19:42 gcc.exe -> /etc/alternatives/gcc
-rwxr-xr-x 1 Admin root   16261 2009-02-25 05:08 gccbug-3
-rwxr-xr-x 1 Admin root   16984 2009-12-11 03:07 gccbug-4
-rwxr-xr-x 1 Admin root    2018 2006-06-11 19:31 gccmakedep
-rwxr-xr-x 1 Admin root   42510 2009-10-27 22:41 gconf-merge-tree.exe
-rwxr-xr-x 1 Admin root   55310 2009-10-27 22:41 gconftool-2.exe
-rwxr-xr-x 1 Admin root   30568 2009-02-25 05:14 gcov-3.exe
-rwxr-xr-x 1 Admin root 1045518 2009-12-11 03:24 gcov-4.exe
lrwxrwxrwx 1 Admin None      22 2009-12-25 19:42 gcov.exe -> /etc/alternatives/gcov


Give me a little more time with this.
>> I copied my c program into C:/cygwin/bin  
Well, just as a matter of principle, you should be working in your /home/user_account_name folder.

My .bash_profile file (located in /home/user_account_name) has in it this line:
     cd ./prj
so that when I click on the Cygwin desktop icon, then:

$ pwd

The user_account_name takes on the name of the limited XP account that I'm working in.

In case you do not have a .bash_profile file in your $HOME folder, then here is one version that you can use:

$ cat .bash_profile
# base-files version 3.9-3

# To pick up the latest recommended .bash_profile content,
# look in /etc/defaults/etc/skel/.bash_profile

# Modifying /etc/skel/.bash_profile directly will prevent
# setup from updating it.

# The copy in your home directory (~/.bash_profile) is yours, please
# feel free to customise it to create a shell
# environment to your liking.  If you feel a change
# would be benifitial to all, please feel free to send
# a patch to the cygwin mailing list.

# ~/.bash_profile: executed by bash for login shells.

# source the system wide bashrc if it exists
if [ -e /etc/bash.bashrc ] ; then
  source /etc/bash.bashrc

# source the users bashrc if it exists
if [ -e "${HOME}/.bashrc" ] ; then
  source "${HOME}/.bashrc"

# Set PATH so it includes user's private bin if it exists
# if [ -d "${HOME}/bin" ] ; then
#   PATH=${HOME}/bin:${PATH}
# fi

# Set MANPATH so it includes users' private man if it exists
# if [ -d "${HOME}/man" ]; then
# fi

# Set INFOPATH so it includes users' private info if it exists
# if [ -d "${HOME}/info" ]; then
# fi

alias dir='ls -lrt'
alias dirt='ls -lrt | tail'
alias ll='ls -l'
alias dirs='ls -l | grep drw'
alias dirc='ls -lav --color=auto'

alias la='ls -al'
alias rmj='rm *.tmp *.bak'
alias rmc='rm a.*stack*'
alias rmo='rm *.o'

alias up='cd ..'
alias xt='xterm -sb -sl 2000 -fg yellow -bg brown&'

export DISPLAY=localhost:0.0
alias sym='alias | grep -i'
alias shl='env | grep -i'

alias h='history'
alias hg='history|grep '

alias proc='ps|grep'
cd ./prj

Open in new window


Ok, I do have a bash profile. phoriffic, I don't understand the prj thing. I am in my home directory -- ex:


also when I type

which gcc
I get:
which: no gcc in ( "5 lines of different paths" )

It also doesn't recognize the command "whereis"

cup said to just add it to one of those directories in the path. I don't know how to do that.
What do you get when you type:
    echo $PATH
What do you get when you type:
cd /usr/bin
ls -al gc* cc* g++*
In http:#33127702 there are instruction for running setup.exe again. Do that and report what status you have for the listed components in the expansion of "Devel". Your status should match what is shown in that post.

>> I don't understand the prj thing
I just created a folder that I called prj to put various Cygwin projects that I am working on. In that folder are sub-folders for different kinds of projects.

To do something similar, go to your home directory, /home/Jeff, and create a project directory with the command:
    mkdir projects (or any directory name)


echo $PATH

/usr/local/bin:/usr/bin:/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/ATI Technologies/ATI.ACE/Core-Static:/cygdrive/c/Program Files (x86)/QuickTime/QTSSystem/:/cygdrive/c/Program Files (x86)/Microsoft SQL Server/90/Tools/binn

change directory to usr/bin and type ls -al ect....

ls: cannot access gc*: No such file or directory
ls: cannot access cc*: No such file or directory
ls: cannot access g++*: No such file or directory


Ok so basically nothing was installed from "Devel" when I went back and ran the setup. It's installing right now. I'll let you know how it goes.
Top Expert 2009

The very first post (http:#33111635 by phoffric) answered the question quite nicely. The rest was just follow-up discussion to help the author get it to work.

So, I recommend a PAQ for that post.


Thanks, sorry it took me so long to close this. Phoffric thank you for your patience