2013-06-30 14 views
-3

下開發的CUDA代碼的代碼是從Windows系統開發的,當我被命令編譯我的CUDA代碼的Linux系統:錯誤Linux下編譯時,最初的Windows

nvcc lbm.cu -I/usr/local/cuda_sdk/CUDALibraries/common/inc -lm 

編譯器的輸出是:

In file included from lbm.cu:15: 
lbm_kernel.h:52:8: warning: extra tokens at end of #endif directive 
In file included from lbm.cu:15: 
lbm_kernel.h:52:8: warning: extra tokens at end of #endif directive 
/tmp/tmpxft_00001fda_00000000-13_lbm.o: In function "main": 
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0xce7): undefined reference to "cutCheckCmdLineFlag" 
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x2103): undefined reference to "diff_wz_w(dim3, int, double*, double*, double*)" 
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x2143): undefined reference to "double gpu_sum<double>(int, int, int, int, int, double*, double*, double*)" 
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x21ca): undefined reference to "fabs_wz(dim3, int, double*, double*)" 
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x220a): undefined reference to "double gpu_sum<double>(int, int, int, int, int, double*, double*, double*)" 
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x22a3): undefined reference to "cpy(dim3, int, double*, double*)" 
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x2320): undefined reference to "lbm_step(dim3, int, int, double*)" 
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x23b5): undefined reference to "lbm_bounce_back_exit_inlet(dim3, int, int, float, float, double*, double*)" 
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x248f): undefined reference to "lbm_bounce_back_hole_wall_1(dim3, int, int, float, float, int, int, int, int, int, int, double*, double*)" 
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x2501): undefined reference to "lbm_bounce_back_wall_2(dim3, int, int, double*)" 
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x25a2): undefined reference to "lbm_stream(dim3, int, int, double*, double*)" 
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x2643): undefined reference to "lbm_den_vel(dim3, int, int, double*, double*, double*, double*, double*)" 
/tmp/tmpxft_00001fda_00000000-13_lbm.o: In function "__cutilExit(int, char**)": 
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text._Z11__cutilExitiPPc[__cutilExit(int, char**)]+0x21): undefined reference to "cutCheckCmdLineFlag" 
/tmp/tmpxft_00001fda_00000000-13_lbm.o: In function "cutilDeviceInit(int, char**)':  
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text._Z15cutilDeviceInitiPPc[cutilDeviceInit(int, char**)]+0x8b): undefined reference to "cutGetCmdLineArgumenti" 
collect2: ld returned 1 exit status 

我可以爲我的代碼做些什麼?

+0

可能的重複[當我編譯我的CUDA代碼時,它表示:在編譯「/tmp/tmpxft\_00005ff8\_00000000-4\_lbm.cpp1.ii"](http://stackoverflow。 com/questions/17233656/when-i-compile-my-cuda-code-it-said1-error-detected-the-the-the-the-compilation-of-tmp) – talonmies

+0

你之前詢問過這個* exact *問題。請不要再問它。 – talonmies

+0

您錯過了錯誤消息中列出的功能的鏈接。你有不同的文件嗎?你只是編譯'lbm.cu'文件。 – JackOLantern

回答

1

你需要包括包含仍然列爲「未定義的參考功能庫:

cutCheckCmdLineFlag 
cutGetCmdLineArgument 

使用編譯命令行的修改,這些功能或許可以被添加到您的鏈接過程對這樣的事情:

nvcc lbm.cu -I/usr/local/cuda_sdk/CUDALibraries/common/inc -L/usr/local/cuda_sdk/shared/lib -lshrutil -lcutil -lm 

不管怎樣,你要查找的圖書館libshrutil.alibshrutil_x86_64.alibcutil.alibcutil_x86_64.a,並且希望將其鏈接到您的程序通過使用-L開關指定這些庫的路徑並指定庫名稱(開頭減去lib,最後減去.a),使用-l開關。