LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to call a shared object which throws (and catches its own) exceptions

I've been attempting to build a shared object that I wish to call from LabVIEW 7 on Linux and Solaris. I can build a simple library just fine, but as soon as I throw exceptions (which are caught within the library) LabVIEW dies a horrible death via SIGABRT. It appears that the exception is not being caught.

To reproduce:
Compile and link the attached file:

g++ -fPIC -c test.cpp
g++ -shared -module -o libtest.so test.o

Run the attached vi. Watch LabVIEW do a disappearing act.

I'm using gcc 3.3.2 on Linux 2.4.25 and gcc 2.95.2 on Solaris 2.8.

I suspect that this link might be part of the explanation, but cannot be sure.

http://gcc.gnu.org/faq.html#dso

Cheer
s,
Jason
Download All
0 Kudos
Message 1 of 3
(2,742 Views)
Hi Jason,

Ideally you'll want to use the exact same version of g++ that was used to compile LabVIEW. For 7.0 on Linux, this was g++-3.1 (so I've been told). I used g++-3.0 (which happened to be on my machine) and it worked okay. This is because exceptions are compiler specific, and the ABI has changed in 3.0 and 3.2.

But, better than that, change your second line to look like this:

g++ -shared -static -module -o libtest.so test.o

Which should fix the problem. I'm not sure if this is the kosher thing to do, but it works for me.

-Duffey
Message 2 of 3
(2,742 Views)
I didn't make it clear, if you used the modified linker line, you should be able to use any version of gcc.

-Duffey
0 Kudos
Message 3 of 3
(2,742 Views)