Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
151 user(s) are online (103 user(s) are browsing Forums)

Members: 1
Guests: 150

orgin, more...

Headlines

 
  Register To Post  

help ! problem compiling c++ using the GNU stuff in the OS4.0 SDK
Just popping in
Just popping in


See User information
If I compile this:

Quote:

// Helloworld.cpp
#include <iostream>
using namespace std;

int main (void)
{
cout << "Hello world !\n";

return 0;
}


using this makefile (which has worked elsewhere - although procedural workbench c):
Quote:

CFLAGS =

CC = gcc -O4 -g -DINLINE=__inline
AR = ar
RANLIB = ppc-amigaos-ranlib
DEBUGLIB =

all: HelloWorld

#HelloWorld: HelloWorld.o
# $(CC) -o HelloWorld HelloWorld.o gcc:lib/libm.a

HelloWorld.o: HelloWorld.cpp
$(CC) -c HelloWorld.cpp -o HelloWorld.o


I get these errors:

Quote:

5.Development:Development/cpp-projects/Helloworld> make
gcc -O4 -g -DINLINE=__inline -c HelloWorld.cpp -o HelloWorld.o
gcc -O4 -g -DINLINE=__inline HelloWorld.o -o HelloWorld
HelloWorld.o(.text+0x6): In function `main':
/Development/Development/cpp-projects/Helloworld/HelloWorld.cpp:8: undefined reference to `std::cout'
HelloWorld.o(.text+0x12):/Development/Development/cpp-projects/Helloworld/HelloWorld.cpp:8: undefined reference to `std::cout'
HelloWorld.o(.text+0x1c):/Development/Development/cpp-projects/Helloworld/HelloWorld.cpp:8: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
HelloWorld.o(.text+0x80): In function `__static_initialization_and_destruction_0':
/gcc/lib/gcc/ppc-amigaos/4.0.2/../../../../include/c++/4.0.2/iostream:76: undefined reference to `std::ios_base::Init::~Init()'
HelloWorld.o(.text+0x94):/gcc/lib/gcc/ppc-amigaos/4.0.2/../../../../include/c++/4.0.2/iostream:76: undefined reference to `std::ios_base::Init::Init()'
make: *** [HelloWorld] Error 1


What am I doing wrong ??

Avatar: Avro Vulcan - XH558 needs YOU !!
Go to top
Re: help ! problem compiling c++ using the GNU stuff in the OS4.0 SDK
Quite a regular
Quite a regular


See User information
@agafaster

g++ , not gcc (you have c++ program there)

Resized Image
"the expression, 'atonal music,' is most unfortunate--it is on a par with calling flying 'the art of not falling,' or swimming 'the art of not drowning.'. A. Schoenberg
Go to top
Re: help ! problem compiling c++ using the GNU stuff in the OS4.0 SDK
Just popping in
Just popping in


See User information
@Jack

Quote:

Jack wrote:
@agafaster

g++ , not gcc (you have c++ program there)


aha ! so I do need to distinguish - thought it'd sort of work it out for itself.

That worked - the glorious world of c++ development awaits

Avatar: Avro Vulcan - XH558 needs YOU !!
Go to top
Re: help ! problem compiling c++ using the GNU stuff in the OS4.0 SDK
Just popping in
Just popping in


See User information
@agafaster

Just as a side note: As soon as you want to try to compile a "bit" more
complex things than HelloWorld.cpp you might want to raise the
stack of your shell noticable .. default is 32k which is way too
less for GCC compiling C++ stuff .. i have it set to 5MB per default
(stack 5000000) and even that's sometimes too less..

Just to warn you, because i also often bitched about GCC crashing on
C++ sources where the cause simply was a too small stack.

AmigaOS 4 core developer
www.os4welt.de - Die deutsche AmigaOS 4 Gemeinschaft

"In the beginning was CAOS.."
-- Andy Finkel, 1988 (ViewPort article, Oct. 1993)
Go to top
Re: help ! problem compiling c++ using the GNU stuff in the OS4.0 SDK
Quite a regular
Quite a regular


See User information
@agafaster

Also: don't use -O4/3/2 stuff while developing. Slows the compilation a lot.
Switch it on in the final release.

And a warning: O4 can change semantics of the proram (afair, it'll throw a fat warning when it occures).
O3 and O2 is safer. So if the program does unexpected things, try to reduce optimisation and see if it helps.

Jack

Resized Image
"the expression, 'atonal music,' is most unfortunate--it is on a par with calling flying 'the art of not falling,' or swimming 'the art of not drowning.'. A. Schoenberg
Go to top
Re: help ! problem compiling c++ using the GNU stuff in the OS4.0 SDK
Just popping in
Just popping in


See User information
@Jack

Cheers !

I really must learn to read the instructions that come with these things - I did notice it took rather a long time for an 800MHz processor compiling 4 lines of code !

Avatar: Avro Vulcan - XH558 needs YOU !!
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project