gcc and g++

swarmanizer pcardoso@ualg.pt
Thu Oct 8 17:16:00 GMT 2009


hello,

why does 

g++ file.cpp -o file #compile ok
gcc file.cpp -o file # doesn't compile  ok - log at the end...
 
for the following code 

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>

using namespace std;
int main()
{
  try
  {
    int *p = new int[100]; //exception-throwing new
  }
  catch(bad_alloc & new_failure) {/*..*/}
  int *p = new (nothrow) int [100]; // exception-free version of
  if (p)
  {/*..*/}
  return 0;
}
 


being the version of gcc: (Ubuntu 4.3.3-5ubuntu4) 4.3.3

thx,
S.


/tmp/ccjGVbYa.o: In function `__static_initialization_and_destruction_0(int,
int)':
l.cc:(.text+0x1d): undefined reference to `std::ios_base::Init::Init()'
l.cc:(.text+0x22): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccjGVbYa.o: In function `main':
l.cc:(.text+0x75): undefined reference to `operator new[](unsigned int)'
l.cc:(.text+0x98): undefined reference to `__cxa_begin_catch'
l.cc:(.text+0xa0): undefined reference to `__cxa_end_catch'
l.cc:(.text+0xa8): undefined reference to `std::nothrow'
l.cc:(.text+0xb4): undefined reference to `operator new[](unsigned int,
std::nothrow_t const&)'
/tmp/ccjGVbYa.o:(.gcc_except_table+0x10): undefined reference to `typeinfo
for std::bad_alloc'
/tmp/ccjGVbYa.o:(.eh_frame+0x12): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status




-- 
View this message in context: http://www.nabble.com/gcc-and-g%2B%2B-tp25803309p25803309.html
Sent from the gcc - libstdc++ mailing list archive at Nabble.com.



More information about the Libstdc++ mailing list