AnsweredAssumed Answered

Cross compilation ad9361-iiostream.c lib file question

Question asked by hiolan on Dec 3, 2017
Latest reply on Apr 17, 2018 by come0088@qq.com

I want myself to use the libiio library for ad9361 development 。Compiling IIO lib with cmake, The contents of the cmake file are as follows :

#this one is importane
SET(CMAKE_SYSTEM_NAME Linux)

#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)

#specify the cross compiler
SET(CMAKE_C_COMPILER /opt/pkg/petalinux-v2015.4-final/tools/linux-i386/arm-xilinx-linux-gnueabi/bin/arm-xilinx-linux-gnueabi-gcc)
SET(CMAKE_CXX_COMPILER /opt/pkg/petalinux-v2015.4-final/tools/linux-i386/arm-xilinx-linux-gnueabi/bin/arm-xilinx-linux-gnueabi-g++)
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH  /opt/pkg/petalinux-v2015.4-final/tools/linux-i386/arm-xilinx-linux-gnueabi /usr/lib)
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

Separate execution 

                  cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_PATH}/usr/share/buildroot/toolchainfile.cmake

                  make all

                  sudo make install DESTDIR=${TOOLCHAIN_PATH}

Modify the Makefile file below the ad9361 routine as follows :

TARGETS := ad9361-iiostream dummy-iiostream iio-monitor
#CFLAGS = -Wall
CFLAGS = -Wall -I /iiolib/usr/include
LDFLAGS += -liio -L /opt/pkg/petalinux-v2015.4-final/tools/linux-i386/arm-xilinx-linux-gnueabi -L /home/mylibiio/libiio
#UNAME_S := $(shell uname -s)

#ifeq ($(UNAME_S),Darwin)
# CFLAGS += -framework iio
#else
# LDFLAGS += -liio
#endif
#CC=/opt/pkg/petalinux-v2015.4-final/tools/linux-i386/arm-xilinx-linux-gnueabi/bin/arm-xilinx-linux-gnueabi-gcc
CC=arm-xilinx-linux-gnueabi-gcc
#CC=gcc

.PHONY: all clean

all: $(TARGETS)

iio-monitor: iio-monitor.o
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) -lpthread -lncurses -lcdk

ad9361-iiostream : ad9361-iiostream.o
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)

dummy-iiostream : dummy-iiostream.o
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)

clean:
rm -f $(TARGETS) $(TARGETS:%=%.o)

Execution of make ad9361-iiostream error information :

root@ubuntu:/home/mylibiio/libiio/examples# make ad9361-iiostream

arm-xilinx-linux-gnueabi-gcc -o ad9361-iiostream ad9361-iiostream.o -Wall -I /iiolib/usr/include -liio -L /opt/pkg/petalinux-v2015.4-final/tools/linux-i386/arm-xilinx-linux-gnueabi -L /home/mylibiio/libiio

/home/mylibiio/libiio/libiio.so: file not recognized: File format not recognized

collect2: error: ld returned 1 exit status

make: *** [ad9361-iiostream] 错误 1

root@ubuntu:/home/mylibiio/libiio/examples#

 

Ask what it would be like if it was my compiled libiio library and did not successfully generate a library file that was executed under the ARM. Thank you!

Outcomes