Author Topic: Can't build, run, or compile.  (Read 8260 times)

pyro_854

  • Guest
Can't build, run, or compile.
« on: August 23, 2006, 09:51:48 pm »
I'm using Code Blocks to learn C++. I wrote the "Hello world!" app. (I used "Poo!") Now when I click run it says "It seems that this project has not been built yet. Do you wish to build it now?"... If I click "yes" the mesage box closes and nothing happens... if I click "No" it opens a command prompt window that says "Press any key to continue." if I press a key it closes... there is also a cancel button.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Can't build, run, or compile.
« Reply #1 on: August 23, 2006, 10:14:14 pm »
I wrote the "Hello world!" app. (I used "Poo!")
If it's such an easy (small) project could you add it as an attachment (ZIPped) to another post? We don't know anything about your configuration (OS, Compiler/version, C::B/version and others). The basic information you give is "My project doesn't work." with no further reference. I doubt there is a way to give a good answer to this. ;-)
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

pyro_854

  • Guest
Re: Can't build, run, or compile.
« Reply #2 on: August 23, 2006, 10:30:07 pm »
Windows XP Pro, C::B August 22, 2006 build, MinGW.

I'm new to programing, I'm not sure if I have evrything I need.

EDIT: I also have Open Watcom
« Last Edit: August 23, 2006, 11:00:30 pm by pyro_854 »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Can't build, run, or compile.
« Reply #3 on: August 24, 2006, 08:47:33 am »
Windows XP Pro, C::B August 22, 2006 build, MinGW.
What does mingw mean? Mingw itself comes without any compiler. I guess you want to compile against gcc. What happens if you type "gcc --version" in a console? Did you actually install any gcc/g++ packages? Did you setup the compiler(s) corectly in C::B? What about the ZIPed project attached to the next post? This would really make things a lot easier.
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

pyro_854

  • Guest
Re: Can't build, run, or compile.
« Reply #4 on: August 24, 2006, 09:42:32 am »
I found the messages window... this is what it says:
----
poo.c:3: iostream: No such file or directory
poo.c:4: error: syntax error before "namespace"
poo.c:4: warning: type defaults to `int' in declaration of `std'
poo.c:4: warning: data definition has no type or storage class
poo.c:8: error: `cout' undeclared (first use in this function)
poo.c:8: error: (Each undeclared identifier is reported only once
poo.c:8: error: for each function it appears in.)
:: === Build finished: 5 errors, 2 warnings ===
----

I used the mingw.exe file to install gcc. I also have a gcc tar.gz file but it doesn't have an installer... do I need it? If so where should I extract to. How do I setup the compiler in C::B?

[attachment deleted by admin]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Can't build, run, or compile.
« Reply #5 on: August 24, 2006, 09:55:21 am »
gcc tar.gz file but it doesn't have an installer... do I need it?
How do I setup the compiler in C::B?
Please have a lok here:
http://wiki.codeblocks.org/index.php?title=MinGW_installation
And here (in general):
http://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks
Yes, you need a compiler to compile (gcc. g++) programs and yes, this needs to be setup. To setup the gcc compiler all you have to do is to provide C::B with the path to the compiler's applications:
- Goto settings -> compiler and debugger
- select the gnu gcc compiler
- switch to the "Programs" tab
- enter the path to GCC (this us the compiler, *not* MinGW), e.g. C:\GCC
This should basically it.
With regards, Morten.

Ps.: Please: before you ask you could also do a search through the forum and the C::B webpage. This would have revealed the WiKi which is full of information, also for beginners.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Can't build, run, or compile.
« Reply #6 on: August 24, 2006, 10:50:11 am »
I found the messages window... this is what it says:
----
poo.c:3: iostream: No such file or directory
poo.c:4: error: syntax error before "namespace"
poo.c:4: warning: type defaults to `int' in declaration of `std'
poo.c:4: warning: data definition has no type or storage class
poo.c:8: error: `cout' undeclared (first use in this function)
poo.c:8: error: (Each undeclared identifier is reported only once
poo.c:8: error: for each function it appears in.)
:: === Build finished: 5 errors, 2 warnings ===
----

I used the mingw.exe file to install gcc. I also have a gcc tar.gz file but it doesn't have an installer... do I need it? If so where should I extract to. How do I setup the compiler in C::B?

you tried to compile a c++ program with the c compiler, this won't work

please search some tutorials on the net and work through them
e.g. http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html

try the attached project

[attachment deleted by admin]

pyro_854

  • Guest
Re: Can't build, run, or compile.
« Reply #7 on: August 24, 2006, 01:28:12 pm »

you tried to compile a c++ program with the c compiler, this won't work

please search some tutorials on the net and work through them
e.g. http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html

try the attached project


So I was using the wrong extention? I knew it had to be something simple.

I was working through a tutorial, but when I had this problem I mistook it for a C::B problem.

I fixed the original file and it works... Thanks for the help.

musiKk

  • Guest
Re: Can't build, run, or compile.
« Reply #8 on: September 07, 2006, 09:51:48 pm »
hi there,
i have the same problem and so i didn't want to start a new topic. but the solution is not that simple here since i'm using the right extension. ;)

let's say, i have the following little program:
Code
#include <iostream>
int main() {
    std::cout << "Hello World!\n";
}

very basic, very simple, saved under hello_world.cpp.
so when i have the file opened all build, run etc buttons are grayed out as well as the build-menu except for one item: compile current file (which works). well of course this would be all i needed but the run command from other ides was great too because then i didn't have to run the binary file by hand. and of course i can not debug (everything grayed out in debug menu) which is more important. when i look in the compiler settings, everything is correct. for example the entry for debugger is "gdb.exe" and this file can be found at the above given directory (but if this was wrong, the simple compiling wouldn't work).

using xp pro and c::b build: oct24 2006 - wx2.6.1 with gcc which was provided in the c::p setup i installed.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Can't build, run, or compile.
« Reply #9 on: September 07, 2006, 10:12:34 pm »
You need to setup a project to have the full functionality...
Be patient!
This bug will be fixed soon...

musiKk

  • Guest
Re: Can't build, run, or compile.
« Reply #10 on: September 08, 2006, 08:15:26 am »
okay, that's a pity because i really like the editor of c::b. and dev-c++ has better compiling options but lacks a good editor. anyway, thanks for the fast answer and i'll recommend c::b if someone asks me for a good ide.