ARM-software / ComputeLibrary

The Compute Library is a set of computer vision and machine learning functions optimised for both Arm CPUs and GPUs using SIMD technologies.
2.87k stars 783 forks source link

Error When compile neon_cnn.cpp using aarch64-linux-gnu-g++ tools #1066

Closed NNUCJ closed 1 year ago

NNUCJ commented 1 year ago

Hey: @morgolock OS: Ubuntu20.04 compile_toosl: aarch64-linux-gnu-g++ -v

Using built-in specs.
COLLECT_GCC=aarch64-linux-gnu-g++
COLLECT_LTO_WRAPPER=/usr/local/arm_linux/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/6.3.1/lto-wrapper
Target: aarch64-linux-gnu
Configured with: '/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/snapshots/gcc.git~linaro-6.3-2017.05/configure' SHELL=/bin/bash --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libmudflap --enable-lto --enable-shared --without-included-gettext --enable-nls --disable-sjlj-exceptions --enable-gnu-unique-object --enable-linker-build-id --disable-libstdcxx-pch --enable-c99 --enable-clocale=gnu --enable-libstdcxx-debug --enable-long-long --with-cloog=no --with-ppl=no --with-isl=no --disable-multilib --enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419 --with-arch=armv8-a --enable-threads=posix --enable-multiarch --enable-libstdcxx-time=yes --enable-gnu-indirect-function --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/sysroots/aarch64-linux-gnu --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu/aarch64-linux-gnu/libc --enable-checking=release --disable-bootstrap --enable-languages=c,c++,fortran,lto --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=aarch64-linux-gnu --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu
Thread model: posix
gcc version 6.3.1 20170404 (Linaro GCC 6.3-2017.05)

Compile command: aarch64-linux-gnu-g++ examples/neon_cnn.cpp utils/Utils.cpp -Wall -I. -Iinclude -std=c++14 -larm_compute-static -larm_compute_core-static -Lbuild -L. build/libarm_compute-static.a build/libarm_compute_core-static.a -o neon_cnn

Error:

