analogdevicesinc / libiio

A cross platform library for interfacing with local and remote Linux IIO devices
http://analogdevicesinc.github.io/libiio/
GNU Lesser General Public License v2.1
484 stars 311 forks source link

Libiio cross-compile issue with toolchain. libc_nonshared.a not found (#330 continued) #394

Closed paholden closed 4 years ago

paholden commented 4 years ago

This is a follow-up on #330 (for background). I created the following toolchain.cmake:

set(CMAKE_C_VERBOSE_FLAG "-vv") set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") set(LIBIIO_BASE ${CMAKE_CURRENT_LIST_DIR}) set(PRO3_SYSROOT_DIR ${LIBIIO_BASE}/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16) set(CMAKE_PREFIX_PATH ${PRO3_SYSROOT_DIR}) set(CMAKE_SYSROOT ${PRO3_SYSROOT_DIR}) set(CMAKE_STAGING_PREFIX ${CMAKE_SYSROOT}) set(PKG_CONFIG_SYSROOT_DIR ${CMAKE_SYSROOT}) set(tools $ENV{HOME}/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_INSTALL_PREFIX ${CMAKE_SYSROOT}/usr) set(CMAKE_C_COMPILER ${tools}/bin/arm-linux-gnueabihf-gcc) set(CMAKE_CXX_COMPILER ${tools}/bin/arm-linux-gnueabihf-g++) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${CMAKE_SYSROOT} -Wall -rdynamic" CACHE STRING "Build CFLAGS" FORCE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=${CMAKE_SYSROOT} -Wall -std=c++0x -rdynamic -D_TRACE ${CMAKE_CXX_FLAGS} " CACHE STRING "Build CXXFLAGS" FORCE) set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} --sysroot=${CMAKE_SYSROOT}" CACHE INTERNAL "" FORCE) set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${CMAKE_SYSROOT}" CACHE INTERNAL "" FORCE) link_directories(${CMAKE_SYSROOT}/lib/arm-linux-gnueabihf ${CMAKE_SYSROOT}/usr/lib/gcc/arm-linux-gnueabihf/6.5.0 ${CMAKE_SYSROOT}/usr/lib/arm-linux-gnueabihf)

set(CMAKE_EXPORT_COMPILE_COMMANDS=ON) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

I enter the following cmake command:

cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf -DCMAKE_TOOLCHAIN_FILE=$PRO3_BASE_DIR/packages/IIO_Utils/libiio/Pro3_toolchain.cmake ../

I get the following result:

-- The C compiler identification is GNU 7.5.0 -- Check for working C compiler: /home/patricaholden/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -- Check for working C compiler: /home/patricaholden/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -- broken CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message): The C compiler

"/home/patricaholden/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_334e2/fast"
/usr/bin/make -f CMakeFiles/cmTC_334e2.dir/build.make CMakeFiles/cmTC_334e2.dir/build
make[1]: Entering directory '/home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_334e2.dir/testCCompiler.c.o
/home/patricaholden/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc --sysroot=/home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16   --sysroot=/home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16 -Wall -rdynamic --sysroot=/home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16 -Wall -rdynamic    -o CMakeFiles/cmTC_334e2.dir/testCCompiler.c.o   -c /home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_334e2
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_334e2.dir/link.txt --verbose=1
/home/patricaholden/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc --sysroot=/home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16  --sysroot=/home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16 -Wall -rdynamic --sysroot=/home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16 -Wall -rdynamic   --sysroot=/home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16   -rdynamic CMakeFiles/cmTC_334e2.dir/testCCompiler.c.o  -o cmTC_334e2  -L/home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16/lib/arm-linux-gnueabihf  -L/home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16/usr/lib/gcc/arm-linux-gnueabihf/6.5.0  -L/home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16/usr/lib/arm-linux-gnueabihf 
/home/patricaholden/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.5.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find /usr/lib/libc_nonshared.a inside /home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_334e2.dir/build.make:97: recipe for target 'cmTC_334e2' failed
make[1]: *** [cmTC_334e2] Error 1
make[1]: Leaving directory '/home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_334e2/fast' failed
make: *** [cmTC_334e2/fast] Error 2

CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:2 (project)

-- Configuring incomplete, errors occurred! See also "/home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/build/CMakeFiles/CMakeOutput.log". See also "/home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/build/CMakeFiles/CMakeError.log".

It found crti.o correctly in my sysroot library path, which is in the same directory as the libc_nonshared.a file. So how come this is not working? I checked my laptop, the libc_nonshared.a library is in the /usr/lib/x86_64/, right along with crti.o.

dump of the sysroot usr/lib/arm-linux-gnueabihf/:

