Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Nov 19, 2017 11:16 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Access to dylib
PostPosted: Fri Nov 18, 2011 5:15 am 
Offline

Joined: Thu Mar 02, 2006 4:42 am
Posts: 23
Location: Germany
Hello,

I have here some dylibs which I have to access from my RS application. But I'm not able to access them. The check with "isFunctionAvailable" results always with False.

I tried to put them in the application bundle - all subfolders

I tried also to set the environment variable DYLD_LIBRARY_PATH to the path.

Does some has an idea how to include these dylibs into my RS application?


Thank you


Top
 Profile  
Reply with quote  
 Post subject: Re: Access to dylib
PostPosted: Fri Nov 18, 2011 2:40 pm 
Offline
Real Software Engineer

Joined: Sat Dec 24, 2005 8:18 pm
Posts: 7858
Location: Canada, Alberta, Near Red Deer
Where in the OS X bundle did you put them ?
And how did you try to access the dylib in declares ?

_________________
Norman Palardy (Real Software)


Top
 Profile  
Reply with quote  
 Post subject: Re: Access to dylib
PostPosted: Fri Nov 18, 2011 3:26 pm 
Offline

Joined: Thu Mar 02, 2006 4:42 am
Posts: 23
Location: Germany
Hello,

I tried first to place the libs outside of the bundle. All libs are in one folder. Within RealBasic I set the environment variable "DYLD_LIBRARY_PATH" to this directory.

Before I aaccessed the libs, I first checked the availability with the

Return System.IsFunctionAvailable( "EricBearbeiteVorgang", "libericapi")

This resulted always with a false response.

I also used tried "LD_LIBRARY_PATH" an addition to "DYLD_LIBRARY_PATH".

Later I tried to copy the libs to all available folders within the application bundle.


Top
 Profile  
Reply with quote  
 Post subject: Re: Access to dylib
PostPosted: Sun Nov 20, 2011 10:27 am 
Offline

Joined: Thu Mar 02, 2006 4:42 am
Posts: 23
Location: Germany
Hello,

today I was able to use the libraries. I placed the file into the folder /use/local/lib. It seems that RS don't use the environment variable DYLD_LIBRARY_PATH.

Does someone was able to to use this variable to put the libraries in another folder? thank for all answers.


Top
 Profile  
Reply with quote  
 Post subject: Re: Access to dylib
PostPosted: Sun Nov 20, 2011 1:09 pm 
Offline
Real Software Engineer

Joined: Sat Dec 24, 2005 8:18 pm
Posts: 7858
Location: Canada, Alberta, Near Red Deer
The best place to put them would be right next to the executable OR in the Frameworks directory inside the application bundle

If it's right next to the executable file you can reference that dylib as
soft declare method as lib "@executable_path/SampleDylib.dylib"

The important thing is the use of @executable_path which the OS uses to know how to locate your dylib

_________________
Norman Palardy (Real Software)


Top
 Profile  
Reply with quote  
 Post subject: Re: Access to dylib
PostPosted: Sun Nov 20, 2011 2:58 pm 
Offline

Joined: Thu Mar 02, 2006 4:42 am
Posts: 23
Location: Germany
Hello,

I get crazy….

As I understood you "@executable_path" stands for the folder where the executable of my application is. So I changed my code to

Soft Declare Function GetFinanzamt Lib "@executable_path/libericapi.dylib" Alias "EricGetFinanzamt" ( InfoType As CString, ListBuffer As CString) As Int32

Afterwards I created the executable package (app). And for testing I copied all libraries to all folders (step by step) within the package. And to be shire also into the folder of the package. But the Function of the library was never found - always an exception.

Also if I enter the full path to the libraries /.../lib/libericapi.dylib the function will not be found.


Top
 Profile  
Reply with quote  
 Post subject: Re: Access to dylib
PostPosted: Sun Nov 20, 2011 3:01 pm 
Offline

Joined: Thu Mar 02, 2006 4:42 am
Posts: 23
Location: Germany
Hello,

after sending I have an idea. Is it possible that the developer of the libraries entered the absolute path for the depending libraries. And because I changed the absolute path, the depending libraries were not found.


Top
 Profile  
Reply with quote  
 Post subject: Re: Access to dylib
PostPosted: Sun Nov 20, 2011 8:56 pm 
Offline
Real Software Engineer

Joined: Sat Dec 24, 2005 8:18 pm
Posts: 7858
Location: Canada, Alberta, Near Red Deer
That certainly seems possible

_________________
Norman Palardy (Real Software)


Top
 Profile  
Reply with quote  
 Post subject: Re: Access to dylib
PostPosted: Mon Nov 21, 2011 2:30 am 
Offline
Real Software Engineer

Joined: Fri Jan 28, 2011 5:24 pm
Posts: 145
Manfred Richter wrote:
Hello,

I get crazy….

As I understood you "@executable_path" stands for the folder where the executable of my application is. So I changed my code to

Soft Declare Function GetFinanzamt Lib "@executable_path/libericapi.dylib" Alias "EricGetFinanzamt" ( InfoType As CString, ListBuffer As CString) As Int32

Afterwards I created the executable package (app). And for testing I copied all libraries to all folders (step by step) within the package. And to be shire also into the folder of the package. But the Function of the library was never found - always an exception.

Also if I enter the full path to the libraries /.../lib/libericapi.dylib the function will not be found.


You need to know what exactly dyld is saying the error is. Unfortunately RB doesn't currently provide this in the exception information, which you should probably file a Feedback ticket about.

What you can do is try the load the dylib yourself and check the error, like this:
declare function dlopen lib "/usr/lib/libSystem.B.dylib" ( path as CString, mode as integer ) as ptr
declare function dlerror lib "/usr/lib/libSystem.B.dylib" () as CString

dim handle as ptr = dlopen( path, 0 )
if handle = nil then
msgbox( dlerror() )
end if


You can also see what dylibs a given Mach-O file requires by running "otool -L" on the file.

_________________
Joe Ranieri
Mac Frameworks & Compiler
REAL Software, Inc.


Top
 Profile  
Reply with quote  
 Post subject: Re: Access to dylib
PostPosted: Mon Nov 21, 2011 2:19 pm 
Offline

Joined: Thu Mar 02, 2006 4:42 am
Posts: 23
Location: Germany
Hello,

thank you very much for this answer. I tried it and got the message "image not found".

For your background. These libraries are from the german government for the tax. In the forum of them I also asked about these libraries. Here we found that there are dependencies between the libraries. The paths are in some libraries absolute and other relative. And there are some other errors within these libraries.

I wait until the publish a corrected version. And hope this will work.

But maybe it is a good idea to include these code for a better analysis if the user made some mistakes.


Top
 Profile  
Reply with quote  
 Post subject: Re: Access to dylib
PostPosted: Tue Jan 31, 2012 5:06 am 
Offline

Joined: Thu Mar 02, 2006 4:42 am
Posts: 23
Location: Germany
Hello,

yesterday I tested the new versions of the libs. The problem still occurs within RS. But an example with xCode works.

I made same tests with calling the libs. With environment variable, without it, with hard and softdeclare. When testing without softdeclare I saw the the lib was loaded. But a depending lib caused an error.

My idea is now, that the environment variable is uses by calling the first lib. But for the calling of the second lib it doesn't will be used.

Does someone can agree me?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group