Cuda by Example, compiling chap4 Julia set example Some help in figuring an example that is not work

I’m a noob at programming cuda. I’m working through the Cuda by Example book by Sanders and Kandrot. They Unfortunately do not give much advice by way of compiling, except to use nvcc, so I assume that their programs are supposed to compile relatively easily, but I got to the example in Chapter 4 regarding the Julia set computation. This fails when compiled. I get undefined reference errors.
. . . undefined reference to glutInit' . . . undefined reference to glutInitDisplayMode’
. . .
I think this might be associated with my LD_LIBRARY_PATHS variable that I’ve had a bit of trouble with, since this appear to be associated with the open GL libraries. Here are the spec for my environment:
Ubuntu 10.4 LTS Lucid x64
NVIDIA Cuda Compiler release 3.2
gcc version 4.4.3-4ubuntu5

I compile with “nvcc julia_cpu.cu” and I get the errors I’ve lists above. When I compile with “nvcc julia_cpu.cu -lGL” I get error “/usr/bin/ld cannot find -lGL” but locate finds several libGL.so files. libglut.so is only found in /usr/lib32.

Any help is appreciated.

I’m a noob at programming cuda. I’m working through the Cuda by Example book by Sanders and Kandrot. They Unfortunately do not give much advice by way of compiling, except to use nvcc, so I assume that their programs are supposed to compile relatively easily, but I got to the example in Chapter 4 regarding the Julia set computation. This fails when compiled. I get undefined reference errors.
. . . undefined reference to glutInit' . . . undefined reference to glutInitDisplayMode’
. . .
I think this might be associated with my LD_LIBRARY_PATHS variable that I’ve had a bit of trouble with, since this appear to be associated with the open GL libraries. Here are the spec for my environment:
Ubuntu 10.4 LTS Lucid x64
NVIDIA Cuda Compiler release 3.2
gcc version 4.4.3-4ubuntu5

I compile with “nvcc julia_cpu.cu” and I get the errors I’ve lists above. When I compile with “nvcc julia_cpu.cu -lGL” I get error “/usr/bin/ld cannot find -lGL” but locate finds several libGL.so files. libglut.so is only found in /usr/lib32.

Any help is appreciated.

SOLVED
glut libraries needed to be installed.

SOLVED
glut libraries needed to be installed.

Hi Andrew

May I ask details about how you solved it? I can’t get it to work, and it seems I have glut libraries installed, as far as I can see in the synaptic package manager I have freeglut installed on my Ubuntu 10

Best regards

Jacob Salomonsen

Compile it with the -lglut flag

nvcc -lglut -o julia_gpu julia_gpu.cu

I am having a very similar problem to this, but when I try compiling with the above command I get the following error:

[Will@CUDA Julia Set]$ nvcc -lglut -o julia_gpu julia_gpu.cu 

/usr/bin/ld: /tmp/tmpxft_00001bdc_00000000-13_julia_gpu.o: undefined reference to symbol 'glClear'

/usr/bin/ld: note: 'glClear' is defined in DSO /usr/lib/libGL.so.1 so try adding it to the linker command line

/usr/lib/libGL.so.1: could not read symbols: Invalid operation

collect2: ld returned 1 exit status

I am running Fedora 13 with a GT 430. I can compile all the examples given in the SDK and glut is installed. I also tried compiling with the following:

nvcc -lGL -lglut -o julia_gpu julia_gpu.cu

Here it throws

/usr/bin/ld: /tmp/tmpxft_00001bb0_00000000-13_julia_gpu.o: undefined reference to symbol 'pthread_create@@GLIBC_2.1'

/usr/bin/ld: note: 'pthread_create@@GLIBC_2.1' is defined in DSO /lib/libpthread.so.0 so try adding it to the linker command line

/lib/libpthread.so.0: could not read symbols: Invalid operation

collect2: ld returned 1 exit status

Any ideas? Any help would be greatly appreciated!

I just replaced Fedora 13 with Ubuntu, reinstalled and everything works fine now. I’m not sure what the problem was but I think the symbolic link was corrupted at some point.

Hi,

I followed the advice and included the glut libraries. Now I’m not having compilation errors. However, when execute the binary, I get no output… Nothing is displayed nor I get any return codes. I tried this from NSight Eclipse version IDE as well as in the terminal command line. Any ideas?

Thank you very much. I have solved my Prolbem. I’m using UBUNTU 12.04 Desktop and GPU Geforce GT 630.