Undefined reference to 'xdr_int' - rcp

I was doing an assignment in rpc. When i run the command "make -f Makefile.add" it throws me the following errors:
cc -g -o add_client add_clnt.o add_client.o add_xdr.o -lnsl
/usr/bin/ld: add_clnt.o: in function `add_1':
/home/mridu/rpc/add_clnt.c:18: undefined reference to `xdr_int'
/usr/bin/ld: /home/mridu/rpc/add_clnt.c:18: undefined reference to `xdr_int'
/usr/bin/ld: add_client.o: in function `add_prog_1':
/home/mridu/rpc/add_client.c:18: undefined reference to `clnt_create'
/usr/bin/ld: /home/mridu/rpc/add_client.c:20: undefined reference to `clnt_pcreateerror'
/usr/bin/ld: /home/mridu/rpc/add_client.c:27: undefined reference to `clnt_perror'
/usr/bin/ld: add_xdr.o: in function `xdr_numbers':
/home/mridu/rpc/add_xdr.c:13: undefined reference to `xdr_int'
/usr/bin/ld: /home/mridu/rpc/add_xdr.c:15: undefined reference to `xdr_int'
collect2: error: ld returned 1 exit status
make: *** [Makefile.add:41: add_client] Error 1
The following code is the code in the Makefile.add:
# This is a template Makefile generated by rpcgen
# Parameters
CLIENT = add_client
SERVER = add_server
SOURCES_CLNT.c =
SOURCES_CLNT.h =
SOURCES_SVC.c =
SOURCES_SVC.h =
SOURCES.x = add.x
TARGETS_SVC.c = add_svc.c add_server.c add_xdr.c
TARGETS_CLNT.c = add_clnt.c add_client.c add_xdr.c
TARGETS = add.h add_xdr.c add_clnt.c add_svc.c add_client.c add_server.c
OBJECTS_CLNT = $(SOURCES_CLNT.c:%.c=%.o) $(TARGETS_CLNT.c:%.c=%.o)
OBJECTS_SVC = $(SOURCES_SVC.c:%.c=%.o) $(TARGETS_SVC.c:%.c=%.o)
# Compiler flags
CFLAGS += -g
LDLIBS += -lnsl
LIBS+= -ltirrp
QMAKE_CXXFLAGS+= -ltirpc
RPCGENFLAGS =
# Targets
all : $(CLIENT) $(SERVER)
$(TARGETS) : $(SOURCES.x)
rpcgen $(RPCGENFLAGS) $(SOURCES.x)
$(OBJECTS_CLNT) : $(SOURCES_CLNT.c) $(SOURCES_CLNT.h) $(TARGETS_CLNT.c)
$(OBJECTS_SVC) : $(SOURCES_SVC.c) $(SOURCES_SVC.h) $(TARGETS_SVC.c)
$(CLIENT) : $(OBJECTS_CLNT)
$(LINK.c) -o $(CLIENT) $(OBJECTS_CLNT) $(LDLIBS)
$(SERVER) : $(OBJECTS_SVC)
$(LINK.c) -o $(SERVER) $(OBJECTS_SVC) $(LDLIBS)
clean:
$(RM) core $(TARGETS) $(OBJECTS_CLNT) $(OBJECTS_SVC) $(CLIENT) $(SERVER)
The following is the code from the add.x file:
struct numbers{
int num1;
int num2;
};
program ADD_PROG{
version ADD_VER{
int ADD( numbers )=1;
}=1;
}=0x23456789;
I tried adding the compiler flags:
LIBS+= -ltirrp
QMAKE_CXXFLAGS+= -ltirpc
But it still doesn't work. Help me solve the issue!!

Related

