Qengineering / Face-Recognition-Jetson-Nano

Recognize 2000+ faces on your Jetson Nano with database auto-fill and anti-spoofing
https://qengineering.eu/deep-learning-examples-on-raspberry-32-64-os.html
BSD 3-Clause "New" or "Revised" License
108 stars 31 forks source link

collect2: error: ld returned 1 exit status using CMakeLists.txt #9

Closed gnajaganathan closed 2 years ago

gnajaganathan commented 2 years ago

I have build code CMakelists.txt for jetson nano. I got the error. I have pasted below. My CMakeLists.txt cmake_minimum_required(VERSION 3.10.2)

project(faceRecognize)

find_package(OpenCV REQUIRED)

find_package(Threads REQUIRED)

set(faceRecognize VERSION 1.0.0)

add_definitions(-std=c++14) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_THREAD_LIBS_INIT "-lpthread") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") set(CMAKE_HAVE_THREADS_LIBRARY 1) set(CMAKE_USE_WIN32_THREADS_INIT 0) set(CMAKE_USE_PTHREADS_INIT 1) set(THREADS_PREFER_PTHREAD_FLAG ON)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")

set(FACE_RECOGNITION_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/)

file(GLOB FACE_RECOGNITION_SRC "${FACE_RECOGNITION_PATH}/*.cpp")

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

include_directories(/usr/local/include/ncnn/)

add_executable(faceRecognitionV0 faceRecognitionMain.cpp ${FACE_RECOGNITION_SRC})

target_link_libraries(faceRecognitionV0 pthread dl)

target_link_libraries(faceRecognitionV0 ${OpenCV_LIBS} /usr/local/lib/ncnn/libGenericCodeGen.a /usr/local/lib/ncnn/libglslang.a /usr/local/lib/ncnn/libMachineIndependent.a /usr/local/lib/ncnn/libncnn.a /usr/local/lib/ncnn/libOGLCompiler.a /usr/local/lib/ncnn/libOSDependent.a /usr/local/lib/ncnn/libSPIRV.a /usr/lib/aarch64-linux-gnu/libvulkan.so)

