Welcome, Guest. Please login or register.

Author Topic: G++ problems  (Read 3965 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline alxTopic starter

G++ problems
« on: November 26, 2003, 10:51:24 AM »
I'm just starting to learn C++, and I've downloaded GCC from Aminet.  I've installed everything as it says and if I do a standard "Hello World" program in C and go:

Work:>GCC -o helloc hello.c

Work:>helloc

It runs nicely.  Now if i write a C++ program:

Quote

#include

int main ()
{
  std::cout << "Hello C++!\n";
  return 0;
}


And go:

Work:>G++ -o hellocpp hello.cpp

Work:>hellocpp

It cannot find "hellocpp" - the compiler hasn't actually written an executable.  If I change the sourcecode a bit:

Quote

#include

int main ()
{
  std::cout << "Hello C++!\n";
  return 0;
}


The compiler compains that it cannot find the header, so I guess it's doing something.  If i do something like this though:

Quote

#include

inain ()

  stdanythjng::cut << "Hello C++!\n" let's not use semicolons
   gerbil
}}}}}


It doesn't actually give any errors, so I suspect the C++ compiler (not the preprocessor) is at fault.  Any ideas?  I'm a C/C++ newbie, and it's running under WinUAE (AIAB)

Offline alxTopic starter

Re: G++ problems
« Reply #1 on: November 26, 2003, 12:05:07 PM »
Quote
Try your first C++ program but...

#include // without .h !

Does it work ?


No - it complains it cannot find the header files (they all end in .h - even for C++)

---edit---

I'm not in front of my computer now BTW so I cannot check for certain, but that's what I remember...

Offline alxTopic starter

Re: G++ problems
« Reply #2 on: November 26, 2003, 05:32:00 PM »
@Ratto/bloodline

Thanks, but it still doesn't work :-(   When I run "hello", it cannot find it (Hello: Unknown Command).  I get the distinct impression it isn't actually compiling the code - surely:

Quote
#include
supercalifragilisticecpialidosios


Should give an error?  Could I have made a mistake installing the C++ parts?

@bytecode

In the C++ tutorial book I'm using, it mentions that about the .h, and it compiles fine under G++ in windoze.  But the Amiga version I have doesn't seem to have those versions, unless I'm looking at this the completely wrong way (it complains it cannot find them without the .h extension)

BTW Welcome to A.org :-D

Offline alxTopic starter

Re: G++ problems
« Reply #3 on: November 26, 2003, 06:30:36 PM »
Quote
#include is definately erronious


Whoops :-D

What I meant is that, as long as I get the #include bits right, i can write anything into the code and it won't complain - wierd... :-?

---edit---

BTW I remember hearing a while ago that geek gadgets was easier to setup than the individual files from Aminet, but the links on GG seem to be broken, I'd had problems with it before, and I can make GCC compile C progs ATM - just not C++ :-(

Offline alxTopic starter

Re: G++ problems
« Reply #4 on: November 26, 2003, 06:40:24 PM »
@Karlos

That sounds worth it, if it comes with an IDE.  Will the trial let me compile without restrictions, or does it time out or something?