Rtoax / VTI-FD-CUDA-GTK

NVIDIA-based GPU Accelerated Finite Difference Forward Seismic Simulation of VTI Media]
GNU General Public License v3.0
24 stars 6 forks source link

Undefined Symbol reference errors during the build process #1

Open SIKtt opened 3 months ago

SIKtt commented 3 months ago

在编译和链接过程中遇到未定义符号的错误

# Copyright (C) RongTao, All right reserve.
CUDA_INSTALL_PATH = /usr/local/cuda-12.1
GCC_INSTALL_PATH = /usr

NVCC = $(CUDA_INSTALL_PATH)/bin/nvcc #cuda_12.1.r12.1
GCC = $(GCC_INSTALL_PATH)/bin/gcc-12 #gcc 12.3.0
MPICC = mpicc

LCUDA = -L$(CUDA_INSTALL_PATH)/lib64
LIB = -lcudart -lcurand -w -lm
LGTK  = `pkg-config --cflags --libs gtk+-2.0`

CFILES = CPU_vti2dfd_kernels.c
GTKFILES = GTK_main.c 
GPU2DFILES = GPU_vti2dfd_kernels.cu
GPU3DFILES = GPU_vti3dfd_kernels.cu
OBJECTS = GTK_main.o GPU_vti2dfd_kernels.o CPU_vti2dfd_kernels.o GPU_vti3dfd_kernels.o
EXECNAME = Tvtigpufd

all:
    $(GCC) -c $(GTKFILES) $(LGTK) 
    $(NVCC) -c $(GPU2DFILES)
    $(NVCC) -c $(GPU3DFILES)
    $(GCC) -c $(CFILES) 
    $(MPICC) -o $(EXECNAME) $(LCUDA) $(LIB) $(LGTK) $(OBJECTS) 
    rm -f *.o *~
clean:
    rm -f *.o *~

具体错误信息如下

mpicc -o Tvtigpufd -L/usr/local/cuda-12.1/lib64 -lcudart -lcurand -w -lm `pkg-config --cflags --libs gtk+-2.0` GTK_main.o GPU_vti2dfd_kernels.o CPU_vti2dfd_kernels.o GPU_vti3dfd_kernels.o
/usr/bin/ld: GTK_main.o: in function `on_menu_activate':
GTK_main.c:(.text+0x27): undefined reference to `g_print'
/usr/bin/ld: GTK_main.o: in function `on_button_clicked':
GTK_main.c:(.text+0x55): undefined reference to `g_print'
/usr/bin/ld: GTK_main.o: in function `About_window':
GTK_main.c:(.text+0x6a): undefined reference to `gtk_window_new'
/usr/bin/ld: GTK_main.c:(.text+0x73): undefined reference to `gtk_window_get_type'
/usr/bin/ld: GTK_main.c:(.text+0x85): undefined reference to `g_type_check_instance_cast'
/usr/bin/ld: GTK_main.c:(.text+0x9a): undefined reference to `gtk_window_set_title'
/usr/bin/ld: GTK_main.c:(.text+0x9f): undefined reference to `gtk_window_get_type'
...
/usr/bin/ld: CPU_vti2dfd_kernels.o:CPU_vti2dfd_kernels.c:(.text+0x15a3e): more undefined references to `pow' follow
/usr/bin/ld: CPU_vti2dfd_kernels.o: in function `mute_directwave':
CPU_vti2dfd_kernels.c:(.text+0x164b8): undefined reference to `sqrtf'
/usr/bin/ld: CPU_vti2dfd_kernels.o: in function `CPU_vti2dfd':
CPU_vti2dfd_kernels.c:(.text+0x16a1c): undefined reference to `sqrtf'
collect2: error: ld returned 1 exit status
make: *** [Makefile:27: all] Error 1

修正Makefile中的链接顺序?

$(MPICC) -o $(EXECNAME) $(LCUDA) $(OBJECTS) $(LIB) $(LGTK)
SIKtt commented 3 months ago

PR https://github.com/Rtoax/VTI-FD-CUDA-GTK/pull/2