LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot link to shared object created with LabVIEW 2009

Solved!
Go to solution
I am having problems linking to a shared library built from a LabVIEW VI under RHEL 5 with LabVIEW 2009.

In order to demonstrate the problem, I have created a VI with a numeric input and output that squares a number. I then created a project with build specification to create a shared library with one function that makes use of this square VI. The shared object is created successfully (square.so).

When I try to compile a test application written in C that links to this library, I get the following link errors:
cc  -I/usr/local/natinst/nidaqmxbase/include -I/usr/local/natinst/LabVIEW-2009/cintools build/square.so  test.c   -o test
/usr/local/lib/liblvrtdark.so.9.0: undefined reference to `std::basic_istream >& std::basic_istream >::_M_extract(float&)@GLIBCXX_3.4.9'
/usr/local/lib/liblvrtdark.so.9.0: undefined reference to `std::basic_istream >& std::basic_istream >::_M_extract(double&)@GLIBCXX_3.4.9'
/usr/local/lib/liblvrtdark.so.9.0: undefined reference to `std::basic_istream >& std::basic_istream >::_M_extract(double&)@GLIBCXX_3.4.9'
/usr/local/lib/liblvrtdark.so.9.0: undefined reference to `std::basic_ostream >& std::basic_ostream >::_M_insert(double)@GLIBCXX_3.4.9'
/usr/local/lib/liblvrtdark.so.9.0: undefined reference to `std::basic_istream >& std::basic_istream >::_M_extract(float&)@GLIBCXX_3.4.9'
/usr/local/lib/liblvrtdark.so.9.0: undefined reference to `std::basic_ostream >& std::basic_ostream >::_M_insert(double)@GLIBCXX_3.4.9'
collect2: ld returned 1 exit status
make: *** [test] Error 1

Running ldd reveals that liblvrtdark.so.9.0 is being used for the labview runtime.

 

In order to investigate what might be causing the problem, I compiled one of the nidaqmx base examples, and I didn't get an error. Running ldd as reveals that it uses liblvrtdark.so.8.2 for the lab view run time.

 

My suspicions is that some labview components are being compiled with gcc 3.4 while others are being compiled with gcc 4.1 (which is the default compiler in RHEL 5).

 

Any ideas how I might resolve these build errors?

 

Thanks in advance for any suggestions.

 

PS.

 

I have attached a tar file with the source files and following are the details from ldd:

ldd build/square.so 
linux-gate.so.1 => (0x008de000)
liblvrtdark.so.9.0 => /usr/local/lib/liblvrtdark.so.9.0 (0x00b9c000)
libc.so.6 => /lib/libc.so.6 (0x00110000)
libstdc++.so.6 => /usr/local/lib/LabVIEW-2009/patchlib/libstdc++.so.6 (0x009a7000)
libm.so.6 => /lib/libm.so.6 (0x00756000)
libdl.so.2 => /lib/libdl.so.2 (0x00256000)
libpthread.so.0 => /lib/libpthread.so.0 (0x0025a000)
/lib/ld-linux.so.2 (0x00b80000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00272000)

ldd /usr/local/natinst/nidaqmxbase/lib/libnidaqmxbase.so.3.3.0
linux-gate.so.1 => (0x00e50000)
libnidaqmxbaselv.so => /usr/local/lib/libnidaqmxbaselv.so (0x00248000)
libc.so.6 => /lib/libc.so.6 (0x00689000)
/lib/ld-linux.so.2 (0x00b80000)
liblvrtdark.so.8.2 => /usr/local/lib/liblvrtdark.so.8.2 (0x00e51000)
libdl.so.2 => /lib/libdl.so.2 (0x00813000)
libpthread.so.0 => /lib/libpthread.so.0 (0x001b0000)
libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x009c7000)
libm.so.6 => /lib/libm.so.6 (0x00b0a000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x0050c000)
Message Edited by rustywheeler on 03-29-2010 02:06 AM
0 Kudos
Message 1 of 5
(3,508 Views)

I have done some research on this and the f2 patch for LabVIEW fixed with the project and building libraries, applications, and etc. I would try this first to see if this fixes the issue and the link to it is below:

 

http://digital.ni.com/public.nsf/allkb/C3F88F3596A164AD86257647006FB022

 

JimS


Jim St
National Instruments
RF Product Support Engineer
0 Kudos
Message 2 of 5
(3,476 Views)

Hi JimS,

 

Thanks for the suggestion.  I applied the patch successfully [LabVIEW version number now displays as 9.0f2 (32-bit)], however I am still getting the same link errors.

 

I've also filled out a bug report (Reference#9412-6H5721) for this issue.

 

Cheers,

 

R

0 Kudos
Message 3 of 5
(3,447 Views)

Sorry to hear that updating LabVIEW didn't fix the issue. I am a bit confused why you think that the labview components are compiled with gcc 3.4 instead of gcc 4.1. Also I saw that at the end of the build errors is says Error 1. Is there an explanation to that error?

 

I am going to try to run this code on a linux machine that we have hear. I'll post if it works or not.

 

JimS


Jim St
National Instruments
RF Product Support Engineer
0 Kudos
Message 4 of 5
(3,427 Views)
Solution
Accepted by topic author rustywheeler

Hi JimS,

I'm happy to report that I managed to get the code working. I've included some of the steps I went through to solve the issue in case this might help to improve documentation or future builds.

In response to your query about the "Error 1" reported by make, it is just an indication that make detected an error from the compiler (it probably looks at the return code from the compiler).

 

The errors "undefined reference ... @GLIBCXX_3.4.9" were narrowed down. The labview generated shared library, square.so, links to /usr/local/lib/LabVIEW-2009/patchlib/libstdc++.so.6 which is a symlink to /usr/local/lib/LabVIEW-2009/patchlib/libstdc++.so.6.0.9. I decided to compare this version of libstdc++ to the one included with RHEL:

strings /usr/local/lib/LabVIEW-2009/patchlib/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_FORCE_NEW
strings /usr/lib/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_FORCE_NEW
So RedHat's libstdc++ doesn't include a string for GLIBCXX_3.4.9.

With this in mind, I was able to get my test application to compile by using LabVIEW's version of libstdc++ using the following makefile:
.PHONY: all clean
CPPFLAGS=-I/usr/local/natinst/nidaqmxbase/include -I/usr/local/natinst/LabVIEW-2009/cintools
LDFLAGS=build/square.so \
/usr/local/lib/LabVIEW-2009/patchlib/libstdc++.so.6 \
-Wl,--rpath -Wl,/usr/local/lib/LabVIEW-2009/patchlib/

all: test

clean:
rm -f test *.o

When trying to run the application, I got the following error:
./test: error while loading shared libraries: /usr/local/lib/liblvrtdark.so.9.0: cannot restore segment prot after reloc: Permission denied

But apparently this is due to SELinux disallowing the use of shared libraries with text relocation.
This can be disabled by running /usr/sbin/setenforce 0 as root.

The test application now works!

Cheers,

RW
Message 5 of 5
(3,397 Views)