On 12/6/05, Aaron Ballman <aaron at realsoftware dot com> wrote:
>
> > Yeah no kidding it breaks easily. But I thought you *had* to use
> hard-coded
> > build-time paths for loading 3rd party libraries. @executable_path is
> > mac-only, right? So on Windows the declare statement needs to use the
> full
> > path to the 3rd party library.
>
> You're right in that @executable_path is Mac-Only, but you're wrong
> about using hard-coded paths. You should never use them!
>
> > My library is a private one. I install (with Vice) at the time my
> program
> > gets installed. Since we are talking about windows, there aren't
> > subdirectories of the program, since the program is a single .EXE file.
> But
> > next to the progam I have a support folder, and in sub-folders of this I
> > have my library that the declare statements use.
>
> You've got two options. 1) You can move the DLL file so that it resides
> next to your executable. 2) You can use some declares to make it work (
> the recommended declare requires XP SP 1 or higher, but there are some
> other hacks you could use in place of a hard-coded path).
>
> I'd do #1 -- it's the easiest solution. If you absolutely can't, then
> let me know and I'll show you how to do #2 properly.
>
> > The only thing that doesn't make sense is how to do a declare on Windows
> to
> > a library, when I thought I had to a) use a constant, and b) the
> constant
> > had to be an absolute, not relative, path.
> >
> > Can the path be relative? If so, that solves all my problems.
>
> No, but there's a specific search path that libraries use when loading
> them.
>
> Essentially (in order):
>
> 1) The directory from which the application loaded.
> 2) The system directory. Use the GetSystemDirectory function to get the
> path of this directory. The name of this directory is System32.
> 3) The 16-bit system directory. There is no function that obtains the
> path of this directory, but it is searched. The name of this directory
> is System.
> 4) The Windows directory. Use the GetWindowsDirectory function to get
> the path of this directory.
> 5) The directories that are listed in the PATH environment variable.
Aaah.. This is great. Looks like a solution.
I have 98 and 2K users, so I can't use your XP solution. Yes, lets go with
#1.
Right now, I have a constant 'library' equal to
@executable_path/../../lib/netCDF/libnetcdf.dylib and 'library_win' equal to
C:\Program files\EVA\lib\netCDF\netcdf.dll
Why don't I have 1 constant with platform-specific entries? Because of this:
http://support.realsoftware.com/listarchives/realbasic-nug/2005-08/msg01260.html
Anyway, my declare statements then look like this:
#If TargetMacOS
#if DebugBuild then
soft declare function nc_open lib library_debug ( path as cstring,
mode as integer, byref ncid as integer ) as integer
#else
soft declare function nc_open lib library ( path as cstring, mode as
integer, byref ncid as integer ) as integer
#endif
#elseif TargetWin32
soft declare function nc_open lib library_win ( path as cstring, mode as
integer, byref ncid as integer ) as integer
#endif
Are you suggesting that the 'library_win' constant just needs to be "
netcdf.dll" rather than the full path to it, as long as netcdf.dll is
located in the same folder as the .EXE file? I'd try this myself but I'm no
where near my windows dev computer.
Thanks for this help,
-k.
P.S. When you mention "GetSystemDirectory" and "GetWindowsDirectory", are
those RB functions or windows functions I need to access via Declare? I
can't find them in the RB help guide. I can find SpecialFolder.System and
SpecialFolder.Windows, but I am hesitant to use SpecialFolder now because it
doesn't understand international stuff... SpecialFolder.Applications returns
c:\program files\ even though it is C:\Progammi on an Italian computer.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|