glibc compilation error: undefined reference to `__lll_lock_wait_private'

I got an error when compiling glibc and googled it for a long time and didn't get it! This is the output of the compiler:
x86_64-pc-linux-gnu-gcc -nostdlib -nostartfiles -shared -o /mnt/g/gcc/build/build-glibc-2.35/elf/ld.so.new \
-Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs \
/mnt/g/gcc/build/build-glibc-2.35/elf/librtld.os -Wl,--version-script=/mnt/g/gcc/build/build-glibc-2.35/ld.ma\
-Wl,-soname=ld-linux-x86-64.so.2 \
-Wl,-defsym=_begin=0
/usr/sbin/ld: /mnt/g/gcc/build/build-glibc-2.35/elf/librtld.os: in function `_dl_make_stacks_executable':
/mnt/g/gcc/build/glibc-2.35/elf/../sysdeps/unix/sysv/linux/dl-execstack.c:69: undefined reference to `__lll_lock_wait_private'
/usr/sbin/ld: /mnt/g/gcc/build/glibc-2.35/elf/../sysdeps/unix/sysv/linux/dl-execstack.c:91: undefined reference to `__lll_lock_wake_private'
/usr/sbin/ld: /mnt/g/gcc/build/build-glibc-2.35/elf/librtld.os: in function `__thread_gscope_wait':
/mnt/g/gcc/build/glibc-2.35/elf/../sysdeps/nptl/dl-thread_gscope_wait.c:79: undefined reference to `__lll_lock_wake_private'
/usr/sbin/ld: /mnt/g/gcc/build/glibc-2.35/elf/../sysdeps/nptl/dl-thread_gscope_wait.c:28: undefined reference to `__lll_lock_wait_private'
/usr/sbin/ld: /mnt/g/gcc/build/build-glibc-2.35/elf/librtld.os: in function `_dl_init_static_tls':
/mnt/g/gcc/build/glibc-2.35/elf/../elf/dl-tls.c:1092: undefined reference to `__lll_lock_wait_private'
/usr/sbin/ld: /mnt/g/gcc/build/glibc-2.35/elf/../elf/dl-tls.c:1103: undefined reference to `__lll_lock_wake_private'

Link object file to project with gprbuild

