2012-04-18 26 views
0

私はパターンマッチングのためのCUDAサポートを備えたパケットアナライザを開発しようとしています。 GUIの作成にGTK +を使用していますが、GUIファイルをcudaファイルとともにコンパイルできません。この場合のmakefileの書き方は?Gtk +とcudaのメイクファイル

プロジェクトは二つの部分を持っている:1.アナライザ2. GUI
アナライザは、多くの.c、.hファイルと1 .cuファイルから構成されています。
GUI部分には1つのファイルしかありませんgui.c gui.cにはpacket_analyzer.hが含まれています。

私は、次のメイク

all: guitest 

guitest: gui.o list.o queue.o Word.o dictionary.o packet_capturer.o rule.o aho-corasick.o aho-corasick_cuda.o packet_analyzer.o 
    gcc -lpcap -lpthread `pkg-config --cflags --libs gtk+-2.0` gui.o list.o queue.o Word.o dictionary.o packet_capturer.o rule.o aho-corasick.o aho-corasick_cuda.o packet_analyzer.o 

gui.o: gui.c 
    gcc -lpcap -lpthread -c `pkg-config --cflags --libs gtk+-2.0` gui.c 

list.o : list.c 
    gcc -c list.c 

queue.o : queue.c 
    gcc -c queue.c 

Word.o : Word.c Word.h 
    gcc -c Word.c 

dictionary.o : dictionary.c 
    gcc -c dictionary.c 

rule.o : rule.c rule.h 
    gcc -c rule.c rule.h 

packet_capturer.o : packet_capturer.c 
    gcc -lpcap -lpthread -c packet_capturer.c 

aho-corasick.o : aho-corasick.c 
    gcc -lpcap -lpthread -c aho-corasick.c 

aho-corasick_cuda.o : aho-corasick_cuda.cu 
    nvcc -lpcap -lpthread -c aho-corasick_cuda.cu 

packet_analyzer.o : packet_analyzer.c 
    gcc -lpcap -lpthread -c packet_analyzer.c 

clean: 
    rm -rf *o guitest 

私は次のエラーで終了しようとした:

aho-corasick_cuda.o: In function `transfer_tries_from_hosttodevice(int, int, int)': 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x37): undefined reference to `cudaMalloc' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x5d): undefined reference to `cudaMalloc' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x86): undefined reference to `cudaMalloc' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0xac): undefined reference to `cudaMalloc' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0xd5): undefined reference to `cudaMalloc' 
aho-corasick_cuda.o:tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0xfb): more undefined references to `cudaMalloc' follow 
aho-corasick_cuda.o: In function `transfer_tries_from_hosttodevice(int, int, int)': 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x132): undefined reference to `cudaMemcpy' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x166): undefined reference to `cudaMemcpy' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x19d): undefined reference to `cudaMemcpy' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x1d1): undefined reference to `cudaMemcpy' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x208): undefined reference to `cudaMemcpy' 
aho-corasick_cuda.o:tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x23c): more undefined references to `cudaMemcpy' follow 
aho-corasick_cuda.o: In function `transfer_packets_from_hosttodevice(void*)': 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x3b1): undefined reference to `Queue_dequeue(Queue*)' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x519): undefined reference to `cudaMalloc' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x52b): undefined reference to `cudaMalloc' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x53d): undefined reference to `cudaMalloc' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x56b): undefined reference to `cudaMemcpy' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x58b): undefined reference to `cudaMemcpy' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x5ab): undefined reference to `cudaMemcpy' 
aho-corasick_cuda.o: In function `analyze_packets(void*)': 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x663): undefined reference to `cudaMalloc' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x683): undefined reference to `cudaMemcpy' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x6dd): undefined reference to `cudaConfigureCall' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x777): undefined reference to `cudaMemcpy' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x78a): undefined reference to `Queue_dequeue(Queue*)' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x7d5): undefined reference to `Queue_enqueue(Queue*, void*)' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x7f3): undefined reference to `cudaFree' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x802): undefined reference to `cudaFree' 
aho-corasick_cuda.o: In function `__cudaUnregisterBinaryUtil()': 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x824): undefined reference to `__cudaUnregisterFatBinary' 
aho-corasick_cuda.o: In function `__device_stub__Z14AC_search_CudaPiS_S_S_S_S_S_S_PhiS_(int*, int*, int*, int*, int*, int*, int*, int*, unsigned char*, int, int*)': 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x85c): undefined reference to `cudaSetupArgument' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x87f): undefined reference to `cudaSetupArgument' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x8a2): undefined reference to `cudaSetupArgument' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x8c5): undefined reference to `cudaSetupArgument' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x8e8): undefined reference to `cudaSetupArgument' 
aho-corasick_cuda.o:tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0x90b): more undefined references to `cudaSetupArgument' follow 
aho-corasick_cuda.o: In function `__sti____cudaRegisterAll_52_tmpxft_00001608_00000000_4_aho_corasick_cuda_cpp1_ii_9958a654()': 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0xa82): undefined reference to `__cudaRegisterFatBinary' 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text+0xae3): undefined reference to `__cudaRegisterFunction' 
aho-corasick_cuda.o: In function `cudaError cudaLaunch<char>(char*)': 
tmpxft_00001608_00000000-1_aho-corasick_cuda.cudafe1.cpp:(.text._Z10cudaLaunchIcE9cudaErrorPT_[cudaError cudaLaunch<char>(char*)]+0x14): undefined reference to `cudaLaunch' 
aho-corasick_cuda.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0' 
collect2: ld returned 1 exit status 
make: *** [guitest] Error 1 
+0

実際に表示されている問題を投稿できますか? – Tom

+0

質問を編集してください... – Arif

答えて

2

CUDAランタイムライブラリにリンクする必要があります。リンクコマンド(および必要に応じてCUDAのlibパス)に-lcudartを追加してください。

+0

ありがとうございました。 – Arif

1

をそれは右、失敗していますnvcc -lpcap -lpthread $(ANALYZER) -o packet_analyzer.oラインですか? -oオプションを使用すると、オブジェクトファイルだけでなく、完全な実行可能ファイルをビルドするように指示されます。これを行うにはmain関数が必要です。$(ANALYZER)ファイルのいずれにもないと推測します。代わりに、の場合はgui.cのようにすべてのソースを-cフラグでコンパイルしてから、すべてまとめてラップし、もう1つのgccコマンドとリンクしてください。

+0

ありがとうたくさん...私は上記のようにmakefileを変更しましたが、cuda関数が定義されていないというエラーが表示されています... – Arif

+0

'#include ' CUDA関数を呼び出すソースファイル? –

+0

いいえ。ヘッダファイル(cuda.h)がなくても、nvcc..iを使ってコンパイルすると、アナライザ部分が出力を出しています。ヘッダファイルを追加しようとしましたが、エラーが発生しました:cuda.h:そのようなファイルやディレクトリはありません。 – Arif