/tmp/ccYZyDcS.o: In function `NEONCNNExample::do_setup(int, char**)':
neon_cnn.cpp:(.text._ZN14NEONCNNExample8do_setupEiPPc[_ZN14NEONCNNExample8do_setupEiPPc]+0x958): undefined reference to `arm_compute::NEConvolutionLayer::configure(arm_compute::ITensor*, arm_compute::ITensor const*, arm_compute::ITensor const*, arm_compute::ITensor*, arm_compute::PadStrideInfo const&, arm_compute::WeightsInfo const&, arm_compute::Size2D const&, arm_compute::ActivationLayerInfo const&, bool, unsigned int)'
neon_cnn.cpp:(.text._ZN14NEONCNNExample8do_setupEiPPc[_ZN14NEONCNNExample8do_setupEiPPc]+0x9b8): undefined reference to `arm_compute::NEActivationLayer::configure(arm_compute::ITensor*, arm_compute::ITensor*, arm_compute::ActivationLayerInfo)'
neon_cnn.cpp:(.text._ZN14NEONCNNExample8do_setupEiPPc[_ZN14NEONCNNExample8do_setupEiPPc]+0xa6c): undefined reference to `arm_compute::NEPoolingLayer::configure(arm_compute::ITensor*, arm_compute::ITensor*, arm_compute::PoolingLayerInfo const&, arm_compute::ITensor*)'
neon_cnn.cpp:(.text._ZN14NEONCNNExample8do_setupEiPPc[_ZN14NEONCNNExample8do_setupEiPPc]+0xb5c): undefined reference to `arm_compute::NEConvolutionLayer::configure(arm_compute::ITensor*, arm_compute::ITensor const*, arm_compute::ITensor const*, arm_compute::ITensor*, arm_compute::PadStrideInfo const&, arm_compute::WeightsInfo const&, arm_compute::Size2D const&, arm_compute::ActivationLayerInfo const&, bool, unsigned int)'
neon_cnn.cpp:(.text._ZN14NEONCNNExample8do_setupEiPPc[_ZN14NEONCNNExample8do_setupEiPPc]+0xbc0): undefined reference to `arm_compute::NEActivationLayer::configure(arm_compute::ITensor*, arm_compute::ITensor*, arm_compute::ActivationLayerInfo)'
neon_cnn.cpp:(.text._ZN14NEONCNNExample8do_setupEiPPc[_ZN14NEONCNNExample8do_setupEiPPc]+0xc78): undefined reference to `arm_compute::NEPoolingLayer::configure(arm_compute::ITensor*, arm_compute::ITensor*, arm_compute::PoolingLayerInfo const&, arm_compute::ITensor*)'
neon_cnn.cpp:(.text._ZN14NEONCNNExample8do_setupEiPPc[_ZN14NEONCNNExample8do_setupEiPPc]+0xd24): undefined reference to `arm_compute::NEFullyConnectedLayer::configure(arm_compute::ITensor const*, arm_compute::ITensor const*, arm_compute::ITensor const*, arm_compute::ITensor*, arm_compute::FullyConnectedLayerInfo, arm_compute::WeightsInfo const&)'
neon_cnn.cpp:(.text._ZN14NEONCNNExample8do_setupEiPPc[_ZN14NEONCNNExample8do_setupEiPPc]+0xd8c): undefined reference to `arm_compute::NEActivationLayer::configure(arm_compute::ITensor*, arm_compute::ITensor*, arm_compute::ActivationLayerInfo)'
neon_cnn.cpp:(.text._ZN14NEONCNNExample8do_setupEiPPc[_ZN14NEONCNNExample8do_setupEiPPc]+0xdd0): undefined reference to `arm_compute::NESoftmaxLayerGeneric<false>::configure(arm_compute::ITensor*, arm_compute::ITensor*, float, int)'
/tmp/ccYZyDcS.o: In function `NEONCNNExample::do_run()':
neon_cnn.cpp:(.text._ZN14NEONCNNExample6do_runEv[_ZN14NEONCNNExample6do_runEv]+0x68): undefined reference to `arm_compute::NEActivationLayer::run()'
neon_cnn.cpp:(.text._ZN14NEONCNNExample6do_runEv[_ZN14NEONCNNExample6do_runEv]+0x78): undefined reference to `arm_compute::NEPoolingLayer::run()'
neon_cnn.cpp:(.text._ZN14NEONCNNExample6do_runEv[_ZN14NEONCNNExample6do_runEv]+0xb0): undefined reference to `arm_compute::NEActivationLayer::run()'
neon_cnn.cpp:(.text._ZN14NEONCNNExample6do_runEv[_ZN14NEONCNNExample6do_runEv]+0xc0): undefined reference to `arm_compute::NEPoolingLayer::run()'
neon_cnn.cpp:(.text._ZN14NEONCNNExample6do_runEv[_ZN14NEONCNNExample6do_runEv]+0xf8): undefined reference to `arm_compute::NEActivationLayer::run()'
/tmp/ccYZyDcS.o: In function `std::_MakeUniq<arm_compute::NEConvolutionLayer>::__single_object std::make_unique<arm_compute::NEConvolutionLayer, std::shared_ptr<arm_compute::MemoryManagerOnDemand>&>(std::shared_ptr<arm_compute::MemoryManagerOnDemand>&)':
neon_cnn.cpp:(.text._ZSt11make_uniqueIN11arm_compute18NEConvolutionLayerEJRSt10shared_ptrINS0_21MemoryManagerOnDemandEEEENSt9_MakeUniqIT_E15__single_objectEDpOT0_[_ZSt11make_uniqueIN11arm_compute18NEConvolutionLayerEJRSt10shared_ptrINS0_21MemoryManagerOnDemandEEEENSt9_MakeUniqIT_E15__single_objectEDpOT0_]+0x44): undefined reference to `arm_compute::NEConvolutionLayer::NEConvolutionLayer(std::shared_ptr<arm_compute::IMemoryManager>)'
/tmp/ccYZyDcS.o: In function `std::_MakeUniq<arm_compute::NEFullyConnectedLayer>::__single_object std::make_unique<arm_compute::NEFullyConnectedLayer, std::shared_ptr<arm_compute::MemoryManagerOnDemand>&>(std::shared_ptr<arm_compute::MemoryManagerOnDemand>&)':
neon_cnn.cpp:(.text._ZSt11make_uniqueIN11arm_compute21NEFullyConnectedLayerEJRSt10shared_ptrINS0_21MemoryManagerOnDemandEEEENSt9_MakeUniqIT_E15__single_objectEDpOT0_[_ZSt11make_uniqueIN11arm_compute21NEFullyConnectedLayerEJRSt10shared_ptrINS0_21MemoryManagerOnDemandEEEENSt9_MakeUniqIT_E15__single_objectEDpOT0_]+0x48): undefined reference to `arm_compute::NEFullyConnectedLayer::NEFullyConnectedLayer(std::shared_ptr<arm_compute::IMemoryManager>, arm_compute::IWeightsManager*)'
/tmp/ccYZyDcS.o: In function `std::_MakeUniq<arm_compute::NESoftmaxLayerGeneric<false> >::__single_object std::make_unique<arm_compute::NESoftmaxLayerGeneric<false>, std::shared_ptr<arm_compute::MemoryManagerOnDemand>&>(std::shared_ptr<arm_compute::MemoryManagerOnDemand>&)':
neon_cnn.cpp:(.text._ZSt11make_uniqueIN11arm_compute21NESoftmaxLayerGenericILb0EEEJRSt10shared_ptrINS0_21MemoryManagerOnDemandEEEENSt9_MakeUniqIT_E15__single_objectEDpOT0_[_ZSt11make_uniqueIN11arm_compute21NESoftmaxLayerGenericILb0EEEJRSt10shared_ptrINS0_21MemoryManagerOnDemandEEEENSt9_MakeUniqIT_E15__single_objectEDpOT0_]+0x44): undefined reference to `arm_compute::NESoftmaxLayerGeneric<false>::NESoftmaxLayerGeneric(std::shared_ptr<arm_compute::IMemoryManager>)'
/tmp/ccYZyDcS.o: In function `NEONCNNExample::NEONCNNExample()':
neon_cnn.cpp:(.text._ZN14NEONCNNExampleC2Ev[_ZN14NEONCNNExampleC5Ev]+0x1dc): undefined reference to `arm_compute::NEPoolingLayer::NEPoolingLayer(std::shared_ptr<arm_compute::IMemoryManager>)'
neon_cnn.cpp:(.text._ZN14NEONCNNExampleC2Ev[_ZN14NEONCNNExampleC5Ev]+0x20c): undefined reference to `arm_compute::NEPoolingLayer::NEPoolingLayer(std::shared_ptr<arm_compute::IMemoryManager>)'
neon_cnn.cpp:(.text._ZN14NEONCNNExampleC2Ev[_ZN14NEONCNNExampleC5Ev]+0x228): undefined reference to `arm_compute::NEActivationLayer::NEActivationLayer(arm_compute::IRuntimeContext*)'
neon_cnn.cpp:(.text._ZN14NEONCNNExampleC2Ev[_ZN14NEONCNNExampleC5Ev]+0x23c): undefined reference to `arm_compute::NEActivationLayer::NEActivationLayer(arm_compute::IRuntimeContext*)'
neon_cnn.cpp:(.text._ZN14NEONCNNExampleC2Ev[_ZN14NEONCNNExampleC5Ev]+0x250): undefined reference to `arm_compute::NEActivationLayer::NEActivationLayer(arm_compute::IRuntimeContext*)'
neon_cnn.cpp:(.text._ZN14NEONCNNExampleC2Ev[_ZN14NEONCNNExampleC5Ev]+0x288): undefined reference to `arm_compute::NEActivationLayer::~NEActivationLayer()'
neon_cnn.cpp:(.text._ZN14NEONCNNExampleC2Ev[_ZN14NEONCNNExampleC5Ev]+0x2a0): undefined reference to `arm_compute::NEActivationLayer::~NEActivationLayer()'
neon_cnn.cpp:(.text._ZN14NEONCNNExampleC2Ev[_ZN14NEONCNNExampleC5Ev]+0x2b8): undefined reference to `arm_compute::NEPoolingLayer::~NEPoolingLayer()'
neon_cnn.cpp:(.text._ZN14NEONCNNExampleC2Ev[_ZN14NEONCNNExampleC5Ev]+0x2c8): undefined reference to `arm_compute::NEPoolingLayer::~NEPoolingLayer()'
/tmp/ccYZyDcS.o: In function `NEONCNNExample::~NEONCNNExample()':
neon_cnn.cpp:(.text._ZN14NEONCNNExampleD2Ev[_ZN14NEONCNNExampleD5Ev]+0x28): undefined reference to `arm_compute::NEActivationLayer::~NEActivationLayer()'
neon_cnn.cpp:(.text._ZN14NEONCNNExampleD2Ev[_ZN14NEONCNNExampleD5Ev]+0x38): undefined reference to `arm_compute::NEActivationLayer::~NEActivationLayer()'
neon_cnn.cpp:(.text._ZN14NEONCNNExampleD2Ev[_ZN14NEONCNNExampleD5Ev]+0x48): undefined reference to `arm_compute::NEActivationLayer::~NEActivationLayer()'
neon_cnn.cpp:(.text._ZN14NEONCNNExampleD2Ev[_ZN14NEONCNNExampleD5Ev]+0x58): undefined reference to `arm_compute::NEPoolingLayer::~NEPoolingLayer()'
neon_cnn.cpp:(.text._ZN14NEONCNNExampleD2Ev[_ZN14NEONCNNExampleD5Ev]+0x68): undefined reference to `arm_compute::NEPoolingLayer::~NEPoolingLayer()'
collect2: error: ld returned 1 exit status
morgolock commented 1 year ago

Hi @NNUCJ

It looks like scons cannot find the static library to link the binary.

Can you please remove the -static suffix and try to link against the .so ? you should only need -L./build/ -llibarm_compute to build the example

NNUCJ commented 1 year ago

Hi @NNUCJ

It looks like scons cannot find the static library to link the binary.

Can you please remove the -static suffix and try to link against the .so ? you should only need -L./build/ -llibarm_compute to build the example I have solved this problem, When compiling the so library, neon=1 was not set.