Using nvcc I created an object file from my project with the following bash script:
nvcc -Xcompiler -std=c99 -dc src/interface.cu src/functions.cu
nvcc -dlink interface.o functions.o -o obj/link.o
In my obj folder I get a link.o file. I need to link this file to my Ada project using gprbuild. I can compile an Ada-Cuda project perfectly if I don't use the separate compilation mode of nvcc. But now, as I need the separate compilation mode, I have to find a way to link link.o with the rest of the project. This is the .gpr file:
project Test is
for Languages use ("Ada");
for Source_Dirs use ("src");
for Object_Dir use "obj";
for Exec_Dir use ".";
for Main use ("main.adb");
for Create_Missing_Dirs use "True";
package Linker is
for Default_Switches("Ada") use (
"-L/usr/local/cuda/lib64",
"-lcuda",
"-lcudart",
"-lcudadevrt",
"-lstdc++",
"-lm");
for Leading_Switches("Ada") use (
"link.o" -- Doesn't work
);
end Linker;
end Test;
This is the error I get
Bind
[gprbind] main.bexch
[Ada] main.ali
Link
[link] main.adb
/usr/local/opt/gnat-19.1-x86_64/bin/../libexec/gcc/x86_64-pc-linux-gnu/7.3.1/ld: main.o: in function `_ada_main':
main.adb:(.text+0x5): undefined reference to `bind_say_hello'
/usr/local/opt/gnat-19.1-x86_64/bin/../libexec/gcc/x86_64-pc-linux-gnu/7.3.1/ld: link.o: in function `__cudaRegisterLinkedBinary_45_tmpxft_0000404a_00000000_11_interface_cpp1_ii_f804fc64':
link.stub:(.text+0x50): undefined reference to `__fatbinwrap_45_tmpxft_0000404a_00000000_11_interface_cpp1_ii_f804fc64'
/usr/local/opt/gnat-19.1-x86_64/bin/../libexec/gcc/x86_64-pc-linux-gnu/7.3.1/ld: link.o: in function `__cudaRegisterLinkedBinary_45_tmpxft_0000404a_00000000_13_functions_cpp1_ii_e57d67fc':
link.stub:(.text+0x96): undefined reference to `__fatbinwrap_45_tmpxft_0000404a_00000000_13_functions_cpp1_ii_e57d67fc'
collect2: error: ld returned 1 exit status
gprbuild: link of main.adb failed
gprbuild: failed command was: /usr/local/opt/gnat-19.1-x86_64/bin/gcc main.o link.o b__main.o -L/usr/local/cuda/lib64 -lcuda -lcudart -lcudadevrt -lstdc++ -lm -L/home/cir_eti/Documents/test/multi_cu_file/obj/ -L/home/cir_eti/Documents/test/multi_cu_file/obj/ -L/usr/local/opt/gnat-19.1-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.3.1/adalib/ -static-libgcc /usr/local/opt/gnat-19.1-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.3.1/adalib/libgnat.a -ldl -Wl,-rpath-link,/usr/local/opt/gnat-19.1-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.3.1//adalib -Wl,-z,origin,-rpath,/usr/local/cuda/lib64:$ORIGIN/obj:/usr/local/opt/gnat-19.1-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.3.1/adalib -o /home/cir_eti/Documents/test/multi_cu_file//main
I'm doing an interface to a DLL and the interface they give is via a C header-file, I have an autogenerated package from the spec; I'm adding the post-conditions and, in the private portion of the package, I put this Linker_Options pragma which instructs the linker to interface with the DLL. -- IIUC, you could use this to address your problem.
Package import_example is
Bad_Return : Exception;
SUCCESS : constant := 20007;
NOT_INITIALIZED : constant := 20008;
ERROR : constant := 20009;
INVALID : constant := 20010;
Function Return_Report (Name : String; Value : unsigned ) return String is
(Name & " should not return" & unsigned'Image(Value) & '.') with Inline;
function item_1 return unsigned -- some_c_header.h:249
with Import => True,
Convention => C,
External_Name => "item_1",
Post => item_1'Result in
SUCCESS | NOT_INITIALIZED | ERROR | INVALID
or else raise Bad_Return with
Return_Report("item_1", item_1'Result)
;
function wait return unsigned -- some_c_header.h:250
with Import => True,
Convention => C,
External_Name => "wait",
Post => wait'Result in
SUCCESS | NOT_INITIALIZED | ERROR
or else raise Bad_Return with
Return_Report("wait", wait'Result)
;
Private
Pragma Linker_Options( "-lsmcex" );
End import_example;

Stdio/Stdlib still linking after passing -ffreestanding and -nostdlib flags to linker

I'm trying to compile a bare metal application for an ARM c
Cortex-M3 processor and I'm having trouble setting up the compiler/link flags. I'm on Ubuntu Trusty, using arm-none-eabi-gcc compiler 4.9.3 20150529.
Here is my main.c:
#include <stdio.h>
void main() {
printf("Hello, world");
}
// Tons of clock initialization code ...
And here is the generated link command:
arm-none-eabi-gcc -mthumb -mcpu=cortex-m3 -mlittle-endian -g -ggdb
-T /home/user/hello-arm/cmake/../ldscripts/STM32F100XB_FLASH.ld
-ffreestanding -nostdlib CMakeFiles/blinky.elf.dir/src/main.c.o
CMakeFiles/blinky.elf.dir/src/stm32f1xx_hal_msp.c.o
CMakeFiles/blinky.elf.dir/src/stm32f1xx_it.c.o
CMakeFiles/blinky.elf.dir/src/stm32vl_discovery.c.o -o blinky.elf
system/libhal_init.a system/libhal_cortex.a system/libhal_flash.a
system/libhal_gpio.a system/libstartup.a system/libhal_rcc.a
and here is the error:
/usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m/libc.a(lib_a-init.o): In function `__libc_init_array':
init.c:(.text.__libc_init_array+0x20): undefined reference to `_init'
/usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-
eabi/lib/armv7-m/libc.a(lib_a-sbrkr.o): In function `_sbrk_r': sbrkr.c
(.text._sbrk_r+0xc): undefined reference to `_sbrk'
/usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none
eabi/lib/armv7-m/libc.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text._write_r+0x10): undefined reference to `_write'
/usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-
eabi/lib/armv7-m/libc.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text._close_r+0xc): undefined reference to `_close'
/usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-
eabi/lib/armv7-m/libc.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text._lseek_r+0x10): undefined reference to `_lseek'
/usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-
eabi/lib/armv7-m/libc.a(lib_a-readr.o): In function `_read_r': readr.c:
(.text._read_r+0x10): undefined reference to `_read'
/usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-
eabi/lib/armv7-m/libc.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text._fstat_r+0xe): undefined reference to `_fstat'
/usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-
eabi/lib/armv7-m/libc.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text._isatty_r+0xc): undefined reference to `_isatty'
I was expecting a different error though: printf undefined. This tells me that stdio.h is being found, and stdlib is being linked.
Finally it is worth noting one thing. If I remove -nostdlib, I get a very slightly different error:
/usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-
m/libg.a(lib_a-exit.o): In function `exit': exit.c:(.text.exit+0x16):
undefined reference to `_exit' /usr/bin/../lib/gcc/arm-none-
eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-m/libg.a(lib_a-sbrkr.o):
In function `_sbrk_r': sbrkr.c:(.text._sbrk_r+0xc): undefined reference to
`_sbrk' /usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-
eabi/lib/armv7-m/libg.a(lib_a-writer.o): In function `_write_r': writer.c:
(.text._write_r+0x10): undefined reference to `_write'
/usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-
m/libg.a(lib_a-closer.o): In function `_close_r': closer.c:
(.text._close_r+0xc): undefined reference to `_close'
/usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-
m/libg.a(lib_a-lseekr.o): In function `_lseek_r': lseekr.c:
(.text._lseek_r+0x10): undefined reference to `_lseek'
/usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-
m/libg.a(lib_a-readr.o): In function `_read_r': readr.c:
(.text._read_r+0x10): undefined reference to `_read'
/usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-
m/libg.a(lib_a-fstatr.o): In function `_fstat_r': fstatr.c:
(.text._fstat_r+0xe): undefined reference to `_fstat'
/usr/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7-
m/libg.a(lib_a-isattyr.o): In function `_isatty_r': isattyr.c:
(.text._isatty_r+0xc): undefined reference to `_isatty' collect2: error: ld
returned 1 exit status
[EDIT] Here is the compiling of main.c:
arm-none-eabi-gcc -DSTM32F100xB -mthumb -mcpu=cortex-m3
-mlittle-endian -nostdlib -ffreestanding -g -ggdb -I/home/user/hello-arm/apps/blinky/include -I/home/user/hello-arm/system/include/stm32f1xx_hal -I/home/user/hello-arm/system/include/cmsis -o CMakeFiles/blinky.elf.dir/src/main.c.o -c
/home/user/hello-arm/apps/blinky/src/main.c
[EDIT2] Object dump of main.c.o:
00000000 <main>:
0: b580 push {r7, lr}
2: b082 sub sp, #8
4: af00 add r7, sp, #0
6: 4824 ldr r0, [pc, #144] ; (98 <main+0x98>)
8: f7ff fffe bl 0 <printf>
c: f7ff fffe bl 0 <HAL_Init>
10: f7ff fffe bl a8 <SystemClock_Config>
14: 4a21 ldr r2, [pc, #132] ; (9c <main+0x9c>)
...
Looks like the printf symbol is still there.
[EDIT3] I just want to explicitly note that the difference between having -nostdlib and not having it is linking libc.a and libg.a
[EDIT4] The linker script makes no references to standard libraries outside of what I've pasted below:
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}

OpenGL linker error on MinGW

I tryies to init OpenGL on windows without GLFW ... her some relevant code:
#include <windows.h>
//...
if(!(g_hDC = GetDC(hWnd)))
return false;
if(!(iPixelFormat = ChoosePixelFormat(g_hDC, &pfdPixelFormat)))
return false;
if(!SetPixelFormat(g_hDC, iPixelFormat, &pfdPixelFormat))
return false;
if(!(g_hRC = wglCreateContext(g_hDC)))
return false;
if(!wglMakeCurrent(g_hDC, g_hRC))
return false;
//...
when I compile with mingw32-g++ -Wall -O2 -Wl,--subsystem,windows -lopengl32 -mwindows Init.c I get following errors:
Temp\cclcIFFB.o:init.c:(.text+0x281): undefined reference to `_wglCreateContext#4'
Temp\cclcIFFB.o:init.c:(.text+0x2a0): undefined reference to `_wglMakeCurrent#8'
collect2.exe: error: ld returned 1 exit status
Why this linker error acours?
Try putting your Init.c before the -lopengl32:
mingw32-g++ -Wall -O2 Init.c -Wl,--subsystem,windows -lopengl32 -mwindows
gcc can be picky about argument positioning.
You must add the OpenGL linker definition library opengl32.lib to the list of to be linked libraries.

Makefile for Gtk+ and cuda

I'm trying to develop a packet analyzer with CUDA support for pattern matching. I'm using GTK+ for GUI creation but I am not able to compile the GUI file together with the cuda files. How to write makefile for this case?
The project is having two parts: 1. Analyzer 2. GUI
Analyzer consists of many .c,.h files and one .cu file.
GUI part has only one file gui.c
I have included packet_analyzer.h in gui.c.
I tried the following makefile
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
i end up with the following errors:
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
You need to link with the CUDA runtime library. Add -lcudart to your link command (and CUDA lib path if necessary).
It's the nvcc -lpcap -lpthread $(ANALYZER) -o packet_analyzer.o line that's failing, right? With the -o option, you're telling it to build a complete executable, not just the object files. It needs a main function to do that, which I presume you don't have in any of the $(ANALYZER) files. Instead, try compiling all the sources with the -c flag (like you've done with gcc for gui.c), and then wrap it all together and link it with the other gcc command.

Resources