Undefined reference to modbus_connect

Asked by JohnMajor

I am using libmodus 3.0.3 on ubuntu desktop and compiling c++ code using eclispe for an arm base single board computer running ubuntu 13.04.

The compiler is working fine and have installed libmodbus OK and have used it for X86 machine just fine. The problem is when compiling code for arm based machine using the libmodbus library I keep getting errors like "undefined reference to modbus_connect" and other modbus functions.
The modus.h header file is located correctly but for some reason the arm compiler doesn't seem to e linking with the modbus libraries?

Any help in configuring the eclipse environment would be most appreciated

John

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu libmodbus Edit question
Assignee:
No assignee Edit question
Solved by:
JohnMajor
Solved:
Last query:
Last reply:
Revision history for this message
JohnMajor (synenergy) said :
#1

Further to above:
I am using eclipse indigo platform (on a Ubuntu PC) and have used the
libmodbus (libmodbus-3.0.3) library for compilation on X86 c/c++ projects -
these work OK!

I can't get it to work with the "arm-linux-gnueanihf-gcc" compiler I am using.
This arm compiler works fine under normal circumstances but when I use the
libmodus library it throws the following errors:

1. cannot find -lmodbus
2. skipping incompatible /usr/local/lib/libmodbus.so when searching
for -lmodbus

It seems to be finding the libraries in the right place OK but
thinks its incompatible for some reason?
Pretty sure the libraries and include files are located in the right places?
John

Revision history for this message
JohnMajor (synenergy) said :
#2

The problem was found to be due to the compiler not linking correctly with libmodbus library using elclipse running from my X86 based development desktop pc?
Anyway to solve the issue, I installed libmodbus on an arm-based pc running ubuntu/linux and then copied all the libmodbus files from the arm based pc to an special folder on the X86 based development desktop. After setting theh appropriate directory these new files have allow the arm-linux-gnueanihf-gcc compiler to do its job and now accepts the new libmodbus libraries and links OK
John Major