У меня возникли проблемы с компиляцией проекта cuda с помощью C Cuda и библиотек lodepng.
Мой makefile выглядит так.
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
Может ли кто-нибудь сказать мне, что я делаю неправильно, потому что он жалуется на
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)'
...
Мне просто нужен способ скомпилировать мой файл .cu и добавить в него файл C .o во время процесса компиляции с использованием nvcc.
РЕДАКТИРОВАТЬ: попробовал предложение. нет успеха.
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*)'
Он по-прежнему не может найти ссылку на объектный файл. Редактировать: вот наш файл .cu.
#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* );
nvcc
, но не включаете объект, который вы создали с помощью gcc (lodepng.o
). попробуйтеnvcc -o super-resolution-cuda super-resolution.o lodepng.o
вместо существующего шага ссылкиnvcc -o super-resolution-cuda super-resolution.o
. - person Robert Crovella   schedule 24.04.2014lodepng_encode32_file
разобралась, а ссылкаlodepng_decode32_file
нет? Вероятно, потребуется увидеть точный код, чтобы понять, почему и правильно ли вы выполняете компоновку C/C++ (например, extern C и т. д.). Вы уверены, что иlodepng_encode32_file
, иlodepng_decode32_file
экспортируются и используются одинаково? - person Robert Crovella   schedule 25.04.2014