I am planning to add a library to my project, however when I try to link the .so file I receive an error

Asked by Esteban Sanchez Canepa

Hello,

I am planning to add a library to my project, I have compiled the library using the GNU and obtained the .so file, however, when I try to link this file to my project I receive the following message:

Hello, I am planning to add a library to my project, however when I link the .a file I receive the following message:

../lplibrary/liblpsolve55.so: file not recognized: File format not recognized

What else should I consider to link this library? Thank you in advance for your help.

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#1

Hi Esteban,

Can you show us the command line you used to create the .so file (especially the line for linking the .so file if you used separate command lines to compile each object file).

Best regards.

Revision history for this message
Esteban Sanchez Canepa (esteban-sanchezcanepa) said :
#2

I created the .so file with the following command:

sh ccc

In the ccc file you can find the following:

:
src='../lp_MDO.c ../shared/commonlib.c ../shared/mmio.c ../shared/myblas.c ../ini.c ../fortify.c ../colamd/colamd.c ../lp_rlp.c ../lp_crash.c ../bfp/bfp_LUSOL/lp_LUSOL.c ../bfp/bfp_LUSOL/LUSOL/lusol.c ../lp_Hash.c ../lp_lib.c ../lp_wlp.c ../lp_matrix.c ../lp_mipbb.c ../lp_MPS.c ../lp_params.c ../lp_presolve.c ../lp_price.c ../lp_pricePSE.c ../lp_report.c ../lp_scale.c ../lp_simplex.c ../lp_SOS.c ../lp_utils.c ../yacc_read.c'
c=cc

#determine platform (32/64 bit)
>/tmp/platform.c
echo '#include <stdlib.h>'>>/tmp/platform.c
echo '#include <stdio.h>'>>/tmp/platform.c
echo 'main(){printf("ux%d", (int) (sizeof(void *)*8));}'>>/tmp/platform.c
$c /tmp/platform.c -o /tmp/platform
PLATFORM=`/tmp/platform`
rm /tmp/platform /tmp/platform.c >/dev/null 2>&1

mkdir bin bin/$PLATFORM >/dev/null 2>&1

#check if this system has the isnan function
>/tmp/isnan.c
echo '#include <stdio.h>'>>/tmp/isnan.c
echo '#include <stdlib.h>'>>/tmp/isnan.c
echo '#include <math.h>'>>/tmp/isnan.c
echo 'main(){isnan(0);}'>>/tmp/isnan.c
$c /tmp/isnan.c -o /tmp/isnan $math >/dev/null 2>&1
if [ $? = 0 ]
then NOISNAN=
else NOISNAN=-DNOISNAN
fi
rm /tmp/isnan.c /tmp/isnan >/dev/null 2>&1

def=
so=
if [ "$PLATFORM" = "SCO_UNIX" ]
then def='-dy -K PIC -DNOLONGLONG'
     dl=-lc
else dl=-ldl
     so=y
fi

opts='-O3'

$c -s -c -I.. -I../shared -I../bfp -I../bfp/bfp_LUSOL -I../bfp/bfp_LUSOL/LUSOL -I../colamd $opts $def $NOISNAN -DYY_NEVER_INTERACTIVE -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine $src
ar rv bin/$PLATFORM/liblpsolve55.a `echo $src|sed s/[.]c/.o/g|sed 's/[^ ]*\///g'`
ranlib bin/$PLATFORM/liblpsolve55.a

if [ "$so" != "" ]
then
  $c -fpic -s -c -I.. -I../shared -I../bfp -I../bfp/bfp_LUSOL -I../bfp/bfp_LUSOL/LUSOL -I../colamd -I. $opts $NOISNAN -DYY_NEVER_INTERACTIVE -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine $src
  $c -shared -Wl,-Bsymbolic -Wl,-soname,liblpsolve55.so -o bin/$PLATFORM/liblpsolve55.so `echo $src|sed s/[.]c/.o/g|sed 's/[^ ]*\///g'` -lc -lm -ldl
fi

rm *.o 2>/dev/null

After I obtain the .so file I try to use the linker to include it in my project. I am using uvision to build my project with the GNU Arm compiler. Please let me know if you need more information.

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#3

I don't see anything wrong with your command line. Would you mind running "file ../lplibrary/liblpsolve55.so"? I also note you were trying to link the static library but it gives you an error about the dynamic library. What was the command line you used for linking the static library?

Revision history for this message
Esteban Sanchez Canepa (esteban-sanchezcanepa) said :
#4

This is the command that I am using to link the library:
-L ../lplibrary *.o -llpsolve55

I tried to run "file ../lplibrary/libsolve55.so" in the console but I received the following error:

liblpsolve55.so: PE32+ executable (DLL) (console) x86-64, for MS Windows

I am using uvision on windows for this project, I downloaded the GNU Arm compiler and that is the one I am using to compile the project, I think I am missing something for the cross compilation

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#5

Hi Esteban,

Does it make a difference if you invoke you script with cc=arm-none-eabi-gcc? I notice that you compile with $c and c is assigned cc. By default cc will point to your native compiler.

Revision history for this message
Esteban Sanchez Canepa (esteban-sanchezcanepa) said :
#6

Hello Thomas,

I have tried that suggestion, however the linker can't still recognized the file. Is there something that I should consider in the linker script to make it work? Thank you in advance.

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#7

Hi Esteban,

Sorry, my mistake. The script contains c=cc, not c =$cc. So you should change that line in the script to c=arm-none-eabi-gcc. Let us know if this doesn't work.

Best regards.

Can you help with this problem?

Provide an answer of your own, or ask Esteban Sanchez Canepa for more information if necessary.

To post a message you must log in.