sipeed / libmaix

New MaixCDK will replace this repo: https://github.com/sipeed/MaixCDK
https://github.com/sipeed/MaixCDK
MIT License
67 stars 27 forks source link

"libgcc_s.so.1: file not recognized: File format not recognized" on Ubuntu 20.04 #1

Closed mentarus closed 3 years ago

mentarus commented 3 years ago

Tried to get the hello_world example to compile on Ubuntu 20.04 (x64) but am getting an error at linking time: /usr/lib/libgcc_s.so.1: file not recognized: File format not recognized

On closer inspection it happens with every example. My libgcc-s1 version is 10.2.0

Thanks for looking into this!

Full output below:

-- SDK_PATH:/home/mentar/dev/libmaix
-- project name: camera
build now
-- SDK_PATH:/home/mentar/dev/libmaix
-- PROJECT_PATH:/home/mentar/dev/libmaix/examples/camera
-- PROJECT_NAME:camera
-- Find component: /home/mentar/dev/libmaix/components/libmaix
-- Find component Kconfig of libmaix
-- find component: /home/mentar/dev/libmaix/examples/camera/main
-- Project defaults config file:/home/mentar/dev/libmaix/examples/camera/config_defaults.mk
-- python command: python3, version: Python 3.8.5

-- Load default: /home/mentar/dev/libmaix/examples/camera/config_defaults.mk
-- Write makefile config at: /home/mentar/dev/libmaix/examples/camera/build/config/global_config.mk
-- Write  cmake  config  at: /home/mentar/dev/libmaix/examples/camera/build/config/global_config.cmake
-- write  c header file  at: /home/mentar/dev/libmaix/examples/camera/build/config/global_config.h
-- TOOLCHAIN_PATH:/opt/toolchain-sunxi-musl/toolchain/bin
-- The ASM compiler identification is GNU
-- Found assembler: /opt/toolchain-sunxi-musl/toolchain/bin/arm-openwrt-linux-muslgnueabi-gcc
-- The C compiler identification is GNU 6.4.1
-- The CXX compiler identification is GNU 6.4.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Config components priority success
-- [register component: libmaix ], path:/home/mentar/dev/libmaix/components/libmaix
-- [register component: main ], path:/home/mentar/dev/libmaix/examples/camera/main
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mentar/dev/libmaix/examples/camera/build
Scanning dependencies of target update_build_info
Scanning dependencies of target gen_exe_src
[ 12%] Generating exe_src.c
-- Update build time and version info to header  config  at: ('/home/mentar/dev/libmaix/examples/camera/build/config/global_build_info_time.h', '/home/mentar/dev/libmaix/examples/camera/build/config/global_build_info_version.h')
[ 12%] Built target gen_exe_src
[ 12%] Built target update_build_info
Scanning dependencies of target libmaix
[ 25%] Building C object libmaix/CMakeFiles/libmaix.dir/src/libmaix.c.obj
arm-openwrt-linux-muslgnueabi-gcc.bin: warning: environment variable 'STAGING_DIR' not defined
[ 37%] Linking C static library liblibmaix.a
[ 37%] Built target libmaix
Scanning dependencies of target main
[ 50%] Building C object main/CMakeFiles/main.dir/src/main.c.obj
arm-openwrt-linux-muslgnueabi-gcc.bin: warning: environment variable 'STAGING_DIR' not defined
[ 62%] Linking C static library libmain.a
[ 62%] Built target main
Scanning dependencies of target camera
[ 75%] Building C object CMakeFiles/camera.dir/exe_src.c.obj
arm-openwrt-linux-muslgnueabi-gcc.bin: warning: environment variable 'STAGING_DIR' not defined
[ 87%] Linking C executable camera
arm-openwrt-linux-muslgnueabi-gcc.bin: warning: environment variable 'STAGING_DIR' not defined
arm-openwrt-linux-muslgnueabi-gcc.bin: warning: environment variable 'STAGING_DIR' not defined
/usr/lib/libgcc_s.so.1: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/camera.dir/build.make:90: camera] Error 1
make[1]: *** [CMakeFiles/Makefile2:176: CMakeFiles/camera.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
Neutree commented 3 years ago

need 32 bit gcc support

install by

sudo apt install build-essential gcc-multilib g++-multilib 
mentarus commented 3 years ago

Thanks! I wish it was that easy, the above problem bit they are all already installed, furthermore:

~/dev/libmaix$ dpkg -l libgcc-s1
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name            Version               Architecture Description
+++-===============-=====================-============-=================================
ii  libgcc-s1:amd64 10.2.0-5ubuntu1~20.04 amd64        GCC support library
ii  libgcc-s1:i386  10.2.0-5ubuntu1~20.04 i386         GCC support library
Neutree commented 3 years ago

I tried in docker image ubuntu:18.04, no problem ocurrs

Neutree commented 3 years ago

And I update the CI: https://github.com/sipeed/libmaix/blob/master/.github/workflows/test_build.yml , it works, log here https://github.com/sipeed/libmaix/runs/2009678884?check_suite_focus=true

Your Detecting C compiler ABI info - failed should be Detecting C compiler ABI info - done, maybe cmake version error?

kervel commented 3 years ago

Hello,

i got the same problem on ubuntu 20.04. The problem is that it tries to use the main ubuntu libgcc_s.so in /usr/lib which it shouldn't (it should take the one from the toolchain in /opt)

i solved it by removing my /usr/lib/libgcc_s.so.1. it seems that nowadays this file is not supposed to be in /usr/lib but somewhere else (see https://packages.ubuntu.com/search?suite=trusty&arch=amd64&mode=exactfilename&searchon=contents&keywords=libgcc_s.so.1)

so i guess my libgcc_s is a leftover from an older installation of something ?

Neutree commented 3 years ago

@kervel @mentarus fixed in 04e6b63a9300a62d6a9bdfbc872623307d8691e9 , for some reason, the gcc not use the gcc's libgcc_s but used the system's, just add link flag resolved this issue.

if problem remain exists, just reopen