0

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

プロジェクトには 2 つの部分があります。 1. アナライザー 2. GUI
アナライザーは、多数の .c、.h ファイルと 1 つの .cu ファイルで構成されます。GUI部分には、私がインクルードした
ファイルgui.cが1つしかありません。packet_analyzer.hgui.c

次のメイクファイルを試しました

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
4

2 に答える 2

2

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

于 2012-04-19T14:57:41.833 に答える
1

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

于 2012-04-18T13:17:31.477 に答える