soft declare runs, but functionNotFoundException thrown when the function is called

I am trying to use the soft declare command to make calls into the Ocean Optics SeaBreeze library. It’s an open source project found on Source Forge. I’ve compiled SeaBreeze and produced a library. I’ve used functions from that library in an application coded in c to control a spectrometer. I’d like to do the same from Xojo but have been unable to do so.

This works:

const aLib ="/usr/lib/libc.dylib"
Soft Declare Function getpid Lib aLib () as Integer
MsgBox "pid="+str(getpid())

This throws a FunctionNotFoundException:

const myLib ="/usr/local/lib/libseabreeze.dylib"
Soft Declare Sub sbapi_initialize Lib myLib () 
sbapi_initialize

A text search of the libseabreeze.dylib file reveals the sbapi_initialize string. The library file is found by Xojo, so it is not a problem with the file path. Is there a gcc compiler option that needs to be set so that Xojo can find functions in a library? I’m at a loss to explain why Xojo can’t find the function.

Maybe its not exported ?

My thought as well, but I can call the function when coding with C. I’ve done several applications using the seabreeze API library in C. I thought, ‘Wouldn’t it be nice to have an interface for Xojo?’ I just assumed a soft declare would duplicate what I’d done in C, but no… I’m looking at gcc compiler options to see if something needs setting for Xojo.

Try running nm on the library to check if the symbols are exported like you expect.

I ran an nm and saw the symbols as expected. I’ve checked to see that the library exists at the path I gave to the soft declare as well. I’m trying to call a function called sbapi_initialize. Here’s part of the nm output:
.
.
.
0000000000102150 T _sbapi_get_stray_light_coeffs_features
0000000000101b10 T _sbapi_get_temperature_features
0000000000101900 T _sbapi_get_thermo_electric_features
0000000000100a30 T _sbapi_initialize
0000000000101800 T _sbapi_irrad_calibration_has_collection_area
0000000000101760 T _sbapi_irrad_calibration_read
.
.
.

Even System.IsFunctionAvailable( “sbapi_initialize”, “/usr/local/lib/libseabreeze.dylib” ) returns ‘false.’

The website SeaBreeze API says that Seabreeze is supported for MacOS. It doesn’t mention OS X.

I’ve already used the SeaBreeze library with Mac OS X, Yosemite. I wrote a daemon that runs on both Raspberry Pi, Raspbian and OS X, Darwin. I compiled the SeaBreeze API under both of those OS’s along with my daemon. The calls to the SeaBreeze API library from the daemon worked in both of those cases, but that code was written in C.

Renaming products sometimes has issues.
While the official name is now OS X, many people still continue to call it Mac OS or MacOS or Mac OS X.
Same happens to Xojo sometimes called RealBasic, REALbasic, RealStudio… :wink:

MacOS was not renamed to, it was replaced by OS X. There fundamentally different OSs (OS X is UNIX based, MacOS was not).

But as the website says Seabreeze has been tested with MacOS 6.5 they must mean OS X 6.5, as there was no MacOS 6.5. Someone should tell them at some point…

Hm. Try running file on the dylib to see what architectures it is.

[quote=188305:@Eli Ott]MacOS was not renamed to, it was replaced by OS X. There fundamentally different OSs (OS X is UNIX based, MacOS was not).

But as the website says Seabreeze has been tested with MacOS 6.5 they must mean OS X 6.5, as there was no MacOS 6.5. Someone should tell them at some point…[/quote]

Ohh I was not even thinking to MacOS Classic :smiley:
After MacOS (Classic), Mac OS X came then recently renamed to OS X (no Mac anymore)
Anyway, it’s clear they are talking of OS X, but this naming error is very common. I believe they mean Mac OS X 10.6.5

libseabreeze.dylib a Mach-O 64-bit dynamically linked shared library x86_64.

This would be the problem. You’ll need a 32-bit version of the dylib to be able to declare into it from a 32-bit Xojo application.

Thank you Joe. I believe that would be the problem.

"On 64-bit Linux distributions, you will need to ensure the appropriate 32-bit compatibility libraries are installed in order to run Xojo or applications built with Xojo. "