Cross platform declares

Having recently got XOJO, to allow for a couple of programs that I have built for Windows to work also on OS X, I seem to be missing something re. Declaring Funcions whose functions would be Global to the rest of the application.

(Two ?'s)

#One:

There are some pointers that I have read on the forum and have done the following:

1> Selected My DLL/Dylib’s and placed them in Copyfile1 & 2, depending on OS build.

2> Created a Module1 and inserted this in a ‘loaddll’ Method:

[code] #if TargetWin32 // In case we try that on a Mac or a Linux Box…
CONST MyDLL=“sqlcipher.dll”
#endif

#if TargetMacOS
Const MyDLL = “@executable_path/…/libsqlcipher.0.dylib”
#endif

msgbox (mydll)
Soft Declare Function sqlite3_sourceid lib MyDLL Alias “sqlite3_sourceid” ( ) As CString[/code]

3> Set the ‘loaddll’ module to be ‘External’; which AFAIK should expose the Declared Functions?

4> Set 2 buttons on the only Window
5> Button 1 ‘Action’ is loaddll
6> Button 2 ‘Action’ is MsgBox(sqlite3_sourceid())

…this results in an error: Window1.Pushbutton2.Action…“sqlite3_sourceid” This item does no exist

Am I incorrect in taking it that the Declares in the ‘External’ module should be exposed as Global? Obviously I have incorrectly coded this.

#Two:
By REMming out the sqlite3_sourceid error, I compile and pass onto an OS X box and see:

"@executable_path/../libsqlcipher.0.dylib"

in the MsgBox on the MAC

…does “@executable_path/…” work or have I missed something else, does not appear to work on Windows either?

Thanks.

No. Making a module External means that it resides in a separate source code file and can thus be shared between projects. Accessing DLL’s is a different matter altogether. You usually have to insert the Declare statement into whatever method you call the declare from.

There are 2 approaches to making a declare global:

  1. You can wrap the declare in a Xojo method in a module and call the Xojo method from anywhere (my preference).
  2. You can use Insert -> External Method to make the Declare globally available.

@executable_path” only works in a Declare where you specify the Lib path. The rest of Xojo treats it as a literal string.