Can't compile a simple c++ program

5 posts / 0 new
Last post
AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 5 years 3 weeks ago
Joined: 2012-02-18 19:55
Can't compile a simple c++ program
Hello everyone, i'm trying to compile a simple c++ program with g++ and codebench. The program works ok on Windows Code::Blocks/MinGW environment. As soon as i try to compile on amigaos i get tons of error. At first the errors was related to certain function written with the 0x11 c++ standard, that Amiga SDK doesn't support yet. I avoided this problem setting Code::Blocks to work with ox00 standard that is supported by Amiga OS latest SDK, as stated in the sdk documentation. Tried again to compile but getting 183 error, this time... I paste just a few lines of the build log: g++ -c -o ../Adventure/main.o ../Adventure/main.cpp SDK:gcc/bin/gcc -o Adventure ../Adventure/main.o -lauto ../Adventure/main.o: In function `std::__verify_grouping(char const*, unsigned int, std::string const&)': main.cpp:(.text+0x350): undefined reference to `std::string::size() const' main.cpp:(.text+0x3b0): undefined reference to `std::string::operator[](unsigned int) const' main.cpp:(.text+0x428): undefined reference to `std::string::operator[](unsigned int) const' main.cpp:(.text+0x4b4): undefined reference to `std::string::operator[](unsigned int) const' ../Adventure/main.o: In function `collectObject(int)': main.cpp:(.text+0x566): undefined reference to `std::cout' main.cpp:(.text+0x56a): undefined reference to `std::cout' main.cpp:(.text+0x574): undefined reference to `std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)' main.cpp:(.text+0x598): undefined reference to `std::basic_ostream >& std::operator<< , std::allocator >(std::basic_ostream >&, std::basic_string, std::allocator > const&)' main.cpp:(.text+0x5a6): undefined reference to `std::basic_ostream >& std::endl >(std::basic_ostream >&)' main.cpp:(.text+0x5aa): undefined reference to `std::basic_ostream >& std::endl >(std::basic_ostream >&)' main.cpp:(.text+0x5ac): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))' Any hint? Thank you very much
Hans
Hans's picture
Offline
Last seen: 6 days 4 hours ago
Joined: 2010-12-09 22:04
@AmigaBlitter You need to
@AmigaBlitter You need to use G++ for linking as well as compiling. Right now, you're using the C compiler to link a C++ program. Try: g++ -o Adventure ../Adventure/main.o -lauto Hans
http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more. Home of the RadeonHD driver for Amiga OS 4.x project. http://keasigmadelta.co.nz/ - more of my software.
AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 5 years 3 weeks ago
Joined: 2012-02-18 19:55
Thank you, Hans The build
Thank you, Hans The build log start with g++ -c -o ../Adventure/main.o ../Adventure/main.cpp SDK:gcc/bin/gcc -o Adventure ../Adventure/main.o -lauto i thought that automatically started with g++ as in the first line of the log... Going to try manually...
AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 5 years 3 weeks ago
Joined: 2012-02-18 19:55
Tested, and it works!!! Thank
Tested, and it works!!! Thank you again. Investigating now how can i setup CodeBench to use the right compiler.
salass00
salass00's picture
Offline
Last seen: 1 month 2 weeks ago
Joined: 2011-02-03 11:27
If you use the gcc command
If you use the gcc command instead of g++ for linking it won't link with the stdc++ library automatically so you need to specify it manually with -lstdc++.
Log in or register to post comments