ls -l ubuntu-18.04.2-minimal-armhf-2019-02-16/usr/lib/arm-linux-gnueabihf/-linux-gnu total 113492 drwxr-xr-x 2 root root 4096 Feb 16 2019 audit drwxr-xr-x 2 root root 4096 Feb 16 2019 avahi drwxr-xr-x 2 root root 4096 Feb 16 2019 coreutils -rw-r--r-- 1 root root 3652 Mar 5 17:53 crt1.o -rw-r--r-- 1 root root 2152 Mar 5 17:53 crti.o -rw-r--r-- 1 root root 1740 Mar 5 17:53 crtn.o drwxr-xr-x 2 root root 4096 Feb 16 2019 engines-1.1 drwxr-xr-x 2 root root 12288 Feb 16 2019 gconv -rw-r--r-- 1 root root 7728 Mar 5 17:53 gcrt1.o drwxr-xr-x 2 root root 4096 Feb 16 2019 girepository-1.0 drwxr-xr-x 2 root root 4096 Feb 16 2019 glib-2.0 drwxr-xr-x 3 root root 4096 Feb 16 2019 krb5 -rw-r--r-- 1 root root 200860 Mar 5 17:53 libanl.a -rwxr-xr-x 1 root root 154380 Mar 5 17:53 libanl.so lrwxrwxrwx 1 root root 20 Jan 25 2019 libapt-inst.so.2.0 -> libapt-inst.so.2.0.0 -rw-r--r-- 1 root root 34264 Jan 25 2019 libapt-inst.so.2.0.0 lrwxrwxrwx 1 root root 19 Jan 25 2019 libapt-pkg.so.5.0 -> libapt-pkg.so.5.0.2 -rw-r--r-- 1 root root 1132928 Jan 25 2019 libapt-pkg.so.5.0.2 lrwxrwxrwx 1 root root 23 Jan 25 2019 libapt-private.so.0.0 -> libapt-private.so.0.0.0 -rw-r--r-- 1 root root 251400 Jan 25 2019 libapt-private.so.0.0.0 -rw-r--r-- 1 root root 26020 Jan 6 2018 libargon2.so.0 lrwxrwxrwx 1 root root 16 Dec 14 2017 libasn1.so.8 -> libasn1.so.8.0.0 -rw-r--r-- 1 root root 351076 Dec 14 2017 libasn1.so.8.0.0 lrwxrwxrwx 1 root root 18 Feb 5 2018 libassuan.so.0 -> libassuan.so.0.8.1 -rw-r--r-- 1 root root 46524 Feb 5 2018 libassuan.so.0.8.1 lrwxrwxrwx 1 root root 24 Jan 30 2019 libavahi-client.so.3 -> libavahi-client.so.3.2.9 -rw-r--r-- 1 root root 42764 Jan 30 2019 libavahi-client.so.3.2.9 lrwxrwxrwx 1 root root 24 Jan 30 2019 libavahi-common.so.3 -> libavahi-common.so.3.5.3 -rw-r--r-- 1 root root 30460 Jan 30 2019 libavahi-common.so.3.5.3 lrwxrwxrwx 1 root root 22 Jan 30 2019 libavahi-core.so.7 -> libavahi-core.so.7.0.2 -rw-r--r-- 1 root root 137012 Jan 30 2019 libavahi-core.so.7.0.2 lrwxrwxrwx 1 root root 19 Oct 10 2018 libbind9.so.160 -> libbind9.so.160.0.6 -rw-r--r-- 1 root root 46412 Oct 10 2018 libbind9.so.160.0.6 -rw-r--r-- 1 root root 22354 Mar 5 17:53 libBrokenLocale.a -rwxr-xr-x 1 root root 24260 Mar 5 17:53 libBrokenLocale.so -rw-r--r-- 1 root root 43632 Mar 12 2018 libbtrfs.a lrwxrwxrwx 1 root root 15 Mar 12 2018 libbtrfs.so -> libbtrfs.so.0.1 lrwxrwxrwx 1 root root 15 Mar 12 2018 libbtrfs.so.0 -> libbtrfs.so.0.1 -rw-r--r-- 1 root root 30388 Mar 12 2018 libbtrfs.so.0.1 -rw-r--r-- 1 root root 28410206 Mar 5 17:53 libc.a -rwxr-xr-x 1 root root 258828 Mar 5 17:53 libcidn.so -rw-r--r-- 1 root root 79264 Mar 5 17:53 libc_nonshared.a -rw-r--r-- 1 root root 188926 Mar 5 17:53 libcrypt.a -rw-r--r-- 1 root root 1128876 Dec 4 2018 libcrypto.so.1.0.0 -rw-r--r-- 1 root root 1442608 Dec 5 2018 libcrypto.so.1.1 -rwxr-xr-x 1 root root 168060 Mar 5 17:53 libcrypt.so -rw-r--r-- 1 root root 249 Mar 5 17:53 libc.so lrwxrwxrwx 1 root root 19 Jan 29 2019 libcurl-gnutls.so.3 -> libcurl-gnutls.so.4 lrwxrwxrwx 1 root root 23 Jan 29 2019 libcurl-gnutls.so.4 -> libcurl-gnutls.so.4.5.0 -rw-r--r-- 1 root root 308852 Jan 29 2019 libcurl-gnutls.so.4.5.0 lrwxrwxrwx 1 root root 18 May 5 2014 libdaemon.so.0 -> libdaemon.so.0.5.0 -rw-r--r-- 1 root root 18016 May 5 2014 libdaemon.so.0.5.0 -rw-r--r-- 1 root root 1077452 Apr 25 2018 libdb-5.3.so lrwxrwxrwx 1 root root 25 Jun 8 2016 libdebconfclient.so.0 -> libdebconfclient.so.0.0.0 -rw-r--r-- 1 root root 5540 Jun 8 2016 libdebconfclient.so.0.0.0 -rw-r--r-- 1 root root 256934 Mar 5 17:53 libdl.a -rwxr-xr-x 1 root root 192444 Mar 5 17:53 libdl.so lrwxrwxrwx 1 root root 25 Oct 10 2018 libdns-pkcs11.so.1100 -> libdns-pkcs11.so.1100.1.1 -rw-r--r-- 1 root root 1491248 Oct 10 2018 libdns-pkcs11.so.1100.1.1 lrwxrwxrwx 1 root root 18 Oct 10 2018 libdns.so.1100 -> libdns.so.1100.1.1 -rw-r--r-- 1 root root 1478512 Oct 10 2018 libdns.so.1100.1.1 lrwxrwxrwx 1 root root 17 Jun 19 2017 libedit.so.2 -> libedit.so.2.0.56 -rw-r--r-- 1 root root 125096 Jun 19 2017 libedit.so.2.0.56 -rw-r--r-- 1 root root 71360 Apr 9 2018 libelf-0.170.so lrwxrwxrwx 1 root root 15 Apr 9 2018 libelf.so.1 -> libelf-0.170.so lrwxrwxrwx 1 root root 16 Sep 24 2017 libestr.so.0 -> libestr.so.0.0.0 -rw-r--r-- 1 root root 9612 Sep 24 2017 libestr.so.0.0.0 lrwxrwxrwx 1 root root 18 Dec 19 2017 libexpatw.so.1 -> libexpatw.so.1.6.7 -rw-r--r-- 1 root root 136760 Dec 19 2017 libexpatw.so.1.6.7 lrwxrwxrwx 1 root root 18 Nov 15 2017 libexslt.so.0 -> libexslt.so.0.8.17 -rw-r--r-- 1 root root 58636 Nov 15 2017 libexslt.so.0.8.17 lrwxrwxrwx 1 root root 20 Jan 14 2018 libfastjson.so.4 -> libfastjson.so.4.2.0 -rw-r--r-- 1 root root 26448 Jan 14 2018 libfastjson.so.4.2.0 lrwxrwxrwx 1 root root 15 Jan 7 2018 libffi.so.6 -> libffi.so.6.0.4 -rw-r--r-- 1 root root 22104 Jan 7 2018 libffi.so.6.0.4 lrwxrwxrwx 1 root root 23 Apr 5 2018 libfontconfig.so.1 -> libfontconfig.so.1.10.1 -rw-r--r-- 1 root root 190676 Apr 5 2018 libfontconfig.so.1.10.1 lrwxrwxrwx 1 root root 14 May 23 2018 libform.so.5 -> libform.so.5.9 -rw-r--r-- 1 root root 34680 May 23 2018 libform.so.5.9 lrwxrwxrwx 1 root root 15 May 23 2018 libformw.so.5 -> libformw.so.5.9 -rw-r--r-- 1 root root 38804 May 23 2018 libformw.so.5.9 lrwxrwxrwx 1 root root 21 Apr 12 2018 libfreetype.so.6 -> libfreetype.so.6.15.0 -rw-r--r-- 1 root root 436036 Apr 12 2018 libfreetype.so.6.15.0 lrwxrwxrwx 1 root root 19 Nov 18 2017 libfribidi.so.0 -> libfribidi.so.0.3.6 -rw-r--r-- 1 root root 83356 Nov 18 2017 libfribidi.so.0.3.6 -rw-r--r-- 1 root root 2518 Mar 5 17:53 libg.a lrwxrwxrwx 1 root root 23 Mar 14 2018 libgdbm_compat.so.4 -> libgdbm_compat.so.4.0.0 -rw-r--r-- 1 root root 9480 Mar 14 2018 libgdbm_compat.so.4.0.0 lrwxrwxrwx 1 root root 16 Mar 14 2018 libgdbm.so.5 -> libgdbm.so.5.0.0 -rw-r--r-- 1 root root 34228 Mar 14 2018 libgdbm.so.5.0.0 lrwxrwxrwx 1 root root 14 Aug 23 2018 libgd.so.3 -> libgd.so.3.0.5 -rw-r--r-- 1 root root 292500 Aug 23 2018 libgd.so.3.0.5 lrwxrwxrwx 1 root root 18 Jan 24 2018 libGeoIP.so.1 -> libGeoIP.so.1.6.12 -rw-r--r-- 1 root root 183716 Jan 24 2018 libGeoIP.so.1.6.12 lrwxrwxrwx 1 root root 22 Sep 26 2018 libgio-2.0.so.0 -> libgio-2.0.so.0.5600.3 -rw-r--r-- 1 root root 1038392 Sep 26 2018 libgio-2.0.so.0.5600.3 lrwxrwxrwx 1 root root 28 Apr 15 2018 libgirepository-1.0.so.1 -> libgirepository-1.0.so.1.0.0 -rw-r--r-- 1 root root 137460 Apr 15 2018 libgirepository-1.0.so.1.0.0 lrwxrwxrwx 1 root root 23 Sep 26 2018 libglib-2.0.so.0 -> libglib-2.0.so.0.5600.3 -rw-r--r-- 1 root root 837824 Sep 26 2018 libglib-2.0.so.0.5600.3 lrwxrwxrwx 1 root root 26 Sep 26 2018 libgmodule-2.0.so.0 -> libgmodule-2.0.so.0.5600.3 -rw-r--r-- 1 root root 9512 Sep 26 2018 libgmodule-2.0.so.0.5600.3 lrwxrwxrwx 1 root root 16 Jan 24 2018 libgmp.so.10 -> libgmp.so.10.3.2 -rw-r--r-- 1 root root 292512 Jan 24 2018 libgmp.so.10.3.2 lrwxrwxrwx 1 root root 21 Mar 12 2018 libgnutls.so.30 -> libgnutls.so.30.14.10 -rw-r--r-- 1 root root 977052 Mar 12 2018 libgnutls.so.30.14.10 lrwxrwxrwx 1 root root 26 Sep 26 2018 libgobject-2.0.so.0 -> libgobject-2.0.so.0.5600.3 -rw-r--r-- 1 root root 227496 Sep 26 2018 libgobject-2.0.so.0.5600.3 lrwxrwxrwx 1 root root 21 Jan 11 2019 libgssapi_krb5.so.2 -> libgssapi_krb5.so.2.2 -rw-r--r-- 1 root root 176044 Jan 11 2019 libgssapi_krb5.so.2.2 lrwxrwxrwx 1 root root 18 Dec 14 2017 libgssapi.so.3 -> libgssapi.so.3.0.0 -rw-r--r-- 1 root root 151616 Dec 14 2017 libgssapi.so.3.0.0 lrwxrwxrwx 1 root root 26 Sep 26 2018 libgthread-2.0.so.0 -> libgthread-2.0.so.0.5600.3 -rw-r--r-- 1 root root 5384 Sep 26 2018 libgthread-2.0.so.0.5600.3 lrwxrwxrwx 1 root root 19 Dec 14 2017 libhcrypto.so.4 -> libhcrypto.so.4.1.0 -rw-r--r-- 1 root root 142072 Dec 14 2017 libhcrypto.so.4.1.0 lrwxrwxrwx 1 root root 20 Dec 14 2017 libheimbase.so.1 -> libheimbase.so.1.0.0 -rw-r--r-- 1 root root 34632 Dec 14 2017 libheimbase.so.1.0.0 lrwxrwxrwx 1 root root 20 Dec 14 2017 libheimntlm.so.0 -> libheimntlm.so.0.1.0 -rw-r--r-- 1 root root 22196 Dec 14 2017 libheimntlm.so.0.1.0 lrwxrwxrwx 1 root root 17 Dec 12 2017 libhogweed.so.4 -> libhogweed.so.4.4 -rw-r--r-- 1 root root 161552 Dec 12 2017 libhogweed.so.4.4 lrwxrwxrwx 1 root root 17 Dec 14 2017 libhx509.so.5 -> libhx509.so.5.0.0 -rw-r--r-- 1 root root 175404 Dec 14 2017 libhx509.so.5.0.0 lrwxrwxrwx 1 root root 15 Dec 2 2017 libi2c.so.0 -> libi2c.so.0.1.0 -rw-r--r-- 1 root root 5388 Dec 2 2017 libi2c.so.0.1.0 lrwxrwxrwx 1 root root 18 Mar 22 2018 libicudata.so.60 -> libicudata.so.60.2 -rw-r--r-- 1 root root 26903812 Mar 22 2018 libicudata.so.60.2 lrwxrwxrwx 1 root root 18 Mar 22 2018 libicui18n.so.60 -> libicui18n.so.60.2 -rw-r--r-- 1 root root 1803972 Mar 22 2018 libicui18n.so.60.2 lrwxrwxrwx 1 root root 16 Mar 22 2018 libicuio.so.60 -> libicuio.so.60.2 -rw-r--r-- 1 root root 34212 Mar 22 2018 libicuio.so.60.2 lrwxrwxrwx 1 root root 18 Mar 22 2018 libicutest.so.60 -> libicutest.so.60.2 -rw-r--r-- 1 root root 43092 Mar 22 2018 libicutest.so.60.2 lrwxrwxrwx 1 root root 16 Mar 22 2018 libicutu.so.60 -> libicutu.so.60.2 -rw-r--r-- 1 root root 129148 Mar 22 2018 libicutu.so.60.2 lrwxrwxrwx 1 root root 16 Mar 22 2018 libicuuc.so.60 -> libicuuc.so.60.2 -rw-r--r-- 1 root root 1197500 Mar 22 2018 libicuuc.so.60.2 lrwxrwxrwx 1 root root 16 Mar 4 2018 libidn2.so.0 -> libidn2.so.0.3.3 -rw-r--r-- 1 root root 107840 Mar 4 2018 libidn2.so.0.3.3 -rw-r--r-- 1 root root 2516 Mar 5 17:53 libieee.a lrwxrwxrwx 1 root root 17 Nov 11 2017 libip4tc.so.0 -> libip4tc.so.0.1.0 -rw-r--r-- 1 root root 17988 Nov 11 2017 libip4tc.so.0.1.0 lrwxrwxrwx 1 root root 17 Nov 11 2017 libip6tc.so.0 -> libip6tc.so.0.1.0 -rw-r--r-- 1 root root 17988 Nov 11 2017 libip6tc.so.0.1.0 lrwxrwxrwx 1 root root 16 Nov 11 2017 libiptc.so.0 -> libiptc.so.0.0.0 -rw-r--r-- 1 root root 5336 Nov 11 2017 libiptc.so.0.0.0 lrwxrwxrwx 1 root root 19 Oct 10 2018 libisccc.so.160 -> libisccc.so.160.0.2 -rw-r--r-- 1 root root 26148 Oct 10 2018 libisccc.so.160.0.2 lrwxrwxrwx 1 root root 20 Oct 10 2018 libisccfg.so.160 -> libisccfg.so.160.1.2 -rw-r--r-- 1 root root 95892 Oct 10 2018 libisccfg.so.160.1.2 lrwxrwxrwx 1 root root 24 Oct 10 2018 libisc-pkcs11.so.169 -> libisc-pkcs11.so.169.0.1 -rw-r--r-- 1 root root 334484 Oct 10 2018 libisc-pkcs11.so.169.0.1 lrwxrwxrwx 1 root root 17 Oct 10 2018 libisc.so.169 -> libisc.so.169.0.1 -rw-r--r-- 1 root root 338580 Oct 10 2018 libisc.so.169.0.1 -rw-r--r-- 1 root root 41096 Apr 3 2018 libjbig.so.0 lrwxrwxrwx 1 root root 16 Jul 5 2018 libjpeg.so.8 -> libjpeg.so.8.1.2 -rw-r--r-- 1 root root 161784 Jul 5 2018 libjpeg.so.8.1.2 lrwxrwxrwx 1 root root 18 Jan 11 2019 libk5crypto.so.3 -> libk5crypto.so.3.1 -rw-r--r-- 1 root root 149168 Jan 11 2019 libk5crypto.so.3.1 lrwxrwxrwx 1 root root 17 Dec 14 2017 libkrb5.so.26 -> libkrb5.so.26.0.0 -rw-r--r-- 1 root root 331916 Dec 14 2017 libkrb5.so.26.0.0 lrwxrwxrwx 1 root root 14 Jan 11 2019 libkrb5.so.3 -> libkrb5.so.3.3 -rw-r--r-- 1 root root 554136 Jan 11 2019 libkrb5.so.3.3 lrwxrwxrwx 1 root root 21 Jan 11 2019 libkrb5support.so.0 -> libkrb5support.so.0.1 -rw-r--r-- 1 root root 26360 Jan 11 2019 libkrb5support.so.0.1 lrwxrwxrwx 1 root root 17 Sep 3 2016 libksba.so.8 -> libksba.so.8.11.6 -rw-r--r-- 1 root root 144808 Sep 3 2016 libksba.so.8.11.6 lrwxrwxrwx 1 root root 21 Oct 23 2018 liblber-2.4.so.2 -> liblber-2.4.so.2.10.8 -rw-r--r-- 1 root root 34240 Oct 23 2018 liblber-2.4.so.2.10.8 lrwxrwxrwx 1 root root 18 Oct 23 2018 libldap-2.4.so.2 -> libldap_r-2.4.so.2 lrwxrwxrwx 1 root root 23 Oct 23 2018 libldap_r-2.4.so.2 -> libldap_r-2.4.so.2.10.8 -rw-r--r-- 1 root root 202824 Oct 23 2018 libldap_r-2.4.so.2.10.8 lrwxrwxrwx 1 root root 19 Oct 10 2018 liblwres.so.160 -> liblwres.so.160.0.1 -rw-r--r-- 1 root root 50524 Oct 10 2018 liblwres.so.160.0.1 lrwxrwxrwx 1 root root 15 Apr 3 2018 liblz4.so.1 -> liblz4.so.1.7.1 -rw-r--r-- 1 root root 75116 Apr 3 2018 liblz4.so.1.7.1 -rw-r--r-- 1 root root 10364764 Mar 5 17:53 libm.a lrwxrwxrwx 1 root root 17 Jun 13 2018 libmagic.so.1 -> libmagic.so.1.0.0 -rw-r--r-- 1 root root 95716 Jun 13 2018 libmagic.so.1.0.0 -rw-r--r-- 1 root root 8760 Mar 5 17:53 libmcheck.a lrwxrwxrwx 1 root root 14 May 23 2018 libmenu.so.5 -> libmenu.so.5.9 -rw-r--r-- 1 root root 21996 May 23 2018 libmenu.so.5.9 lrwxrwxrwx 1 root root 15 May 23 2018 libmenuw.so.5 -> libmenuw.so.5.9 -rw-r--r-- 1 root root 21996 May 23 2018 libmenuw.so.5.9 lrwxrwxrwx 1 root root 17 Apr 23 2018 libmpdec.so.2 -> libmpdec.so.2.4.2 -rw-r--r-- 1 root root 120520 Apr 23 2018 libmpdec.so.2.4.2 -rwxr-xr-x 1 root root 5948304 Mar 5 17:53 libm.so lrwxrwxrwx 1 root root 31 Oct 11 2016 libnetfilter_conntrack.so.3 -> libnetfilter_conntrack.so.3.6.0 -rw-r--r-- 1 root root 66988 Oct 11 2016 libnetfilter_conntrack.so.3.6.0 lrwxrwxrwx 1 root root 16 Dec 12 2017 libnettle.so.6 -> libnettle.so.6.4 -rw-r--r-- 1 root root 173672 Dec 12 2017 libnettle.so.6.4 lrwxrwxrwx 1 root root 21 Apr 26 2014 libnfnetlink.so.0 -> libnfnetlink.so.0.2.0 -rw-r--r-- 1 root root 17452 Apr 26 2014 libnfnetlink.so.0.2.0 lrwxrwxrwx 1 root root 21 Apr 10 2018 libnghttp2.so.14 -> libnghttp2.so.14.15.2 -rw-r--r-- 1 root root 95692 Apr 10 2018 libnghttp2.so.14.15.2 lrwxrwxrwx 1 root root 25 Jun 2 2017 libnl-route-3.so.200 -> libnl-route-3.so.200.24.0 -rw-r--r-- 1 root root 296652 Jun 2 2017 libnl-route-3.so.200.24.0 lrwxrwxrwx 1 root root 16 Nov 12 2017 libnpth.so.0 -> libnpth.so.0.1.1 -rw-r--r-- 1 root root 9768 Nov 12 2017 libnpth.so.0.1.1 -rw-r--r-- 1 root root 1071058 Mar 5 17:53 libnsl.a -rwxr-xr-x 1 root root 596332 Mar 5 17:53 libnsl.so -rwxr-xr-x 1 root root 148960 Mar 5 17:53 libnss_compat.so -rwxr-xr-x 1 root root 267344 Mar 5 17:53 libnss_db.so -rwxr-xr-x 1 root root 103360 Mar 5 17:53 libnss_dns.so -rwxr-xr-x 1 root root 325228 Mar 5 17:53 libnss_files.so -rwxr-xr-x 1 root root 105924 Mar 5 17:53 libnss_hesiod.so -rwxr-xr-x 1 root root 396196 Mar 5 17:53 libnss_nisplus.so -rwxr-xr-x 1 root root 336904 Mar 5 17:53 libnss_nis.so lrwxrwxrwx 1 root root 19 Oct 14 2017 libp11-kit.so.0 -> libp11-kit.so.0.3.0 -rw-r--r-- 1 root root 725644 Oct 14 2017 libp11-kit.so.0.3.0 lrwxrwxrwx 1 root root 15 May 23 2018 libpanel.so.5 -> libpanel.so.5.9 -rw-r--r-- 1 root root 9488 May 23 2018 libpanel.so.5.9 lrwxrwxrwx 1 root root 16 May 23 2018 libpanelw.so.5 -> libpanelw.so.5.9 -rw-r--r-- 1 root root 9488 May 23 2018 libpanelw.so.5.9 lrwxrwxrwx 1 root root 22 Feb 3 2018 libpcreposix.so.3 -> libpcreposix.so.3.13.3 -rw-r--r-- 1 root root 5412 Feb 3 2018 libpcreposix.so.3.13.3 lrwxrwxrwx 1 root root 20 Dec 19 2017 libpcsclite.so.1 -> libpcsclite.so.1.0.0 -rw-r--r-- 1 root root 25936 Dec 19 2017 libpcsclite.so.1.0.0 lrwxrwxrwx 1 root root 17 Nov 19 2018 libperl.so.5.26 -> libperl.so.5.26.1 -rw-r--r-- 1 root root 1399012 Nov 19 2018 libperl.so.5.26.1 lrwxrwxrwx 1 root root 20 Nov 14 2017 libpipeline.so.1 -> libpipeline.so.1.5.0 -rw-r--r-- 1 root root 34112 Nov 14 2017 libpipeline.so.1.5.0 lrwxrwxrwx 1 root root 19 Jul 10 2018 libpng16.so.16 -> libpng16.so.16.34.0 -rw-r--r-- 1 root root 128316 Jul 10 2018 libpng16.so.16.34.0 lrwxrwxrwx 1 root root 16 Mar 27 2018 libpopt.so.0 -> libpopt.so.0.0.0 -rw-r--r-- 1 root root 34468 Mar 27 2018 libpopt.so.0.0.0 lrwxrwxrwx 1 root root 15 Mar 4 2018 libpsl.so.5 -> libpsl.so.5.2.0 -rw-r--r-- 1 root root 50440 Mar 4 2018 libpsl.so.5.2.0 -rw-r--r-- 1 root root 4190526 Mar 5 17:53 libpthread.a -rw-r--r-- 1 root root 20992 Mar 5 17:53 libpthread_nonshared.a -rw-r--r-- 1 root root 221 Mar 5 17:53 libpthread.so -rw-r--r-- 1 root root 504864 Mar 5 17:53 libresolv.a -rwxr-xr-x 1 root root 359708 Mar 5 17:53 libresolv.so lrwxrwxrwx 1 root root 18 Dec 14 2017 libroken.so.18 -> libroken.so.18.1.0 -rw-r--r-- 1 root root 50960 Dec 14 2017 libroken.so.18.1.0 -rw-r--r-- 1 root root 341550 Mar 5 17:53 librpcsvc.a -rw-r--r-- 1 root root 637976 Mar 5 17:53 librt.a -rw-r--r-- 1 root root 79724 Apr 27 2016 librtmp.so.1 -rwxr-xr-x 1 root root 368572 Mar 5 17:53 librt.so lrwxrwxrwx 1 root root 18 Feb 5 2018 libsasl2.so.2 -> libsasl2.so.2.0.25 -rw-r--r-- 1 root root 67396 Feb 5 2018 libsasl2.so.2.0.25 -rw-r--r-- 1 root root 159420 Mar 1 2018 libsemanage.so.1 lrwxrwxrwx 1 root root 19 Jan 22 2018 libsqlite3.so.0 -> libsqlite3.so.0.8.6 -rw-r--r-- 1 root root 648632 Jan 22 2018 libsqlite3.so.0.8.6 -rw-r--r-- 1 root root 242636 Dec 4 2018 libssl.so.1.0.0 -rw-r--r-- 1 root root 249624 Dec 5 2018 libssl.so.1.1 lrwxrwxrwx 1 root root 19 Jul 28 2018 libstdc++.so.6 -> libstdc++.so.6.0.25 -rw-r--r-- 1 root root 1052548 Jul 28 2018 libstdc++.so.6.0.25 lrwxrwxrwx 1 root root 17 Jan 21 2018 libtasn1.so.6 -> libtasn1.so.6.5.5 -rw-r--r-- 1 root root 46508 Jan 21 2018 libtasn1.so.6.5.5 -rwxr-xr-x 1 root root 538504 Mar 5 17:53 libthread_db.so lrwxrwxrwx 1 root root 13 May 23 2018 libtic.so.5 -> libtic.so.5.9 -rw-r--r-- 1 root root 42356 May 23 2018 libtic.so.5.9 lrwxrwxrwx 1 root root 16 Jan 17 2019 libtiff.so.5 -> libtiff.so.5.3.0 -rw-r--r-- 1 root root 353952 Jan 17 2019 libtiff.so.5.3.0 lrwxrwxrwx 1 root root 21 Mar 3 2018 libunistring.so.2 -> libunistring.so.2.1.0 -rw-r--r-- 1 root root 1418596 Mar 3 2018 libunistring.so.2.1.0 -rw-r--r-- 1 root root 50516 Mar 5 17:53 libutil.a -rwxr-xr-x 1 root root 38428 Mar 5 17:53 libutil.so lrwxrwxrwx 1 root root 16 Mar 1 2018 libwebp.so.6 -> libwebp.so.6.0.2 -rw-r--r-- 1 root root 252044 Mar 1 2018 libwebp.so.6.0.2 lrwxrwxrwx 1 root root 16 Dec 14 2017 libwind.so.0 -> libwind.so.0.0.0 -rw-r--r-- 1 root root 161140 Dec 14 2017 libwind.so.0.0.0 lrwxrwxrwx 1 root root 15 Aug 29 2018 libX11.so.6 -> libX11.so.6.3.0 -rw-r--r-- 1 root root 918148 Aug 29 2018 libX11.so.6.3.0 lrwxrwxrwx 1 root root 15 Jun 15 2013 libXau.so.6 -> libXau.so.6.0.0 -rw-r--r-- 1 root root 9640 Jun 15 2013 libXau.so.6.0.0 lrwxrwxrwx 1 root root 15 Mar 7 2018 libxcb.so.1 -> libxcb.so.1.1.0 -rw-r--r-- 1 root root 95828 Mar 7 2018 libxcb.so.1.1.0 lrwxrwxrwx 1 root root 17 Mar 2 2017 libXdmcp.so.6 -> libXdmcp.so.6.0.0 -rw-r--r-- 1 root root 13704 Mar 2 2017 libXdmcp.so.6.0.0 lrwxrwxrwx 1 root root 16 Aug 10 2018 libxml2.so.2 -> libxml2.so.2.9.4 -rw-r--r-- 1 root root 1118204 Aug 10 2018 libxml2.so.2.9.4 lrwxrwxrwx 1 root root 16 Dec 22 2016 libXpm.so.4 -> libXpm.so.4.11.0 -rw-r--r-- 1 root root 42748 Dec 22 2016 libXpm.so.4.11.0 lrwxrwxrwx 1 root root 17 Nov 15 2017 libxslt.so.1 -> libxslt.so.1.1.29 -rw-r--r-- 1 root root 165336 Nov 15 2017 libxslt.so.1.1.29 lrwxrwxrwx 1 root root 20 Nov 11 2017 libxtables.so.12 -> libxtables.so.12.0.0 -rw-r--r-- 1 root root 34164 Nov 11 2017 libxtables.so.12.0.0 lrwxrwxrwx 1 root root 18 Jul 10 2017 libyaml-0.so.2 -> libyaml-0.so.2.0.5 -rw-r--r-- 1 root root 75220 Jul 10 2017 libyaml-0.so.2.0.5 lrwxrwxrwx 1 root root 16 Mar 12 2018 libzstd.so.1 -> libzstd.so.1.3.3 -rw-r--r-- 1 root root 316788 Mar 12 2018 libzstd.so.1.3.3 -rw-r--r-- 1 root root 1228 Mar 5 17:53 Mcrt1.o drwxr-xr-x 3 root root 4096 Feb 16 2019 openssl-1.0.0 drwxr-xr-x 5 root root 4096 Feb 16 2019 perl drwxr-xr-x 3 root root 4096 Feb 16 2019 perl5 drwxr-xr-x 16 root root 4096 Feb 16 2019 perl-base drwxr-xr-x 2 root root 4096 Feb 16 2019 rsyslog drwxr-xr-x 2 root root 4096 Feb 16 2019 sasl2 -rw-r--r-- 1 root root 3724 Mar 5 17:53 Scrt1.o drwxr-xr-x 2 root root 4096 Feb 16 2019 xtables

