Exception problem with QCC

When I try compiling the short program appended below, I get:

QCC -fexceptions extest.cpp -o extest
/tmp/AAA371497_cc.o: In function main': /tmp/AAA371497_cc.o(.text+0x2a): undefined reference to runtime_error::runtime_
error(basic_string<char, string_char_traits, __default_alloc_template<fals
e, 0> > const &)’
cc: /usr/bin/ntox86-ld error 1
make: *** [extest] Error 1

(This is under QNX 6.2/Momentics NC using the g+±3 libs)

Any advice as to how I can compile this correctly?

TIA,

  • Dave

P.S. The error is the same, with or without the ‘-fexceptions’ switch…


#include
#include
#include

using namespace std;

int main( int argc, char* argv[] )
{

try { throw runtime_error( “bad cheese” ); }
catch( runtime_error E ) { cout << "Error: " << E.what() << endl; }

return 0;
}

Colin Burgess wrote:

The gcc libs weren’t compiled with -fhonor-std, so you shouldn’t be
using the using namespace std; line.

I can’t get this to compile with or without “using namespace std;”.

I did a little investigation, and it seems that the signature for the
std::runtime_error constructor is different in the library, than it is
in the header (__default_alloc_template<true, 0> in the library
__default_alloc_template<false, 0> in the header).

The gcc libs weren’t compiled with -fhonor-std, so you shouldn’t be
using the using namespace std; line.

Cheers,

Colin

David Wolfe <da5id@luvspamwolfe.name> wrote:

When I try compiling the short program appended below, I get:

QCC -fexceptions extest.cpp -o extest
/tmp/AAA371497_cc.o: In function main': /tmp/AAA371497_cc.o(.text+0x2a): undefined reference to runtime_error::runtime_
error(basic_string<char, string_char_traits, __default_alloc_template<fals
e, 0> > const &)’
cc: /usr/bin/ntox86-ld error 1
make: *** [extest] Error 1

(This is under QNX 6.2/Momentics NC using the g+±3 libs)

Any advice as to how I can compile this correctly?

TIA,

  • Dave

P.S. The error is the same, with or without the ‘-fexceptions’ switch…


#include <iostream
#include <exception
#include <stdexcept

using namespace std;

int main( int argc, char* argv[] )
{

try { throw runtime_error( “bad cheese” ); }
catch( runtime_error E ) { cout << "Error: " << E.what() << endl; }

return 0;
}



cburgess@qnx.com