How to use a Library?

I have a Library with the name “libad4.dylib”
I have copy them into the Program with OSX > Add to “Build Settings” > Build Step > Copy Files.

The Manufacturer has given an Example for Windows VB.
Like:
If LIBAD4.Open(“usb-ad:0”) Then

How can I use this Library? On my Imac?

From the other thread you opened:

[quote=394826:@Ulrich Bogun]http://developer.xojo.com/declare
https://forum.xojo.com/13023-how-to-call-dylib/0
https://forum.xojo.com/43610-c-c-external-dynamic-library-linkage-example-project/20
https://xojoblog.me/2014/10/12/deklaration-der-abhangigkeit/[/quote]
If there is anything you don’t understand you can ask here. If your coding experience is limited maybe you can start here: https://www.xojo.com/resources/learn.php

Hi Hans,

As replied in the other thread, you need to use Declares in order to call the functions from the Library. To know what the functions are, you need to have access to the “.h” or header file for the library or, preferably, the documentation provided from the vendor to programming languages like C or Objective-C, for example.

Once you have these resources, you can find some examples about how to use the Declare in the Example Projects > Advanced > Declares folder from the Xojo main Folder for macOS.

Hope this helps!

Javier

Hi Javier,
I have try:

Soft Declare Function Open Lib "Libad4.dylib"() As Boolean

but witgout respons

Open is a parameter of the Lib, i have found it bij Examples for VB and C++

In this case i am a beginner.

Did you import the dylib?
If not:
Insert a Copy Files Build Step to each appropriate platform.
Drag the dylib from your hard disk into the build step (into the place where usually the code editor resides)
In Inspector, make sure behavior applies to both build steps – debug and release –, and set the destination to the framework folder.
Afterwards, if the declare is right, it should work when you call it: Put a line

Dim Result as Boolean = (ModuleName).Open

somewhere in your project where it will be run.

Hi hans, after declaring the function you should be able to use it from the Xojo Code. I mean:

Soft Declare Function Open Lib "Libad4.dylib"() As Boolean Dim b as boolean = Open

In case that the function name from the library is confuse or it collides with anyone used in the Xojo language itself, then you should use the Alias option in the Declare to differentiate it. For example:

Soft Declare Function Open Lib "Libad4.dylib" Alias Open_From_Lib () As Boolean Dim b as boolean = Open_From_Lib
Javier

Thanks Ulrich and Javier,
I will tray your propasals.