error: identifier "_ZSt4cerr" is undefined

Hi,

I have installed new CUDA Toolkit 3.1 on my 64-bit Ubuntu 10.4. When compiling my code I get this message

error: identifier “_ZSt4cerr” is undefined

I would expect some linking problem but it seems to be a problem of a compilation since this message was invoked by

nvcc -DHAVE_CONFIG_H -I. -I…/…/src -I… -I/usr/local/cuda/include -DHAVE_CUDA -arch=sm_13 -DCUDA_ARCH=1.3 -I/home/oberhuber/local/include/tnl-0.1 -c …/…/src/gfFVMSchemeCUDAGetRHS.cu -Xcompiler -fPIC -DPIC -o .libs/libgeom_flow_0_3_la-gfFVMSchemeCUDAGetRHS.o

Can anybody help me?

Thanks, Tomas.

A random guess… the ‘cerr’ bit suggests that something is looking for iostream and not finding it? I agree that it looks more like a linker error, though.

Thanks for the reply. I should have put the complete message here.

/home/oberhuber/local/include/tnl-0.1/core/tnlField2D.h(28): error: identifier “_ZSt4cerr” is undefined

/home/oberhuber/local/include/tnl-0.1/core/tnlField2D.h(28): warning: a value of type “int” cannot be assigned to an entity of type “struct _ZSo *”

and here is the code

21 #include
22 #include <core/tnlLongVectorHost.h>
23
24 using namespace std;
25
26 template< class T > class tnlFieldCUDA2D;
27
28 template< class T > class tnlField2D : public tnlLongVector< T >
29 {
30 public:
31
32 tnlField2D( const char* name = 0 )
33 : tnlLongVector< T >( name )
34 {
35 };

I have added the lines 21 and 24 just because of the error message. They were not in the code before. I don’t get the message if I remove the line 26. This code can be compiled with gcc without errors.

Tomas.

It looks like a compiler bug to me. If you can post the smallest snippet of code which reproduces this error, I’ll file a bug.

This is the smallest one giving the error message.

//-------------------------------------------------------
#include
using namespace std;

enum tnlDevice { tnlHost, tnlCuda };

class tnlObject
{
public:

tnlObject();

virtual ~tnlObject(){};
};

template< typename T, tnlDevice device > class tnlLongVector : public tnlObject
{

};

template< class T > class tnlLongVector< T, tnlCuda > : public tnlObject
{
public:
~tnlLongVector()
{
cerr << “Unable to free alocated memory on CUDA device of .” << endl;
};

};

template< class T > class tnlGridCUDA2D : public tnlLongVector< T, tnlCuda >
{
public:

tnlGridCUDA2D( )
{
};

};

template class tnlGridCUDA2D< double >;
//---------------------------------------------------------------------------------------

Btw, there seems to be another problem with the templates parsing. Try this code:

#include <assert.h>

enum device { host, cuda };

template< typename T, device D > class number
{
public:
T x;

void test()
{
assert( number< T, D > :: x == 1 );
};
};

int main()
{
number< double, host > n1;
n1. test();
}

I was unable to reproduce an error from your first listing:

jhoberock@jhoberock-dt:~/dev/p4/research/research/jhoberock/src/bugs$ cat bug1.cu; nvcc bug1.cu; nvcc --version

#include <iostream>

using namespace std;

enum tnlDevice { tnlHost, tnlCuda };

class tnlObject

{

public:

tnlObject();

virtual ~tnlObject(){};

};

template< typename T, tnlDevice device > class tnlLongVector : public tnlObject

{

};

template< class T > class tnlLongVector< T, tnlCuda > : public tnlObject 

{

public:

~tnlLongVector()

{

cerr << "Unable to free alocated memory on CUDA device of ." << endl;

};

};

template< class T > class tnlGridCUDA2D : public tnlLongVector< T, tnlCuda > 

{

public:

tnlGridCUDA2D( )

{

};

};

int main(void)

{

  return 0;

}

nvcc: NVIDIA (R) Cuda compiler driver

Copyright (c) 2005-2010 NVIDIA Corporation

Built on Mon_Jun__7_18:10:28_PDT_2010

Cuda compilation tools, release 3.1, V0.2.1221

Your second listing needs parenthesis around the argument to assert:

assert( (number<T,D>::x == 1) );

Both g++ and nvcc get confused otherwise.

I would try compiling your code using nvcc 3.1.

Ok. With old nvcc

nvcc: NVIDIA (R) Cuda compiler driver

Copyright (c) 2005-2009 NVIDIA Corporation

Built on Fri_Feb_19_19:12:59_PST_2010

Cuda compilation tools, release 3.0, V0.2.1221

I get this

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 0 has invalid symbol index 11

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 1 has invalid symbol index 12

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 2 has invalid symbol index 2

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 3 has invalid symbol index 2

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 4 has invalid symbol index 11

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 5 has invalid symbol index 13

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 6 has invalid symbol index 13

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 7 has invalid symbol index 13

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 8 has invalid symbol index 2

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 9 has invalid symbol index 2

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 10 has invalid symbol index 12

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 11 has invalid symbol index 13

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 12 has invalid symbol index 13

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 13 has invalid symbol index 13

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 14 has invalid symbol index 13

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 15 has invalid symbol index 13

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 16 has invalid symbol index 13

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 17 has invalid symbol index 13

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 18 has invalid symbol index 13

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 19 has invalid symbol index 13

/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 20 has invalid symbol index 20

/usr/lib/gcc/x86_64-linux-gnu/4.3.4/../../../../lib/crt1.o: In function `_start':

(.text+0x20): undefined reference to `main'

/tmp/tmpxft_000008f0_00000000-12_bug.o: In function `tnlLongVector<double, (tnlDevice)1>::tnlLongVector()':

tmpxft_000008f0_00000000-1_bug.cudafe1.cpp:(.text._ZN13tnlLongVectorIdL9tnlDevice1EEC2Ev[tnlLongVector<double, (tnlDevice)1>::tnlLongVector()]+0x11): undefined reference to `tnlObject::tnlObject()'

collect2: ld returned 1 exit status

which is ok. The weird message comes from nvcc version

nvcc: NVIDIA (R) Cuda compiler driver

Copyright (c) 2005-2010 NVIDIA Corporation

Built on Mon_Jun__7_18:56:31_PDT_2010

Cuda compilation tools, release 3.1, V0.2.1221

Concerning the second bug - you are right, is is not a problem of nvcc, g++ does not accept it either eventhough it should I think.