libmodbus Linking Issue

2,048 views
Skip to first unread message

Uğur Onursal

unread,
Jan 8, 2014, 2:48:42 AM1/8/14
to libm...@googlegroups.com
Greetings,

I am currently working on a small project to create a modbus server via using libmodbus libraries under Linux.

I should say there is no problem with the usual GCC compilation of the tests or new source files I write.

After testing the library on GCC I needed to transfer it to a Hawkboard for testing it on ARM architecture. Of course, I changed the configuration with;

./configure --host=arm-none-linux-gnueabi

Then reinstalled the libraries,

Now whenever I use my ARM compiler, I get;

/home/ugralitan/CodeSourcery/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lmodbus
collect2: ld returned 1 exit status

I thought compiling the libraries for ARM would be enough, but apparently I need to do something else as well. Can you help me, please?

Julien Blanc

unread,
Jan 8, 2014, 3:21:07 AM1/8/14
to libm...@googlegroups.com
Hi

Most likely, your libmodbus.so file is not found by your linker. You
have a few options :

- copy the libmodbus.so (arm compiled) into the standard link path of
you compiler (should be something like
$HOME/CodeSourcery/arm-none-linux-gnueabi/usr/lib)
- specify the path of the file using -L option

Regards,

Julien

Uğur Onursal

unread,
Jan 8, 2014, 4:07:39 AM1/8/14
to libm...@googlegroups.com
Thank you very much, Julien. Linking by directory worked, definitely.

I am still quite new to Linux and have issues from time to time in simple matters. Though now I have a follow up issue when I send it to Hawkboard via tftp.

After turning my "fserver" file to executable via chmod +x command in Hawkboard, now executing it gives me this error: (monitoring by minicom)

./fserver: error while loading shared libraries: libmodbus.so.5: cannot open shared object file: No such file or directory

Transferring libraries did not help either...or would I require to turn the transferred files into a format before being able to use them?

Regardless, thanks for solving my linking issue.

Best Regards

-Uğur

Julien Blanc

unread,
Jan 8, 2014, 4:47:29 AM1/8/14
to libm...@googlegroups.com
Le 08/01/2014 10:07, Uğur Onursal a écrit :
> Thank you very much, Julien. Linking by directory worked, definitely.
>
> I am still quite new to Linux and have issues from time to time in
> simple matters. Though now I have a follow up issue when I send it to
> Hawkboard via tftp.
>
> After turning my "fserver" file to executable via chmod +x command in
> Hawkboard, now executing it gives me this error: (monitoring by minicom)
>
> ./fserver: error while loading shared libraries: libmodbus.so.5:
> cannot open shared object file: No such file or directory
>
> Transferring libraries did not help either...or would I require to
> turn the transferred files into a format before being able to use them?
>
>
Usually libraries need to be copied to /usr/lib for being available to
programs, putting them in the same directory does not work.

You can run "ldconfig -p |grep modbus" on the board to show available
libraries, and check if libmodbus.so.5 is provided (note the .5, you may
have to run "ldconfig -l" for it to create symlinks after copying
libmodbus.so to /usr/lib).

Regards,

Julien

Uğur Onursal

unread,
Jan 8, 2014, 6:40:43 AM1/8/14
to libm...@googlegroups.com
Thanks again Julien! You have been a great help.

Best Regards

-Uğur
Reply all
Reply to author
Forward
0 new messages