[問題] 用makefile編譯包含CUDA的動態連結(.so)
開發平台(Platform): (Ex: Win10, Linux, ...)
Unbuntu 16
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
g++ 5.4
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
CUDA: 8 openCV:3.2
問題(Question):
想將自己的函式編譯成動態連結給別人使用
在win10 已成功產生其.dll並使用 by vs2017
但在ubuntu上make時卻出現錯誤結果
此時如果在.cpp 加個main 輸出程執行檔就不會有問題
懇請各位大大指點一下小弟makefile在輸出.so時做錯了哪步
餵入的資料(Input):
.cpp .cu .h檔
預期的正確結果(Expected Output):
成功產生 pdda.so
錯誤結果(Wrong Output):
/usr/bin/ld: ./pdda_cuda.o: relocation R_X86_64_32 against `.bss' can not be
used when making a shared object; recompile with -fPIC
./pdda_cuda.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
程式碼(Code):(請善用置底文網頁, 記得排版)
https://gist.github.com/ChiFang/70b6ee3ac2d3266373706ac16ff90345
pdda.so: pdda_cuda.o
g++ -fPIC -shared -o pdda.so ./src/pdda.cpp ./pdda_cuda.o -I ./src/
-I/usr/local/cuda/include -L/usr/local/cuda/lib64 -lcuda -lcudart `pkg-config
--libs opencv`
pdda_cuda.o:
nvcc -c ./src/pdda_cuda.cu -o pdda_cuda.o
clean:
補充說明(Supplement):
nvcc -c ./src/pdda_cuda.cu -o pdda_cuda.o >> 可執行 .o檔也有產生
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.132.89.186
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1517492778.A.4E0.html
※ 編輯: hardman1110 (220.132.89.186), 02/01/2018 21:47:30
推
02/01 22:14,
7年前
, 1F
02/01 22:14, 1F
→
02/01 22:27,
7年前
, 2F
02/01 22:27, 2F
→
02/01 22:28,
7年前
, 3F
02/01 22:28, 3F
→
02/01 22:36,
7年前
, 4F
02/01 22:36, 4F
推
02/01 23:11,
7年前
, 5F
02/01 23:11, 5F
→
02/01 23:11,
7年前
, 6F
02/01 23:11, 6F
→
02/01 23:17,
7年前
, 7F
02/01 23:17, 7F
→
02/01 23:17,
7年前
, 8F
02/01 23:17, 8F
→
02/01 23:52,
7年前
, 9F
02/01 23:52, 9F
→
02/02 10:56,
7年前
, 10F
02/02 10:56, 10F