[etherlab-users] Linker problems with stable-1.5 patched withthe latest rtdm-patch

Graeme Foot GraemeF at touchcut.com
Wed Mar 14 22:44:21 CET 2012


Hi,

The only way I've managed to reproduce "undefined reference to" to the rtdm functions is to:
- not apply the patch; or
- not have --enable-rtdm specified as a configuration option
- not have library -lethercat defined for the linker (though it also misses the non-rt functions)

My libethercat.so file is located in /usr/lib

/usr/realtime/lib contains:
  liblxrt
  librtdm

I don't have an /opt/etherlab directory.


The readelf on my libethercat.so file looks similar (didn't do a diff, just looked for the rtdm functions).


My only other suggestion is check to see if you have multiple libethercat files and see if your app is picking up the wrong one.


Graeme.



-----Original Message-----
From: etherlab-users-bounces at etherlab.org [mailto:etherlab-users-bounces at etherlab.org] On Behalf Of WIEGAND Ralf
Sent: Wednesday, 14 March 2012 04:21
To: Richard Hacker; Graeme Foot
Cc: etherlab-users at etherlab.org
Subject: Re: [etherlab-users] Linker problems with stable-1.5 patched withthe latest rtdm-patch

Thanks for the fast response.

The problem is only with the ecrt_rtdm_*** library-functions and not with other functions, like erct_master_get_slave(..). My ld configuration contains /usr/realtime/lib and /opt/etherlab/lib system wide (etc/ld.so.conf.d/). I used exactly this configuration for older versions of the etherlabmaster patched with rtdm-support.

Could it be a problem with the rpath-entry in the libethercat for the rtdm-library ? 

The attached file contains the output of readelf -a libethercat.so.

Regards,

Ralf Wiegand





Hexagon Metrology GmbH
Siegmund-Hiepe-Str. 2-12
35578 Wetzlar
Deutschland

Phone: +49 6441 207-410
Fax: +49 6441 207-387

E-Mail: Ralf.Wiegand at hexagonmetrology.com 



Hauptgeschäftsführer: Holger Fritze
Geschäftsführer: Per Holmberg - Erik Steinbacher - Arno Seuren
Amtsgericht Wetzlar, HRB 1201



-----Ursprüngliche Nachricht-----
Von: Richard Hacker [mailto:ha at igh-essen.com] 
Gesendet: Dienstag, 13. März 2012 09:25
An: etherlab-users at etherlab.org
Cc: WIEGAND Ralf
Betreff: Re: [etherlab-users] Linker problems with stable-1.5 patched with the latest rtdm-patch

On Monday 12 March 2012 21:39:28 WIEGAND Ralf wrote:
> Hello Graeme,
> 
> first of all, thanks for the great job on the rtdm-patch.
> 
> I am trying to use your latest rtdm-patch for the stable-1.5 on revision
>  2266 and get some problems during linking my own application. There are
>  undefined references to every ecrt_rtdm_*** library function. I use the
>  linker-flags "-L/usr/realtime/lib -L/opt/etherlab/lib" and "-llxrt -lrtdm
>  -lethercat". The patch, compilation and installation of the master runs
>  without any problems. The ld is configured to search libraries under
>  /usr/realtime/lib and /opt/etherlab/lib.
... but libc probably isn't ;)

While you told your linker where to find libetherlab.so (by using 
-L/opt/etherlab/lib), libc (actually libdl.so.2) does not know where to find 
it. If you call ldd on your executable, you should find that libetherlab.so is 
not resolved.

To tell libdl.so.2 where to find the library, you must use the option rpath in 
the linking stage of ld:
ld -o <executable> <objects>.o \
	-L/opt/etherlab/lib -rpath=/opt/etherlab/lib -letherlab
or with gcc:
gcc -o <executable> <objects>.o \
	-L/opt/etherlab/lib -Wl,-rpath=/opt/etherlab/lib -letherlab

Alternatively you can configure it system wide by adding the line
/opt/etherlab/lib
to /etc/ld.so.conf
or added a file /etc/ld.so.conf.d/ethercat.conf with the directory included. 
Thereafter run ldconfig as root (instead of rebooting, which will also work... 
but we're not using Windows here ;) )

Now calling ldd on your executable should show libetherlab.so being resolved.

>  I also checked the content of the
>  libethercat library with readelf, but all called library-functions are
>  listed in the output. When i try to read out the ELF information with
>  readelf of the ec_rtai_rtdm_example, i get an error that the file isn't an
>  ELF-file.
It is probably statically linked to libethercat.a, although I am not conviced 
thereof.

> 
> My system is debian based (lenny) with kernel 2.6.32.11 and rtai-3.8.1.
> 
> Do you or anybody on the list have any idea to solve the problem or give me
>  a hint ?
> 
> 
> Regards,
> 
> Ralf Wiegand
> 
> 
> Hexagon Metrology GmbH
> Siegmund-Hiepe-Str. 2-12
> 35578 Wetzlar
> Deutschland
> 
> Phone: +49 6441 207-410
> Fax: +49 6441 207-387
> 
> E-Mail: Ralf.Wiegand at hexagonmetrology.com
> 
> 
> 
> Hauptgeschäftsführer: Holger Fritze
> Geschäftsführer: Per Holmberg - Erik Steinbacher - Arno Seuren
> Amtsgericht Wetzlar, HRB 1201
> 
> 
> 
> _______________________________________________
> etherlab-users mailing list
> etherlab-users at etherlab.org
> http://lists.etherlab.org/mailman/listinfo/etherlab-users
> 

Mit freundlichem Gruß

Richard Hacker

-- 
------------------------------------------------------------------------

Richard Hacker M.Sc. 
richard.hacker at igh-essen.com
Tel.: +49 201 / 36014-16

Ingenieurgemeinschaft IgH
Gesellschaft für Ingenieurleistungen mbH
Heinz-Bäcker-Str. 34
D-45356 Essen
Amtsgericht Essen HRB 11500
USt-Id.-Nr.: DE 174 626 722
Geschäftsführung: 
- Dr.-Ing. S. Rotthäuser, 
- Dr.-Ing. T. Finke, 
- Dr.-Ing. W. Hagemeister
Tel.: +49 201 / 360-14-0
http://www.igh-essen.com

------------------------------------------------------------------------



More information about the Etherlab-users mailing list