paholden commented 4 years ago

Adding CMakeFiles.txt and Pro3_toolchain.cmake files for review.

cmakefiles.tar.gz

paholden commented 4 years ago

Follow up:

I had to do two things to get libiio to finally build: 1) I had to put the /usr/lib/arm-linux-gnueabihf/libc_nonshared.a and /usr/lib/arm-linux-gnueabihf/libpthread* into the CMAKE_SYSROOT/usr/lib directory and 2) Add "add_definitions("--sysroot=${CMAKE_SYSROOT}")" and --sysroot to both C and CXX flags definitions.

The final toolchain file is here for anyone who needs to do cross-compilation for arm-linux-gnueabihf. toolchain.tar.gz

rgetz commented 4 years ago

Sorry - I will try to improve the cross compile instructions.

Since pthreads is provided by glibc, and it's on every host, we don't call it out specifically... The same for uClibc - it should just be there... https://packages.debian.org/sid/i386/libc6-dev/filelist

It, and other libraries need to be in the SYSROOT folder for things to work.

For example - if it can't find libusb, you won't get USB support; if it doesn't find libserial, you don't get serial support. If it can't find fcntl.h (also part of glibc) in your headers - you won't get networking.

The optional ones we call out in the build instructions, the others, we don't (since they aren't optional on a properly built system.

