Dynamic Librarys (dylibs)

Mac OSX specific forum
SEO
Enthusiast
Enthusiast
Posts: 178
Joined: Fri Dec 09, 2005 11:42 pm
Location: Sweden
Contact:

Dynamic Librarys (dylibs)

Post by SEO »

First, sorry for the 'jumping' in the threads!
Not nice, therefore I created this new thread for dylibs Questions, and hope answers.
-----------------------------------

I compiled my SampleDylib and use the code:

Code: Select all

If OpenLibrary(0, "SampleDylib.dylib") 
  FunctionPointer = IsFunction(0, "addFunction") 
  If FunctionPointer 
    x = CallFunctionFast(FunctionPointer, 10,5) 
Debug x
  EndIf 
EndIf
I get Line 2: Syntax Error ! (FunctionPointer = IsFunction(0, "addFunction")

Any ideas?
/SEO
Fred
Administrator
Administrator
Posts: 18220
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

I just try it here and it seems to work, could you test it again with the registered version ?
SEO
Enthusiast
Enthusiast
Posts: 178
Joined: Fri Dec 09, 2005 11:42 pm
Location: Sweden
Contact:

Post by SEO »

Yes I should (Have not doing that)
SEO
Enthusiast
Enthusiast
Posts: 178
Joined: Fri Dec 09, 2005 11:42 pm
Location: Sweden
Contact:

Post by SEO »

Nope!
Line 2 Syntax Error!

I have the SampleDylib.dylib in the same folder that the PB source file when I run from IDE. Is PB created some temporary bundle?

C code:

Code: Select all

int addFunction( int a, int b ) {
      return a + b;
  }


  int stringLength( char *str ) {
      return strlen(str);
  }
  
Download project
http://www.xhtmlsoft.com/pb/downloads/

SEO
Fred
Administrator
Administrator
Posts: 18220
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

the syntax error is very wierd. could you try to retype it in a new source (don't copy/paste) ?
SEO
Enthusiast
Enthusiast
Posts: 178
Joined: Fri Dec 09, 2005 11:42 pm
Location: Sweden
Contact:

Post by SEO »

YEP!!

Then I get the same error on next line and so on.
But I cleanup and use new carrige returns in the code.

And then it works!

Thx,
SEO
SEO
Enthusiast
Enthusiast
Posts: 178
Joined: Fri Dec 09, 2005 11:42 pm
Location: Sweden
Contact:

Post by SEO »

Sorry, it looks not work inside the bundle.

I tested some 'paths' /dsd/sds/SampleDylib.dylib
and inside the MacOs folder and as 'absolutepath on the desktop, but no...

This have NOT prioritet 10 only 1-2 ...

Thx,
SEO
SEO
Enthusiast
Enthusiast
Posts: 178
Joined: Fri Dec 09, 2005 11:42 pm
Location: Sweden
Contact:

Post by SEO »

If fond some strange or perhaps i do some wrong...

As I wrote I DON'T get Dylibs to works and today I have this problem, that could Explain also why Dylibs not working inside the bundle.

Code: Select all

Result = LoadImage(tb1ico,"Resources/Toolbaricons/tbico1.png")
It looks that nothing works when I use to call something that is inside an folder. The Result = 0

And is this also the reason why the PB Example Project Toolbar.pb NOT was in the Mac Example Folder ???

Regards,
SEO
Fred
Administrator
Administrator
Posts: 18220
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

This is a good question, should all the filesystem paths be relative to the bundle (ie: current directory set to the bundle path) by default ? If yes, it shouldn't be a problem to change (for your tests you can still use an absolute path).
SEO
Enthusiast
Enthusiast
Posts: 178
Joined: Fri Dec 09, 2005 11:42 pm
Location: Sweden
Contact:

Post by SEO »

Hi and thanks for the response!

Absolute paths on Mac is DEVIL! Criminal and forbidden... That is my an many Mac users opinion. That is beacuse you could move an file to an another folder or harddisk and Mac file system is following your file. So it find it also when you moved it.

Absolute paths are only used to display where the file is located .. like in an Window title ....


About the bundle: The file should be relative to the executable, you could not use an 'absolute path', what happens if you move your application bundle ? When an user download an application, he could use it every where... And how do I know as an developer of the app where he put his application?


My second test with the Toolbar...
I could not use something like this LoadImage "folder1/folder2/image.png"

Regards,
SEO
SEO
Enthusiast
Enthusiast
Posts: 178
Joined: Fri Dec 09, 2005 11:42 pm
Location: Sweden
Contact:

Post by SEO »

Hi again,

I post this example how it works in an another language ...
or could work....

myPath$ = GetPath("") // This give the Executable (CurrDir)

Here opening an text file inside the bundle
myPath$ = GetPath("").child("folder1").child(folder2").child("textfile.txt")

So if my bundle is on the desktop folder i could address desktop folder like this:


myPath$ = getPath("")
myPath$ = myPath$.parent
or like this myPath$ = getPath(..)

Now myPath$ = desktopFolder

Regards,
SEO
Fred
Administrator
Administrator
Posts: 18220
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

I mean for your tests you could use an absolute path, not for release ! To test it: LoadImage(0, "/Users/yourlogin/test.png"). About the bundle currentdir by default, it makes sens, so i will do this change. About the command to retrieve the executable path, it will be done as well.
SEO
Enthusiast
Enthusiast
Posts: 178
Joined: Fri Dec 09, 2005 11:42 pm
Location: Sweden
Contact:

Post by SEO »

@Fred

It's a taste of Christmas .... :)
Looking forward to test...

Regards,
SEO
Fred
Administrator
Administrator
Posts: 18220
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

It's now added :wink: .
SEO
Enthusiast
Enthusiast
Posts: 178
Joined: Fri Dec 09, 2005 11:42 pm
Location: Sweden
Contact:

Post by SEO »

THANKS!
Do you need something from me, I think about to fix 'Live Resize' as standard or an 'command' ... (I think about my carbonx.pbl file )

Regards,
SEO....

PS. Where do i find the Constants for Application menu, About menu... i thinkI have seen those some where but can't find them now...
Post Reply