Skip to contentSkip to conversation

Static library created by recipe arch is not correct #sdk #yocto

DISCUSSION Iurascu Teodor 3 participants 5 messages Dec 7, 2023 – Dec 8, 2023

lore
Share & tools
lore
#0 lore raw

Hello,

I have created a recipe to include the IOBB library in the SDK. Trying to compile a .c file in the SDK environment gives me this error:

$ ${CC} pb-test-inputs.c -liobb
/opt/poky/4.2.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/12.3.0/ld: /opt/poky/4.2.2/sysroots/cortexa8hf-neon-poky-linux-gnueabi/usr/local/lib/libiobb.a: error adding symbols: file format not recognized

Recipe file:

do_compile () {
# You will almost certainly need to add additional arguments here oe_runmake cc=${CC}
}

do_install () {
# This is a guess; additional arguments may be required oe_runmake install locatie=${D}
#rm ${D}/usr/local/lib/libiobb.a
}

Makefile:

libiobb.a : ${ LIB_PATH } BBBiolib.c ${ LIB_PATH } BBBiolib.h BBBiolib_PWMSS.o BBBiolib_McSPI.o BBBiolib_ADCTSC.o i2cfunc.o
${ cc } -c ${ LIB_PATH } BBBiolib.c -o ${ LIB_PATH } BBBiolib.o
ar -rs ${ LIB_PATH } libiobb.a ${ LIB_PATH } BBBiolib.o ${ LIB_PATH } BBBiolib_PWMSS.o ${ LIB_PATH } BBBiolib_McSPI.o ${ LIB_PATH } BBBiolib_ADCTSC.o ${ LIB_PATH } i2cfunc.o

Thank you!

#1 lore raw
Quoted 22 lines · Iurascu Teodor via lists.yoctoproject.org

Hello,

I have created a recipe to include the IOBB library in the SDK. Trying to compile a .c file in the SDK environment gives me this error:

$ ${CC} pb-test-inputs.c -liobb 
/opt/poky/4.2.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/12.3.0/ld: /opt/poky/4.2.2/sysroots/cortexa8hf-neon-poky-linux-gnueabi/usr/local/lib/libiobb.a: error adding symbols: file format not recognized

Recipe file:

do_compile () {
# You will almost certainly need to add additional arguments here oe_runmake cc=${CC}
}

do_install () {
    # This is a guess; additional arguments may be required
    oe_runmake install locatie=${D}
    #rm ${D}/usr/local/lib/libiobb.a
}
Quoted 5 lines

Makefile:

libiobb.a : ${LIB_PATH}BBBiolib.c ${LIB_PATH}BBBiolib.h BBBiolib_PWMSS.o BBBiolib_McSPI.o BBBiolib_ADCTSC.o i2cfunc.o
${cc} -c ${LIB_PATH}BBBiolib.c -o ${LIB_PATH}BBBiolib.o
ar -rs ${LIB_PATH}libiobb.a ${LIB_PATH}BBBiolib.o ${LIB_PATH}BBBiolib_PWMSS.o ${LIB_PATH}BBBiolib_McSPI.o ${LIB_PATH}BBBiolib_ADCTSC.o ${LIB_PATH}i2cfunc.o

That’s not the whole makefile, can you verify that it’s actually using ${CC} and not gcc in every build step?

Run file on the libiobb.a to verify it contains what you expect.

Also install the library to ${D}${libdir}, /usr/local/ is for non-managed files and by writing a recipe it’s managed.

I also note that iobb is long-dead so there might be a better alternative now.

Ross

#2 lore raw

Re: Static library created by recipe arch is not correct #yocto #sdk

Thanks for the reply Ross!

This is the whole Makefile:

LIB_PATH = ./BBBio_lib/
DEMO_PATH = ./Demo/
TOOLKIT_PATH = ./Toolkit/
LAB_PATH = ./Lab/

LIBRARIES = iobb

cc ="gcc"

all : libiobb.a LED ADT7301 SEVEN_SCAN SMOTOR LED_GPIO DEBOUNCING 4x4keypad ADC ADC_VOICE GPIO_STATUS EP_STATUS ADC_CALC lcd3-test test-outputs pb-test-outputs test-inputs pb-test-inputs

