ncnn/lib/libncnn.a(gpu.cpp.o): undefined reference to `glslang::FinalizeProcess()' etc.

bjp0bcyl  于 5个月前  发布在  其他
关注(0)|答案(5)|浏览(61)

Hi @nihui & ncnn users,

I am trying to use NCNN build library files for another project. First, I build NCNN in jetson nano according to the instruction Build for Linux / NVIDIA Jetson / Raspberry Pi. Now I have ncnn library and header files in ncnn/build/install folder. Vulkan was also enabled while building the ncnn.

While using NCNN lib in the separate project there is link error such as:

libncnn.a(gpu.cpp.o): undefined reference to `glslang::FinalizeProcess()'
...

I do not know why library linking is not working simply.

The attached file is the whole example project. I just took scrfd.cpp file in example for showing the bug.

jetson-ncnn-vulkan-app.zip

Build log and error:

jetson-ncnn-vulkan-app/build$ cmake ..
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenCV: /usr (found version "4.1.1")
-- Found Vulkan: /usr/lib/aarch64-linux-gnu/libvulkan.so
-- Found OpenMP_C: -fopenmp (found version "4.5")
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
OPENMP FOUND
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ghimire/Desktop/jetson-ncnn-vulkan-app/build
ghimire@jetsonnano:~/Desktop/jetson-ncnn-vulkan-app/build$ makeScanning dependencies of target NCNN_VULKAN_TEST
[ 50%] Building CXX object CMakeFiles/NCNN_VULKAN_TEST.dir/src/scrfd_ncnn.cpp.o
[100%] Linking CXX executable NCNN_VULKAN_TEST
../ncnn/lib/libncnn.a(gpu.cpp.o): In function `ncnn::destroy_gpu_instance()':
gpu.cpp:(.text+0xca0): undefined reference to `glslang::FinalizeProcess()'
../ncnn/lib/libncnn.a(gpu.cpp.o): In function `ncnn::create_gpu_instance()':
gpu.cpp:(.text+0x3e40): undefined reference to `glslang::InitializeProcess()'
../ncnn/lib/libncnn.a(gpu.cpp.o): In function `ncnn::compile_spirv_module(char const*, int, ncnn::Option const&, std::vector<unsigned int, std::allocator<unsigned int> >&)':
gpu.cpp:(.text+0x77e8): undefined reference to `glslang::TShader::TShader(EShLanguage)'
gpu.cpp:(.text+0x77fc): undefined reference to `glslang::TShader::setStringsWithLengths(char const* const*, int const*, int)'
gpu.cpp:(.text+0x7810): undefined reference to `glslang::TShader::addProcesses(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)'
gpu.cpp:(.text+0x7820): undefined reference to `glslang::TShader::setEntryPoint(char const*)'
gpu.cpp:(.text+0x782c): undefined reference to `glslang::TShader::setSourceEntryPoint(char const*)'
gpu.cpp:(.text+0x79c0): undefined reference to `glslang::TShader::parse(TBuiltInResource const*, int, EProfile, bool, bool, EShMessages, glslang::TShader::Includer&)'
gpu.cpp:(.text+0x7a08): undefined reference to `glslang::TShader::getInfoLog()'
gpu.cpp:(.text+0x7a30): undefined reference to `glslang::TShader::getInfoDebugLog()'
gpu.cpp:(.text+0x7a54): undefined reference to `glslang::TShader::~TShader()'
gpu.cpp:(.text+0x8404): undefined reference to `glslang::GlslangToSpv(glslang::TIntermediate const&, std::vector<unsigned int, std::allocator<unsigned int> >&, glslang::SpvOptions*)'
gpu.cpp:(.text+0x8410): undefined reference to `glslang::TShader::~TShader()'
gpu.cpp:(.text+0x9334): undefined reference to `glslang::TShader::~TShader()'
collect2: error: ld returned 1 exit status
CMakeFiles/NCNN_VULKAN_TEST.dir/build.make:117: recipe for target 'NCNN_VULKAN_TEST' failed
make[2]: *** [NCNN_VULKAN_TEST] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/NCNN_VULKAN_TEST.dir/all' failed
make[1]: *** [CMakeFiles/NCNN_VULKAN_TEST.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

I will really appreciate help with this issue.
Waiting to hear from you.

Thanks.

Best,
Deepak

agyaoht7

agyaoht71#

@nihui, yes. But all the libs are in the lib directory and they are linked in CMake file. I am wondering why it doesn't link.

polhcujo

polhcujo2#

Hello, did you solve this problem? I also encountered the same problem, how did you solve it?
My settings are here: #3247
Thank you.

pkln4tw6

pkln4tw63#

same problem, use this:
-lglslang -lshaderc_shared

wztqucjr

wztqucjr4#

Having the same issue, but on android, my Android.mk file:

LOCAL_PATH := $(call my-dir)

# change this folder path to yours
NCNN_INSTALL_PATH := ${LOCAL_PATH}/ncnn-android-vulkan-lib

include $(CLEAR_VARS)
LOCAL_MODULE := ncnn
LOCAL_SRC_FILES := $(NCNN_INSTALL_PATH)/$(TARGET_ARCH_ABI)/lib/libncnn.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := glslang
LOCAL_SRC_FILES := $(NCNN_INSTALL_PATH)/$(TARGET_ARCH_ABI)/lib/libglslang.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := SPIRV
LOCAL_SRC_FILES := $(NCNN_INSTALL_PATH)/$(TARGET_ARCH_ABI)/lib/libSPIRV.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := OGLCompiler
LOCAL_SRC_FILES := $(NCNN_INSTALL_PATH)/$(TARGET_ARCH_ABI)/lib/libOGLCompiler.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := OSDependent
LOCAL_SRC_FILES := $(NCNN_INSTALL_PATH)/$(TARGET_ARCH_ABI)/lib/libOSDependent.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := facebud
LOCAL_SRC_FILES := facebud.cpp

LOCAL_C_INCLUDES := $(NCNN_INSTALL_PATH)/$(TARGET_ARCH_ABI)/include $(NCNN_INSTALL_PATH)/$(TARGET_ARCH_ABI)/include/ncnn

LOCAL_STATIC_LIBRARIES := ncnn glslang OGLCompiler SPIRV OSDependent

LOCAL_CFLAGS := -O2 -fvisibility=hidden -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math
LOCAL_CPPFLAGS := -O2 -fvisibility=hidden -fvisibility-inlines-hidden -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math
LOCAL_LDFLAGS += -Wl,--gc-sections

LOCAL_CFLAGS += -fopenmp
LOCAL_CPPFLAGS += -fopenmp
LOCAL_LDFLAGS += -static-openmp -fopenmp

LOCAL_LDLIBS := -lz -llog -ljnigraphics -lvulkan -landroid

include $(BUILD_SHARED_LIBRARY)
nnsrf1az

nnsrf1az5#

The link error indicates that glslang and it relared libraries are not linked

相关问题