I'm having some trouble compiling a cuda project with C Cuda and the lodepng libraries.
My makefile looks like this.
gpu: super-resolution.cu gcc -g -O -c lodepng.c nvcc -c super-resolution.cu nvcc -o super-resolution-cuda super-resolution.o rm -rf super-resolution.o rm -rf lodepng.o Could anyone tell me what I am doing wrong, because it is complaining about
nvcc warning : The 'compute_10' and 'sm_10' architectures are deprecated, and may be removed in a future release. super-resolution.o: In function `main': parallel-algorithm/super-resolution.cu:238: undefined reference to `lodepng_decode32_file(unsigned char**, unsigned int*, unsigned int*, char const*)' parallel-algorithm/super-resolution.cu:259: undefined reference to `lodepng_encode32_file(char const*, unsigned char const*, unsigned int, unsigned int)' parallel-algorithm/super-resolution.cu:269: undefined reference to `lodepng_encode32_file(char const*, unsigned char const*, unsigned int, unsigned int)' parallel-algorithm/super-resolution.cu:282: undefined reference to `lodepng_encode32_file(char const*, unsigned char const*, unsigned int, unsigned int)' parallel-algorithm/super-resolution.cu:292: undefined reference to `lodepng_encode32_file(char const*, unsigned char const*, unsigned int, unsigned int)' parallel-algorithm/super-resolution.cu:301: undefined reference to `lodepng_encode32_file(char const*, unsigned char const*, unsigned int, unsigned int)' ... I just need a way to compile my .cu file and add a C .o file into it during the compilation process using nvcc.
EDIT: tried suggestion. no success.
gcc -g -O -c lodepng.c nvcc -c super-resolution.cu nvcc warning : The 'compute_10' and 'sm_10' architectures are deprecated, and may be removed in a future release. super-resolution.cu:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated] #import "cuda.h" ^ super-resolution.cu(106): warning: expression has no effect super-resolution.cu(116): warning: expression has no effect super-resolution.cu(141): warning: variable "y" was declared but never referenced super-resolution.cu:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated] #import "cuda.h" ^ super-resolution.cu(106): warning: expression has no effect super-resolution.cu(116): warning: expression has no effect super-resolution.cu(141): warning: variable "y" was declared but never referenced ptxas /tmp/tmpxft_00000851_00000000-5_super-resolution.ptx, line 197; warning : Double is not supported. Demoting to float nvcc -o super-resolution-cuda super-resolution.o lodepng.o nvcc warning : The 'compute_10' and 'sm_10' architectures are deprecated, and may be removed in a future release. super-resolution.o: In function `main': tmpxft_00000851_00000000-3_super-resolution.cudafe1.cpp:(.text+0x5d): undefined reference to `lodepng_decode32_file(unsigned char**, unsigned int*, unsigned int*, char const*)' It still can't find the reference to the object file. Edit: here's our .cu file.
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <cstdio> extern "C" unsigned lodepng_encode32_file(const char* ,const unsigned char* , unsigned , unsigned h); extern "C" unsigned lodepng_decode32_file(unsigned char** , unsigned* , unsigned* ,const char* );
nvccbut not including the object you built with gcc (lodepng.o). trynvcc -o super-resolution-cuda super-resolution.o lodepng.oin place of your existingnvcc -o super-resolution-cuda super-resolution.olink step.lodepng_encode32_filereference got sorted out but thelodepng_decode32_filereference did not? Would probably need to see the exact code then to understand why and if you are doing C/C++ linking correctly (e.g. extern C, etc.) Are you sure that bothlodepng_encode32_fileandlodepng_decode32_fileare exported and used the same way?