libiobb.a : ${ LIB_PATH } BBBiolib.c ${ LIB_PATH } BBBiolib.h BBBiolib_PWMSS.o BBBiolib_McSPI.o BBBiolib_ADCTSC.o i2cfunc.o
${ cc } -c ${ LIB_PATH } BBBiolib.c -o ${ LIB_PATH } BBBiolib.o
ar -rs ${ LIB_PATH } libiobb.a ${ LIB_PATH } BBBiolib.o ${ LIB_PATH } BBBiolib_PWMSS.o ${ LIB_PATH } BBBiolib_McSPI.o ${ LIB_PATH } BBBiolib_ADCTSC.o ${ LIB_PATH } i2cfunc.o cp ${ LIB_PATH } libiobb.a ./
cp ${ LIB_PATH } BBBiolib.h ./iobb.h
cp ${ LIB_PATH } BBBiolib_ADCTSC.h ./
cp ${ LIB_PATH } BBBiolib_McSPI.h ./
cp ${ LIB_PATH } BBBiolib_PWMSS.h ./
cp ${ LIB_PATH } i2cfunc.h ./

BBBiolib_PWMSS.o : ${ LIB_PATH } BBBiolib_PWMSS.c ${ LIB_PATH } BBBiolib_PWMSS.h ${ cc } -c ${ LIB_PATH } BBBiolib_PWMSS.c -o ${ LIB_PATH } BBBiolib_PWMSS.o -W

BBBiolib_McSPI.o : ${ LIB_PATH } BBBiolib_McSPI.c ${ LIB_PATH } BBBiolib_PWMSS.h ${ cc } -c ${ LIB_PATH } BBBiolib_McSPI.c -o ${ LIB_PATH } BBBiolib_McSPI.o -W

BBBiolib_ADCTSC.o : ${ LIB_PATH } BBBiolib_ADCTSC.c ${ LIB_PATH } BBBiolib_ADCTSC.h ${ cc } -c ${ LIB_PATH } BBBiolib_ADCTSC.c -o ${ LIB_PATH } BBBiolib_ADCTSC.o -W

i2cfunc.o : ${ LIB_PATH } i2cfunc.c ${ LIB_PATH } i2cfunc.h ${ cc } -c ${ LIB_PATH } i2cfunc.c -o ${ LIB_PATH } i2cfunc.o

install :
ifndef locatie
$( info locatie is [${ locatie }])
rm -f /usr/local/include/BBBiolib.h
cp ${ LIB_PATH } libiobb.a /usr/local/lib
cp ${ LIB_PATH } BBBiolib.h /usr/local/include/iobb.h
cp ${ LIB_PATH } BBBiolib_ADCTSC.h /usr/local/include
cp ${ LIB_PATH } BBBiolib_McSPI.h /usr/local/include
cp ${ LIB_PATH } BBBiolib_PWMSS.h /usr/local/include
cp ${ LIB_PATH } i2cfunc.h /usr/local/include
ln -s /usr/local/include/iobb.h /usr/local/include/BBBiolib.h
else
$( info locatie is [${ locatie }])
rm -f $( locatie ) /usr/local/include/BBBiolib.h
mkdir -p $( locatie ) /usr/local/lib
mkdir -p $( locatie ) /usr/local/include
cp ${ LIB_PATH } libiobb.a $( locatie ) /usr/local/lib
cp ${ LIB_PATH } BBBiolib.h $( locatie ) /usr/local/include/iobb.h
cp ${ LIB_PATH } BBBiolib_ADCTSC.h $( locatie ) /usr/local/include
cp ${ LIB_PATH } BBBiolib_McSPI.h $( locatie ) /usr/local/include
cp ${ LIB_PATH } BBBiolib_PWMSS.h $( locatie ) /usr/local/include
cp ${ LIB_PATH } i2cfunc.h $( locatie ) /usr/local/include
cp $( locatie ) /usr/local/include/iobb.h $( locatie ) /usr/local/include/BBBiolib.h endif

#---------------------------------------------------
# Demo
#---------------------------------------------------

test-outputs : test-io/test-outputs.c libiobb.a
${ cc } -o test-outputs test-io/test-outputs.c -I. -L. -liobb

pb-test-outputs : test-io/pb-test-outputs.c libiobb.a
${ cc } -o pb-test-outputs test-io/pb-test-outputs.c -I. -L. -liobb

test-inputs : test-io/test-inputs.c libiobb.a
${ cc } -o test-inputs test-io/test-inputs.c -I. -L. -liobb

pb-test-inputs : test-io/pb-test-inputs.c libiobb.a
${ cc } -o pb-test-inputs test-io/pb-test-inputs.c -I. -L. -liobb

LED : ${ DEMO_PATH } Demo_LED/LED.c libiobb.a
${ cc } -o LED ${ DEMO_PATH } Demo_LED/LED.c -L ${ LIB_PATH } -liobb

