Jump to content

Very simple question

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
kern

kern

    Newbie

  • Members
  • Pip
  • 2 posts
Hi,

I'm a total newbie at programming. I just started learning C/C++, I have no problem understanding the language, but when it comes to compiling I'm completely lost (my book has nothing about this). For example, let's say I have a very simple program called test.c

I installed Cygwin (as I really need the GSL library), I put my file in the C:\cygwin\home\user folder. I open Cygwin.exe, enter the command;

gcc -o test test.c

And I get a .exe file. It seems to work fine. Now I try with the file, but with NetBeans. I install everything, it seems to work fine, but th

mkdir -p build/Debug/Cygwin-Windows

gcc.exe    -c -g -o build/Debug/Cygwin-Windows/test.o test.c


Build successful. Exit value 0.

But I don't get any .exe file, and I don't have a "run" option for the file, I can only compile it. The only thing I get is my initial .c file and a .o file.

Thank you.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Depending on the environment/compiler, it doesn't always link in the same step as compiling. Your second command has created an object file, which needs to be linked into any standard libraries to create a .exe.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
kern

kern

    Newbie

  • Members
  • Pip
  • 2 posts
And how can I do that ?

Like I said, I know nothing about compiling.

#4
Irfanerol

Irfanerol

    Newbie

  • Members
  • PipPip
  • 16 posts
I've searched it from google, and i've find a little information maybe you've checked this but i'll write down here.

Quote

Firstly, log on to the Cygwin Shell, i think this is the command operator which you have written the codes looks like 'gcc -o gcc.c gcc.o'
Then you need to go to the directory of your .c files and use this command 'gcc filename.c -o filename' then your compiling is over.


#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
It will look something like:
g++ -o build/Debug/Cygwin-Windows/test.exe build/Debug/Cygwin-Windows/test.o
There could be additional options needed, such as specifying -LC:\wx\lib\gcc_lib to specify the library of your compiler
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog