gnu compiler and linker for C++

hi,

I just ported some C++ source-code incl. Makefile from QNX 4 to QNX 6. Most
of the modules compile and link as it should be. However in one executable
module consisting of 4 object modules I get for each module.o an error
message concerning the “std:: …” Scope

— snipp

cc -o Queue2 CStr.o Person.o Queue2.o Main.o
CStr.o: In function CStr::CStr(CStr const &)': CStr.o(.text+0xc5): undefined reference to std::cerr’
CStr.o: In function CStr::operator=(CStr const &)': CStr.o(.text+0x175): undefined reference to std::cerr’
CStr.o: In function CStr::ShowLine(void)': CStr.o(.text+0x365): undefined reference to std::cout’
CStr.o: In function __static_initialization_and_destruction_0': CStr.o(.text+0x3a2): undefined reference to std::ios_base::Init::Init(void)’
CStr.o(.text+0x3b7): undefined reference to
std::ios_base::Init::~Init(void)' CStr.o: In function std::basic_string<char, std::char_traits,
std::allocator >::_Copy(unsigned int, unsigned int)’:
CStr.o(.gnu.linkonce.t._Copy__Q23stdt12basic_string3ZcZQ23stdt11char_traits1
ZcZQ23stdt9allocator1ZcUiUi+0x121): undefined reference to
std::terminate(void)' CStr.o: In function std::basic_string<char, std::char_traits,
std::allocator >::_Grow(unsigned int, bool)’:
CStr.o(.gnu.linkonce.t._Grow__Q23stdt12basic_string3ZcZQ23stdt11char_traits1
ZcZQ23stdt9allocator1ZcUib+0x22): undefined reference to
std::_String_base::_Xlen(void) const' CStr.o: In function std::basic_string<char, std::char_traits,
std::allocator >::erase(unsigned int, unsigned int)’:

— snip —

any ideas what is missing?

Jörg

================= lat=52.35°N - lon=10.25°E ======================
http://www.ibk-consult.de

IBK-Consult <joerg.kampmann@ibk-consult.de> wrote:

hi,

I just ported some C++ source-code incl. Makefile from QNX 4 to QNX 6. Most
of the modules compile and link as it should be. However in one executable
module consisting of 4 object modules I get for each module.o an error
message concerning the “std:: …” Scope

— snipp

cc -o Queue2 CStr.o Person.o Queue2.o Main.o

When you link you have to tell the linker you are doing C++…

cc -lang-c++ -o Queue2 CStr.o Person.o Queue2.o Main.o

You might also have to specify which C++ lib you want to use with the -Y
option. Check the output from “use cc” for more info.

chris

\

Chris McKillop <cdm@qnx.com> “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/

cc -o foo foo.C

this option is not necessary. What is the difference ??

In that case cc knows already that it is a C++ program (based on the input
file). So it can do the right thing.

chris


Chris McKillop <cdm@qnx.com> “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/

thanks Chris - that works !!

but:

when I have a single module “make line” like

cc -o foo foo.C

this option is not necessary. What is the difference ??
Jörg

“Chris McKillop” <cdm@qnx.com> schrieb im Newsbeitrag
news:b98n8n$1u0$1@nntp.qnx.com

IBK-Consult <> joerg.kampmann@ibk-consult.de> > wrote:
hi,

I just ported some C++ source-code incl. Makefile from QNX 4 to QNX 6.
Most
of the modules compile and link as it should be. However in one
executable
module consisting of 4 object modules I get for each module.o an error
message concerning the “std:: …” Scope

— snipp

cc -o Queue2 CStr.o Person.o Queue2.o Main.o


When you link you have to tell the linker you are doing C++…

cc -lang-c++ -o Queue2 CStr.o Person.o Queue2.o Main.o

You might also have to specify which C++ lib you want to use with the -Y
option. Check the output from “use cc” for more info.

tnx
Jörg

cc -o foo foo.C

this option is not necessary. What is the difference ??


In that case cc knows already that it is a C++ program (based on the input
file). So it can do the right thing.


================= lat=52.35°N - lon=10.25°E ======================
http://www.ibk-consult.de