paholden commented 4 years ago

I got past the others (libusb et al), but now I'm back to square 1 due to my new image won't even boot. I get a kernel crash during initialization from one of the new libraries!

I can keep posting things I find here for you to improve the cross-compile documentation & for others who have to do cross-compile of libiio.

paholden commented 4 years ago

Now I'm seeing the following errors, the thing that is most perplexing is that the libusb.h is in the CMAKE_SYSROOT/usr/include AND "libusb_get_version" is clearly in the libusb.h file. Also quite perplexing is that libpthread.so.0 is clearly in CMAKE_SYSROOT/usr/lib AND CMAKE_SYSROOT/usr/lib/arm-linux-gnueabihf directories.

CMAKE_SYSROOT: /home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16 -- Looking for strdup - not found -- Looking for strerror_r CMAKE_SYSROOT: /home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16 -- Looking for strerror_r - not found -- Looking for newlocale CMAKE_SYSROOT: /home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16 -- Looking for newlocale - not found -- Looking for in6addr_any CMAKE_SYSROOT: /home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16 -- Looking for in6addr_any - not found CMake Warning at CMakeLists.txt:112 (message): IPv6 is not available in your system.

-- Found Git: /usr/bin/git (found version "2.17.1") -- Looking for libusb-1.0 : Found -- Looking for libusb_get_version CMAKE_SYSROOT: /home/patricaholden/williamson/testbuild/Pro3-Linux/packages/IIO_Utils/libiio/../../../ubuntu-18.04.2-minimal-armhf-2019-02-16 -- Looking for libusb_get_version - not found -- Building with Network back end support -- Performing Test HAS_O_TMPFILE

