Hello everyone!

I'm facing now the problem with integrating CUDA-5.5 with QtCreator on Ubuntu 12.04. Steps I followed:
1. I installed CUDA-5.5 with samples, then builded them and run correctly.
2. I added to .bashrc file:
export PATH=$PATH:/usr/local/cuda-5.5/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-5.5/lib64
3. I made a program, which looks like follows:
cuda_main.cu:
Qt Code:
  1. #include <stdio.h>
  2. #include <cuda_runtime.h>
  3.  
  4. __global__ void cube(float * d_out, float * d_in){
  5. int index=threadIdx.x;
  6. float f=d_in[index];
  7. d_out[index]=f*f*f;
  8. }
  9.  
  10. extern "C"
  11. int cuda_main()
  12. {
  13. const int ARRAY_SIZE = 96;
  14. const int ARRAY_BYTES = ARRAY_SIZE * sizeof(float);
  15.  
  16. // generate the input array on the host
  17. float h_in[ARRAY_SIZE];
  18. for (int i = 0; i < ARRAY_SIZE; i++) {
  19. h_in[i] = float(i);
  20. }
  21. float h_out[ARRAY_SIZE];
  22.  
  23. // declare GPU memory pointers
  24. float * d_in;
  25. float * d_out;
  26.  
  27. // allocate GPU memory
  28. cudaMalloc((void**) &d_in, ARRAY_BYTES);
  29. cudaMalloc((void**) &d_out, ARRAY_BYTES);
  30.  
  31. // transfer the array to the GPU
  32. cudaMemcpy(d_in, h_in, ARRAY_BYTES, cudaMemcpyHostToDevice);
  33.  
  34. // launch the kernel
  35. cube<<<1, ARRAY_SIZE>>>(d_out, d_in);
  36.  
  37. // copy back the result array to the CPU
  38. cudaMemcpy(h_out, d_out, ARRAY_BYTES, cudaMemcpyDeviceToHost);
  39.  
  40. // print out the resulting array
  41. for (int i =0; i < ARRAY_SIZE; i++) {
  42. printf("%f", h_out[i]);
  43. printf(((i % 4) != 3) ? "\t" : "\n");
  44. }
  45.  
  46. cudaFree(d_in);
  47. cudaFree(d_out);
  48.  
  49. return 0;
  50. }
  51.  
  52. int main(int argc, char *argv[])
  53. {
  54. cuda_main();
  55. return 0;
  56. }
To copy to clipboard, switch view to plain text mode 

*.pro file:
Qt Code:
  1. CONFIG += console
  2. CONFIG -= qt
  3. TEMPLATE = app
  4. SOURCES += cuda_main.cu
  5. SOURCES -= cuda_main.cu
  6. CUDA_SOURCES += cuda_main.cu
  7.  
  8. # project build directories
  9. DESTDIR = $$system(pwd)
  10. OBJECTS_DIR = $$DESTDIR/Obj
  11.  
  12. # C++ flags
  13. QMAKE_CXXFLAGS_RELEASE = -O3
  14.  
  15. # Path to cuda toolkit install
  16. CUDA_DIR = /usr/local/cuda-5.5
  17.  
  18. # Path to header and libs files
  19. INCLUDEPATH += $$CUDA_DIR/include
  20. QMAKE_LIBDIR += $$CUDA_DIR/lib64 # Note I'm using a 64 bits Operating system
  21.  
  22. # libs used in your code
  23. LIBS += -lcudart \
  24. -lcuda
  25.  
  26. # GPU architecture
  27. CUDA_ARCH = sm_12 # I've a old device. Adjust with your compute capability
  28.  
  29. # Here are some NVCC flags I've always used by default.
  30. NVCCFLAGS = --compiler-options -fno-strict-aliasing -use_fast_math --ptxas-options=-v
  31.  
  32. # Prepare the extra compiler configuration (taken from the nvidia forum - i'm not an expert in this part)
  33. CUDA_INC = $$join(INCLUDEPATH,' -I','-I',' ')
  34. cuda.commands = $$CUDA_DIR/bin/nvcc -m64 -O3 -arch=$$CUDA_ARCH -c $$NVCCFLAGS \
  35. $$CUDA_INC $$LIBS ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT} 2>&1 \
  36. | sed -r \"s/\\(([0-9]+)\\)/:\\1/g\" 1>&2
  37.  
  38. cuda.dependency_type = TYPE_C
  39. cuda.depend_command = $$CUDA_DIR/bin/nvcc -O3 -M $$CUDA_INC $$NVCCFLAGS ${QMAKE_FILE_NAME}
  40. cuda.input = CUDA_SOURCES
  41. cuda.output = ${OBJECTS_DIR}${QMAKE_FILE_BASE}_cuda.o
  42.  
  43. # Tell Qt that we want add more stuff to the Makefile
  44. QMAKE_EXTRA_COMPILERS += cuda
To copy to clipboard, switch view to plain text mode 

4. Application builded correctly, but when I tried to run it from terminal i got message:
./CUDATry: error while loading shared libraries: libcudart.so.5.5: cannot open shared object file: No such file or directory
That's what ldd ./CUDATry return:
Qt Code:
  1. linux-vdso.so.1 => (0x00007fffb9dff000)
  2. libcudart.so.5.5 => /usr/local/cuda-5.5/lib64/libcudart.so.5.5 (0x00007fbfd3eca000)
  3. libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbfd3ae3000)
  4. libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fbfd38de000)
  5. libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fbfd35de000)
  6. libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fbfd33c1000)
  7. librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fbfd31b8000)
  8. /lib64/ld-linux-x86-64.so.2 (0x00007fbfd4119000)
  9. libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fbfd2ebc000)
  10. libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fbfd2ca6000)
To copy to clipboard, switch view to plain text mode 
So it looks like libcudart.so.5.5 was included properly... I dont know what to do, what do you think about it?