[ 12%] Building CXX object CMakeFiles/faceRecognitionV0.dir/faceRecognitionMain.cpp.o [ 25%] Building CXX object CMakeFiles/faceRecognitionV0.dir/src/TArcface.cpp.o [ 37%] Building CXX object CMakeFiles/faceRecognitionV0.dir/src/TBlur.cpp.o [ 50%] Building CXX object CMakeFiles/faceRecognitionV0.dir/src/TLive.cpp.o [ 62%] Building CXX object CMakeFiles/faceRecognitionV0.dir/src/TMtCNN.cpp.o [ 75%] Building CXX object CMakeFiles/faceRecognitionV0.dir/src/TRetina.cpp.o [ 87%] Building CXX object CMakeFiles/faceRecognitionV0.dir/src/TWarp.cpp.o [100%] Linking CXX executable faceRecognitionV0 /usr/local/lib/ncnn/libncnn.a(gpu.cpp.o): In function ncnn::destroy_gpu_instance()': gpu.cpp:(.text+0xca0): undefined reference toglslang::FinalizeProcess()' /usr/local/lib/ncnn/libncnn.a(gpu.cpp.o): In function ncnn::create_gpu_instance()': gpu.cpp:(.text+0x3e40): undefined reference toglslang::InitializeProcess()' /usr/local/lib/ncnn/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 toglslang::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 toglslang::TShader::addProcesses(std::vector<std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::cxx11::basic_string<char, std::char_traits, std::allocator > > > const&)' gpu.cpp:(.text+0x7820): undefined reference to glslang::TShader::setEntryPoint(char const*)' gpu.cpp:(.text+0x782c): undefined reference toglslang::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 toglslang::TShader::getInfoDebugLog()' gpu.cpp:(.text+0x7a54): undefined reference to glslang::TShader::~TShader()' gpu.cpp:(.text+0x8410): undefined reference toglslang::TShader::~TShader()' gpu.cpp:(.text+0x9334): undefined reference to glslang::TShader::~TShader()' /usr/local/lib/ncnn/libSPIRV.a(GlslangToSpv.cpp.o): In function(anonymous namespace)::TGlslangToSpvTraverser::convertGlslangStructToSpvType(glslang::TType const&, glslang::TVector const, glslang::TLayoutPacking, glslang::TQualifier const&)': GlslangToSpv.cpp:(.text+0x92b4): undefined reference to glslang::TIntermediate::computeTypeLocationSize(glslang::TType const&, EShLanguage)' GlslangToSpv.cpp:(.text+0x97dc): undefined reference toglslang::TIntermediate::getMemberAlignment(glslang::TType const&, int&, int&, glslang::TLayoutPacking, bool)' GlslangToSpv.cpp:(.text+0x9818): undefined reference to glslang::TIntermediate::improperStraddle(glslang::TType const&, int, int)' GlslangToSpv.cpp:(.text+0x9a88): undefined reference toglslang::TIntermediate::getMemberAlignment(glslang::TType const&, int&, int&, glslang::TLayoutPacking, bool)' /usr/local/lib/ncnn/libSPIRV.a(GlslangToSpv.cpp.o): In function (anonymous namespace)::TGlslangToSpvTraverser::convertGlslangToSpvType(glslang::TType const&, glslang::TLayoutPacking, glslang::TQualifier const&, bool, bool)': GlslangToSpv.cpp:(.text+0xad40): undefined reference toglslang::TIntermediate::getMemberAlignment(glslang::TType const&, int&, int&, glslang::TLayoutPacking, bool)' GlslangToSpv.cpp:(.text+0xb200): undefined reference to glslang::TIntermediate::getMemberAlignment(glslang::TType const&, int&, int&, glslang::TLayoutPacking, bool)' /usr/local/lib/ncnn/libSPIRV.a(GlslangToSpv.cpp.o): In function(anonymous namespace)::TGlslangToSpvTraverser::visitBinary(glslang::TVisit, glslang::TIntermBinary)': GlslangToSpv.cpp:(.text+0xbb68): undefined reference to glslang::TIntermediate::getBaseAlignmentScalar(glslang::TType const&, int&)' GlslangToSpv.cpp:(.text+0xc328): undefined reference toglslang::TIntermediate::getBaseAlignmentScalar(glslang::TType const&, int&)' GlslangToSpv.cpp:(.text+0xcda4): undefined reference to glslang::TIntermediate::getBaseAlignmentScalar(glslang::TType const&, int&)' /usr/local/lib/ncnn/libSPIRV.a(GlslangToSpv.cpp.o): In function(anonymous namespace)::TGlslangToSpvTraverser::convertGlslangToSpvType(glslang::TType const&, glslang::TLayoutPacking, glslang::TQualifier const&, bool, bool) [clone .constprop.1111]': GlslangToSpv.cpp:(.text+0xec90): undefined reference to glslang::TIntermediate::getMemberAlignment(glslang::TType const&, int&, int&, glslang::TLayoutPacking, bool)' GlslangToSpv.cpp:(.text+0xf138): undefined reference toglslang::TIntermediate::getMemberAlignment(glslang::TType const&, int&, int&, glslang::TLayoutPacking, bool)' /usr/local/lib/ncnn/libSPIRV.a(GlslangToSpv.cpp.o): In function (anonymous namespace)::TGlslangToSpvTraverser::getSymbolId(glslang::TIntermSymbol const*)': GlslangToSpv.cpp:(.text+0x16c88): undefined reference toglslang::GetThreadPoolAllocator()' GlslangToSpv.cpp:(.text+0x17f98): undefined reference to glslang::TPoolAllocator::allocate(unsigned long)' /usr/local/lib/ncnn/libSPIRV.a(GlslangToSpv.cpp.o): In function(anonymous namespace)::TGlslangToSpvTraverser::visitAggregate(glslang::TVisit, glslang::TIntermAggregate)': GlslangToSpv.cpp:(.text+0x1ce24): undefined reference to glslang::TIntermediate::findLinkerObjects() const' /usr/local/lib/ncnn/libSPIRV.a(GlslangToSpv.cpp.o): In functionglslang::GlslangToSpv(glslang::TIntermediate const&, std::vector<unsigned int, std::allocator >&, spv::SpvBuildLogger, glslang::SpvOptions)': GlslangToSpv.cpp:(.text+0x1e504): undefined reference to glslang::GetThreadPoolAllocator()' GlslangToSpv.cpp:(.text+0x1e508): undefined reference toglslang::TPoolAllocator::push()' GlslangToSpv.cpp:(.text+0x1e540): undefined reference to glslang::GetThreadPoolAllocator()' GlslangToSpv.cpp:(.text+0x1e568): undefined reference toglslang::GetKhronosToolId()' GlslangToSpv.cpp:(.text+0x1ec38): undefined reference to glslang::GetThreadPoolAllocator()' GlslangToSpv.cpp:(.text+0x1ec3c): undefined reference toglslang::TPoolAllocator::pop()' /usr/local/lib/ncnn/libSPIRV.a(GlslangToSpv.cpp.o): In function glslang::TType::setFieldName(std::__cxx11::basic_string<char, std::char_traits<char>, glslang::pool_allocator<char> > const&)': GlslangToSpv.cpp:(.text._ZN7glslang5TType12setFieldNameERKNSt7__cxx1112basic_stringIcSt11char_traitsIcENS_14pool_allocatorIcEEEE[_ZN7glslang5TType12setFieldNameERKNSt7__cxx1112basic_stringIcSt11char_traitsIcENS_14pool_allocatorIcEEEE]+0x1c): undefined reference toglslang::GetThreadPoolAllocator()' GlslangToSpv.cpp:(.text._ZN7glslang5TType12setFieldNameERKNSt7cxx1112basic_stringIcSt11char_traitsIcENS_14pool_allocatorIcEEEE[_ZN7glslang5TType12setFieldNameERKNSt7__cxx1112basic_stringIcSt11char_traitsIcENS_14pool_allocatorIcEEEE]+0x24): undefined reference to `glslang::TPoolAllocator::allocate(unsigned long)' GlslangToSpv.cpp:(.text._ZN7glslang5TType12setFieldNameERKNSt7cxx1112basic_stringIcSt11char_traitsIcENS_14pool_allocatorIcEEEE[_ZN7glslang5TType12setFieldNameERKNSt7cxx1112basic_stringIcSt11char_traitsIcENS_14pool_allocatorIcEEEE]+0x2c): undefined reference to `glslang::GetThreadPoolAllocator()' GlslangToSpv.cpp:(.text._ZN7glslang5TType12setFieldNameERKNSt7__cxx1112basic_stringIcSt11char_traitsIcENS_14pool_allocatorIcEEEE[_ZN7glslang5TType12setFieldNameERKNSt7cxx1112basic_stringIcSt11char_traitsIcENS_14pool_allocatorIcEEEE]+0xa4): undefined reference to glslang::TPoolAllocator::allocate(unsigned long)' /usr/local/lib/ncnn/libSPIRV.a(GlslangToSpv.cpp.o): In functionvoid std::vector<glslang::TArraySize, glslang::pool_allocator >::_M_range_insert<__gnu_cxx::__normal_iterator<glslang::TArraySize, std::vector<glslang::TArraySize, glslang::pool_allocator > > >(gnu_cxx::normal_iterator<glslang::TArraySize*, std::vector<glslang::TArraySize, glslang::pool_allocator > >, gnu_cxx::normal_iterator<glslang::TArraySize, std::vector<glslang::TArraySize, glslang::pool_allocator > >, __gnu_cxx::__normal_iterator<glslang::TArraySize, std::vector<glslang::TArraySize, glslang::pool_allocator > >, std::forward_iterator_tag)': GlslangToSpv.cpp:(.text._ZNSt6vectorIN7glslang10TArraySizeENS0_14pool_allocatorIS1_EEE15_M_range_insertIN9gnu_cxx17__normal_iteratorIPS1_S4_EEEEvS9_T_SA_St20forward_iterator_tag[_ZNSt6vectorIN7glslang10TArraySizeENS0_14pool_allocatorIS1_EEE15_M_range_insertIN9gnu_cxx17__normal_iteratorIPS1_S4_EEEEvS9_T_SA_St20forward_iterator_tag]+0xf4): undefined reference to glslang::TPoolAllocator::allocate(unsigned long)' /usr/local/lib/ncnn/libSPIRV.a(GlslangToSpv.cpp.o): In functionglslang::TType::TType(glslang::TType const&, int, bool)': GlslangToSpv.cpp:(.text._ZN7glslang5TTypeC2ERKS0_ib[_ZN7glslang5TTypeC5ERKS0_ib]+0x2e4): undefined reference to glslang::GetThreadPoolAllocator()' GlslangToSpv.cpp:(.text._ZN7glslang5TTypeC2ERKS0_ib[_ZN7glslang5TTypeC5ERKS0_ib]+0x2ec): undefined reference toglslang::TPoolAllocator::allocate(unsigned long)' GlslangToSpv.cpp:(.text._ZN7glslang5TTypeC2ERKS0_ib[_ZN7glslang5TTypeC5ERKS0_ib]+0x334): undefined reference to glslang::GetThreadPoolAllocator()' GlslangToSpv.cpp:(.text._ZN7glslang5TTypeC2ERKS0_ib[_ZN7glslang5TTypeC5ERKS0_ib]+0x33c): undefined reference toglslang::TPoolAllocator::allocate(unsigned long)' GlslangToSpv.cpp:(.text._ZN7glslang5TTypeC2ERKS0_ib[_ZN7glslang5TTypeC5ERKS0_ib]+0x344): undefined reference to `glslang::GetThreadPoolAllocator()' collect2: error: ld returned 1 exit status CMakeFiles/faceRecognitionV0.dir/build.make:318: recipe for target 'faceRecognitionV0' failed make[2]: [faceRecognitionV0] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/faceRecognitionV0.dir/all' failed make[1]: [CMakeFiles/faceRecognitionV0.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2

Qengineering commented 2 years ago

Somehow your ncnn installation isn't correct, or your cmake has an error. Follow the steps in the manual and try to compile the project first with code::blocks and this repo. This should go right in one go. Then you can create your cmake from the project file. In the cmake you send me I see that you are calling MachineIndependent.a, something that doesn't happen in the original.

gnajaganathan commented 2 years ago

I build the project using code::blocks. Its built successfully. In CMake, i linked the (libncnn.a,libglslang.a,libSPIRV.a,libMachineIndependent.a,libOGLCompiler.a,libOSDependent.a,libGenericCodeGen.a) and libvulkan.so files in CMakeLists.txt

Qengineering commented 2 years ago

Are you still getting an error message? Look in the FaceRecognition.cbp file with a text editor In addition to the correct list of files to link, you will also find many options defined. These are also crucial for a successful build. Study this file and see if you can translate it into a cmake file. After all, Code::blocks uses the same gcc compiler as cmake.

gnajaganathan commented 2 years ago

I changed order of the library files in linker setting in the Code::block project build options.I can able to reproduce the issue. Original library linking order is libncnn.a ,libglslang.a,libSPIRV.a,libMachineIndependent.a,libOGLCompiler.a,libOSDependent.a,libGenericCodeGen.a,libvulkan.so.

In Code::Block, If i run command or Ctrl+F10 face recognition is working fine. But when i execute same file from the terminal window, i got error. FaceRecognitionError

Qengineering commented 2 years ago

This error has to do with the location of the required models. Running from your current parent folder ..../bin/Debug, you will need a set of folders holding the deep learning models. They must located at .../bin/Debug/models/ etc.

gnajaganathan commented 2 years ago

It is working now.