lcd3-test : ${ DEMO_PATH } Demo_I2C/lcd3-test.c libiobb.a
${ cc } -o lcd3-test ${ DEMO_PATH } Demo_I2C/lcd3-test.c -I. -L ${ LIB_PATH } -liobb

ADT7301 : ${ DEMO_PATH } Demo_ADT7301/ADT7301.c libiobb.a
${ cc } -o ADT7301 ${ DEMO_PATH } Demo_ADT7301/ADT7301.c -L ${ LIB_PATH } -liobb

ADXL345 : ${ DEMO_PATH } Demo_ADXL345/ADXL345.c libiobb.a
${ cc } -o ADXL345 ${ DEMO_PATH } Demo_ADXL345/ADXL345.c -L ${ LIB_PATH } -liobb ADXL345_NET : ${ DEMO_PATH } Demo_ADXL345/ADXL345_net.c libiobb.a
${ cc } -o ADXL345 ${ DEMO_PATH } Demo_ADXL345/ADXL345_net.c -L ${ LIB_PATH } -liobb

L3G4200D : ${ DEMO_PATH } Demo_L3G4200D/L3G4200D.c libiobb.a
${ cc } -o L3G4200D ${ DEMO_PATH } Demo_L3G4200D/L3G4200D.c -L ${ LIB_PATH } -liobb

SEVEN_SCAN : ${ DEMO_PATH } Demo_SevenScan/SevenScan.c libiobb.a
${ cc } -o SevenScan ${ DEMO_PATH } Demo_SevenScan/SevenScan.c -L ${ LIB_PATH } -liobb

SMOTOR : ${ DEMO_PATH } Demo_ServoMotor/ServoMotor.c libiobb.a
${ cc } -o SMOTOR ${ DEMO_PATH } Demo_ServoMotor/ServoMotor.c -L ${ LIB_PATH } -liobb

LED_GPIO : ${ DEMO_PATH } Demo_LED_GPIO/LED_GPIO.c libiobb.a
${ cc } -o LED_GPIO ${ DEMO_PATH } Demo_LED_GPIO/LED_GPIO.c -L ${ LIB_PATH } -liobb -pthread

DEBOUNCING : ${ DEMO_PATH } Demo_Debouncing/Debouncing.c libiobb.a
${ cc } -o Debouncing ${ DEMO_PATH } Demo_Debouncing/Debouncing.c -L ${ LIB_PATH } -liobb

4x4keypad : ${ DEMO_PATH } Demo_4x4keypad/4x4keypad.c libiobb.a
${ cc } -o 4x4keypad ${ DEMO_PATH } Demo_4x4keypad/4x4keypad.c -L ${ LIB_PATH } -liobb

PWM : ${ DEMO_PATH } Demo_PWM/PWM.c libiobb.a
${ cc } -o PWM ${ DEMO_PATH } Demo_PWM/PWM.c -L ${ LIB_PATH } -liobb

ADC : ${ DEMO_PATH } Demo_ADC/ADC.c libiobb.a
${ cc } -o ADC ${ DEMO_PATH } Demo_ADC/ADC.c -L ${ LIB_PATH } -liobb -lm

ADC_VOICE : ${ DEMO_PATH } Demo_ADC/ADC_voice.c libiobb.a
${ cc } -o ADC_VOICE ${ DEMO_PATH } Demo_ADC/ADC_voice.c -L ${ LIB_PATH } -liobb -lm -pthread -O3

#---------------------------------------------------

# toolkit
#---------------------------------------------------

GPIO_STATUS : ${ TOOLKIT_PATH } Toolkit_GPIO_CLK_Status/GPIO_status.c libiobb.a
${ cc } -o GPIO_CLK_status ${ TOOLKIT_PATH } Toolkit_GPIO_CLK_Status/GPIO_status.c -L ${ LIB_PATH } -liobb

EP_STATUS : ${ TOOLKIT_PATH } Toolkit_EP_Status/EP_status.c libiobb.a
${ cc } -o EP_status ${ TOOLKIT_PATH } Toolkit_EP_Status/EP_status.c -L ${ LIB_PATH } -liobb

ADC_CALC : ${ TOOLKIT_PATH } Toolkit_ADC_CALC/ADC_CALC.c ${ cc } -o ADC_CALC ${ TOOLKIT_PATH } Toolkit_ADC_CALC/ADC_CALC.c

#---------------------------------------------------
# Lab
#---------------------------------------------------

