LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   arm-linux-gcc linker problem with libmodbus (https://www.linuxquestions.org/questions/linux-software-2/arm-linux-gcc-linker-problem-with-libmodbus-721354/)

meda75 04-24-2009 03:41 AM

arm-linux-gcc linker problem with libmodbus
 
Hi everyone . I have problem with arm-linux-gcc crosstool . I have download and install libmodbus library for modicon Modbus protocol . And with gcc that library works just fine . But when I try to use arm-linux-gcc instead he sends me error . this is command for compiling

$arm-linux-gcc -I/usr/local/include my_app.c -lmodbus (/usr/local/include is where actualy is modbus.h) and error is
/arm-linux-gcc/bin/ld: cannot find -lmodbus
collect2:ld returned 1 exit status .

Remark : When I installed libmodbus, as CC variable I have use CC=gcc in Makefile ( but I had try with CC=arm-linux-gcc also , but without any result )
Thank You in advance :)
Sorry for my poor English

knudfl 04-24-2009 05:46 AM

Try using the 'absolute path' to arm-linux-gcc, when
you configure 'libmodbus' :

CC="arm-linux-gcc -B/<path-to-arm-linux-gcc>/" ./configure
( Adding it, when you do 'make' , does not always work.)

A 'libmodbus' compiled with /usr/bin/gcc cannot be used
to compile anything 'arm'.
All dependencies, libraries etc. to be used with an
'arm' application, arm-linux-gcc, must be compiled for
arm.

.....

ChrisOnLinux 12-20-2013 04:42 AM

this worked for me but I get the following errors now:

...
configure:3154: checking for gcc
configure:3181: result: arm-ssv1-linux-gcc
configure:3410: checking for C compiler version
configure:3419: arm-ssv1-linux-gcc --version >&5
./configure: line 3421: arm-ssv1-linux-gcc: command not found
configure:3430: $? = 127
configure:3419: arm-ssv1-linux-gcc -v >&5
./configure: line 3421: arm-ssv1-linux-gcc: command not found
configure:3430: $? = 127
configure:3419: arm-ssv1-linux-gcc -V >&5
./configure: line 3421: arm-ssv1-linux-gcc: command not found
configure:3430: $? = 127
configure:3419: arm-ssv1-linux-gcc -qversion >&5
./configure: line 3421: arm-ssv1-linux-gcc: command not found
configure:3430: $? = 127
configure:3450: checking whether the C compiler works
configure:3472: arm-ssv1-linux-gcc conftest.c >&5
./configure: line 3474: arm-ssv1-linux-gcc: command not found
configure:3476: $? = 127
configure:3514: result: no
configure: failed program was:
| /* confdefs.h /
| #define PACKAGE_NAME "libmodbus"
| #define PACKAGE_TARNAME "libmodbus"
| #define PACKAGE_VERSION "3.0.5"
| #define PACKAGE_STRING "libmodbus 3.0.5"
| #define PACKAGE_BUGREPORT "https://github.com/stephane/libmodbus/issues"
| #define PACKAGE_URL ""
| #define PACKAGE "libmodbus"
| #define VERSION "3.0.5"
| / end confdefs.h. */
...
configure:3519: error: in `/libmodbus-3.0.5':
configure:3521: error: C compiler cannot create executables

Anyone an idea if and how I can make my compiler work for libmodbus?

nake 12-20-2013 06:40 AM

Quote:

Originally Posted by ChrisOnLinux (Post 5084424)
configure:3154: checking for gcc
configure:3181: result: arm-ssv1-linux-gcc

I thought you said your cross compiler was arm-linux-gcc and not arm-ssv1-linux-gcc

The problem I see is that your library is compiled for your normal gcc (downloaded I suppose) and not the cross-compiler one, so you will have to recompile it with the cross-compiler. Make sure you specify what gcc to use when compiling (usuarlly an option when calling ./configure).
Also, in your first post you specified where to find the header (.h) files, but not the libraries. Thats done with -L/path/to/lib

So recompile that library and specify to gcc where to find it :)

ChrisOnLinux 12-20-2013 07:20 AM

Hello nake and thaks for your quick reply.
I think there is a misunderstanding. I am not the same person like "meda75"
and yes I am using the cross compiler arm-ssv1-linux-gcc cause I am trying to get libmodbus running on a IGW/920 from SSV Industrial Communication
http://www.ssv-comm.de/de/produkte/igw920.php

The errors I posted had appeared while running ./configure.
The command I used was:
CC="arm-ssv1-linux-gcc" ./configure

I don't think I need the -B/<path-to-arm-ssv1-linux-gcc> option cause I have that path in my bashrc

nake 12-20-2013 08:19 AM

Quote:

Originally Posted by ChrisOnLinux (Post 5084480)
Hello nake and thaks for your quick reply.
I think there is a misunderstanding. I am not the same person like "meda75"

Whoops. Sorry.

Alright, so could you make sure that the command can be executed outside the ./configure script?
I mean, if you open a console and enter arm-ssv1-linux-gcc --version, does it show any output?
And maybe I'm wrong, but you could try adding the complete path to the variable CC. It seems that somehow the script can't find the cross-compiler.

ChrisOnLinux 01-07-2014 04:26 AM

Quote:

Originally Posted by nake (Post 5084491)
... if you open a console and enter arm-ssv1-linux-gcc --version, does it show any output?

Yes, this works fine. I get the following:
~$ arm-ssv1-linux-gcc --version
arm-ssv1-linux-gcc (GCC) 3.4.4
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Maybe the configure file expects something else e.g. "3.4.4" and nothing else.
I tried it also with the -B option but it doesn't make a difference.
sudo CC="arm-ssv1-linux-gcc -B/usr/local/arm-ssv1-linux/bin/" ./configure
I get the same result.
...
configure:3154: checking for gcc
configure:3181: result: arm-ssv1-linux-gcc -B/usr/local/arm-ssv1-linux/bin/
configure:3410: checking for C compiler version
configure:3419: arm-ssv1-linux-gcc -B/usr/local/arm-ssv1-linux/bin/ --version >&5
./configure: line 3421: arm-ssv1-linux-gcc: command not found
configure:3430: $? = 127
...

ChrisOnLinux 01-07-2014 09:16 AM

Looks like it works now. All I had to do was to enter the following command:

./configure --host arm-ssv1-linux


All times are GMT -5. The time now is 10:55 PM.