Ive been trying to generate a cuda shared object of a modified (but working) sobelfilter using the makefile provided in the SDK, not getting anywhere.
According to other threads, my makefile should look like this:
# Add source files here
EXECUTABLE := mySobeldll
# Cuda source files (compiled with cudacc)
CUFILES := mySobeldllComb.cu
# C/C++ source files (compiled with gcc / c++)
CCFILES :=
CU_DEPS :=
##################################
# Rules and targets
include ../../common/common.mk
NVCCFLAGS += -Xcompiler -fPIC
CFLAGS += -fPIC
CXXFLAGS += -fPIC
LINK += -shared
I’ve tried many other things, but thats the makefile with every compiler’s flags set.
I usually get the error:
obj/release/mySobeldllComb.cu_o relocation R_X86_64_32 against `a local symbol’ can not be used when making a shared object; recompile with -fPIC
obj/release/mySobeldllComb.cu_o: could not read symbols: Bad value
Can some one please tell me what i’m doing wrong?
Thanks in advance!
wumpus
April 4, 2008, 7:18pm
2
As I can remember, you should use “-Xcompiler -fPIC” in your nvcc flags
Thanks for the quick response, but haven’t i done that in the makefile i posted?
NVCCFLAGS += -Xcompiler -fpic
Am i doing something wrong or missing something?
I’m on a 64 bit system - if that helps.
wumpus
April 5, 2008, 12:31pm
4
Thanks for the quick response, but haven’t i done that in the makefile i posted?
NVCCFLAGS += -Xcompiler -fpic
Am i doing something wrong or missing something?
I’m on a 64 bit system - if that helps.
[snapback]356804[/snapback]
Here I had that problem on a 64-bit machine as well (in 32-bit you don’t need the -fPIC). and In my case it went away after recompiling all object files with that flag. Weird.
I changed my .cu file a bit and now this is what I’m getting:
/usr/bin/ld: ../../lib/libcutil.a(cutil.cpp_o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
../../lib/libcutil.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [../../bin/linux/release/mySobeldll.so] Error 1
Any suggestions?
lars
April 16, 2008, 8:00am
6
I changed my .cu file a bit and now this is what I’m getting:
/usr/bin/ld: ../../lib/libcutil.a(cutil.cpp_o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
../../lib/libcutil.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [../../bin/linux/release/mySobeldll.so] Error 1
Any suggestions?
[snapback]363017[/snapback]
You probably need to recompile libcutil.a using the -fPIC option. If you change
Compilers
NVCC := nvcc
CXX := g++
CC := gcc
LINK := g++ -fPIC
to
Compilers
NVCC := nvcc -Xcompiler -fPIC
CXX := g++ -fPIC
CC := gcc -fPIC
LINK := g++ -fPIC
in sdk/common/common.mk and recompile libcutil, it might work better. I had a similar problem with cudpp and doing this solved it.
/Lars