Page 1 of 2
Dynamic Librarys (dylibs)
Posted: Wed Dec 14, 2005 3:06 pm
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
Posted: Fri Dec 16, 2005 12:32 pm
by Fred
I just try it here and it seems to work, could you test it again with the registered version ?
Posted: Fri Dec 16, 2005 2:14 pm
by SEO
Yes I should (Have not doing that)
Posted: Fri Dec 16, 2005 10:30 pm
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
Posted: Fri Dec 16, 2005 10:41 pm
by Fred
the syntax error is very wierd. could you try to retype it in a new source (don't copy/paste) ?
Posted: Fri Dec 16, 2005 10:50 pm
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
Posted: Sat Dec 17, 2005 12:17 am
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
Posted: Sat Dec 17, 2005 7:07 pm
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
Posted: Tue Dec 20, 2005 11:46 am
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).
Posted: Tue Dec 20, 2005 12:02 pm
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
Posted: Tue Dec 20, 2005 12:22 pm
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
Posted: Tue Dec 20, 2005 1:10 pm
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.
Posted: Tue Dec 20, 2005 1:17 pm
by SEO
@Fred
It's a taste of Christmas ....

Looking forward to test...
Regards,
SEO
Posted: Wed Dec 21, 2005 12:23 pm
by Fred
It's now added

.
Posted: Wed Dec 21, 2005 12:29 pm
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...