RA : ${ LAB_PATH } Lab_Robot_Arm/Robot_Arm.c libiobb.a
${ cc } -o RA ${ LAB_PATH } Lab_Robot_Arm/Robot_Arm.c -L ${ LIB_PATH } -liobb -lm

VD : ${ LAB_PATH } Voice_Door/voice_door.cpp libiobb.a
g++ -o VD ${ LAB_PATH } Voice_Door/voice_door.cpp -L ${ LIB_PATH } -liobb -lfftw3 -lm -pthread -O3

.PHONY : clean
clean :
rm -rf ${ LIB_PATH } *.o ${ LIB_PATH } libiobb.a libiobb.a iobb.h BBBiolib_ADCTSC.h BBBiolib_McSPI.h i2cfunc.h lcd3-test test-inputs pb-test-inputs test-outputs pb-test-outputs BBBiolib_PWMSS.h LED ADT7301 GPIO_CLK_status SevenScan Ultrasonic28015 TMP SMOTOR LED_GPIO Debouncing 4x4keypad EP_status PWM RA ADXL345 ADC ADC_CALC L3G4200D

It looks like cc is used everywhere.

Running file on libiobb.a returns:

$ file libiobb.a
libiobb.a: current ar archive I'm not sure what the correct output should be. Running file on any object files in the archive returns:
$ file BBBiolib.o
BBBiolib.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped

Thanks for the heads up about IOBB being dead, I'll search for an alternative, after I get this working, if it doesn't meet my needs.

Thank you!

PS: Sorry for the mishap, the forum sets the sender to Private instead of to Group

#3 lore raw

Re: [yocto] Static library created by recipe arch is not correct #yocto #sdk

Quoted 3 lines · Iurascu Teodor via lists.yoctoproject.org

Running file on any object files in the archive returns:

$ file BBBiolib.o  
BBBiolib.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped

Well that’s not right. :)

I note that your makefile doesn’t have any clean functionalty, so it’s entirely possible that it’s reusing previous binaries from when cc wasn’t set correctly. Adding a ‘clean’ target that deletes all built files from the build tree would be a good idea.

You can test this theory by doing bitbake -C unpack bbio (assuming your recipe is called bbio) to force it to rebuild the recipe, and then rebuilding your SDK.

Also have a look at the log.do_compile in the recipe build directory to check it actually is using the arm cross compiler.

I’ll note that Makefiles are hard and if you’re writing your own makefile it’s good to use something else instead.

Ross

#4 lore raw
In reply to Iurascu Teodor

Can you run file command on libiobb.a it seems its not built for either correct architecture or is corrupted in SDK somehow.

It will be good to use AR/RANLIB/CC/CXX variables in your Makefile and weakly assign them e.g.

CC ?= cc

AR ?= ar

...

Quoted 42 lines · Iurascu Teodor

Hello,

I have created a recipe to include the IOBB library in the SDK. Trying to compile a .c file in the SDK environment gives me this error:

$ ${CC} pb-test-inputs.c -liobb
/opt/poky/4.2.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/12.3.0/ld: /opt/poky/4.2.2/sysroots/cortexa8hf-neon-poky-linux-gnueabi/usr/local/lib/libiobb.a: error adding symbols: file format not recognized

Recipe file:

do_compile () {
    # You will almost certainly need to add additional arguments here oe_runmake cc=${CC}
}

do_install () {
    # This is a guess; additional arguments may be required oe_runmake install locatie=${D}
    #rm ${D}/usr/local/lib/libiobb.a
}

Makefile:

libiobb.a: ${LIB_PATH}BBBiolib.c ${LIB_PATH}BBBiolib.h BBBiolib_PWMSS.o BBBiolib_McSPI.o BBBiolib_ADCTSC.o i2cfunc.o
${cc}-c ${LIB_PATH}BBBiolib.c -o ${LIB_PATH}BBBiolib.o
ar -rs ${LIB_PATH}libiobb.a ${LIB_PATH}BBBiolib.o ${LIB_PATH}BBBiolib_PWMSS.o ${LIB_PATH}BBBiolib_McSPI.o ${LIB_PATH}BBBiolib_ADCTSC.o ${LIB_PATH}i2cfunc.o

Thank you!

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
You automatically follow any topics you start or reply to. View/Reply Online (#61828):https://lists.yoctoproject.org/g/yocto/message/61828 Mute This Topic:https://lists.yoctoproject.org/mt/103032949/1997914 Mute #yocto:https://lists.yoctoproject.org/g/yocto/mutehashtag/yocto Mute #sdk:https://lists.yoctoproject.org/g/yocto/mutehashtag/sdk Group Owner:[email protected] Unsubscribe:https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-