$ grep libusb_get_version ubuntu-18.04.2-minimal-armhf-2019-02-16/usr/include/libusb-1.0/libusb.h

const struct libusb_version * LIBUSB_CALL libusb_get_version(void);

$ ls ubuntu-18.04.2-minimal-armhf-2019-02-16/usr/lib/arm-linux-gnueabihf/libpthread*

ubuntu-18.04.2-minimal-armhf-2019-02-16/usr/lib/arm-linux-gnueabihf/libpthread-2.23.so ubuntu-18.04.2-minimal-armhf-2019-02-16/usr/lib/arm-linux-gnueabihf/libpthread.so.0

rgetz commented 4 years ago

Have a look how we include this in buildroot.

Most cross environments handle all these things for you.

For example - debian - we build on all but powerpcspe - this would include ARM. https://packages.debian.org/sid/libiio0

We also build ARM binaries for Raspberry Pi every release on Travis-CI. You can check that out to see how it works.

-Robin

paholden commented 4 years ago

Do you have the source available for the Raspberry PI? It's similar to what I'm working on. The development board I am currently working with is based on AM5728, it's on of TI Sitara family. I've used buildroot in the past, seems a bit cumbersome for what I'm doing. I looked at crosstool-ng too. Unfortunately, TI only uses scripts so that's predominantly why I continued with that approach. I'm slogging my way through it!

rgetz commented 4 years ago

For ARM, we set up a QEMU system, so we can run ARM binaries on x86, and then chroot to that.

Here is the setup: https://github.com/analogdevicesinc/libiio/blob/master/CI/travis/setup_qemu_for_arm.sh

Here is the build: https://github.com/analogdevicesinc/libiio/blob/master/CI/travis/make_linux_qemu

paholden commented 4 years ago

Thanks, I actually found the X15 has a Buildroot config so I am heading down that path to see if I can get an SD card to boot using Buildroot. As you pointed out, Buildroot has the option for Libiio so I am trying this out. Thanks for the links, I will take a look at that too. I need to find a good solution that I can provide to the client for reproducing the image in manufacturing.

paholden commented 4 years ago

Buildroot turned out to be the best path. I got it going with our u-boot & kernel, libiio was installed, the daemon came up, iio_info worked just fine. I think we're done here.

paholden commented 4 years ago

Thanks for all your assistance!