[問題] CUDA: 無法解析的外部符號 _cuda_sample
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC++ 2010
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
CUDA 5.0
問題(Question):
剛接觸CUDA不久,想建立一個簡單的程式,模擬在 .c file中的main能呼叫.cu內的
vector add function。
main裡面只有一個printf和一個被呼叫的function,該function是CUDA的範例。
餵入的資料(Input):
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
>C_FILE.obj : error LNK2019: 無法解析的外部符號 _cuda_sample 在函式 _main 中被
參考
>C:\Users\Yo\Desktop\D\R2\Debug\R2.exe : fatal error LNK1120: 1 個無法解析的
外部符號
程式碼(Code):(請善用置底文網頁, 記得排版)
C_FILE.c:
#include <stdio.h>
#include "CUDA_cowork.h"
int cuda_sample();
void main()
{
printf("Cowork is correct. \n");
cuda_sample();
}
=======================================================
CUDA_cowork.h:
int cuda_sample();
補充說明(Supplement):
搜尋error LNK2019:無法解析的外部符號,有提到更改Linker->Subsystem,
我試過改成Console 和 Windows都無法解決問題。
而且同樣的程式碼若將 .c 改成 .cpp 就能順利編譯並執行,
為何無法在 .c 檔案下執行,這點我很困惑!!
麻煩大家了,謝謝!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.187.150
→
05/07 01:02, , 1F
05/07 01:02, 1F
→
05/07 21:46, , 2F
05/07 21:46, 2F
→
05/07 21:46, , 3F
05/07 21:46, 3F
→
05/07 21:47, , 4F
05/07 21:47, 4F
→
05/07 21:48, , 5F
05/07 21:48, 5F
→
05/07 23:18, , 6F
05/07 23:18, 6F
→
05/07 23:21, , 7F
05/07 23:21, 7F
我懂了!!! 非常感謝你!!!
※ 編輯: bagaohya 來自: 140.116.187.150 (05/09 13:42)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章