replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Trying to link to a 3rd-party DLL...
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Trying to link to a 3rd-party DLL...

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
KennyT



Joined: 02 Aug 2005
Posts: 318

PostPosted: Wed Aug 08, 2012 3:14 pm    Post subject: Trying to link to a 3rd-party DLL... Reply with quote

...and at run time, it insists that the DLL should be in the c:\ root folder, rather than searching in the "current" folder.

Anyone got any ideas where to start when trying to solve this?

K
Back to top
View user's profile Send private message Visit poster's website
ebarbero



Joined: 01 Aug 2012
Posts: 20

PostPosted: Wed Aug 08, 2012 8:15 pm    Post subject: Reply with quote

.NET or win32 project? do you use !dec$ attributes dllimport:: ???
_________________
http://www.cadec-online.com/
Back to top
View user's profile Send private message Visit poster's website
KennyT



Joined: 02 Aug 2005
Posts: 318

PostPosted: Thu Aug 09, 2012 7:26 am    Post subject: Reply with quote

I'm working in Win32. The DLL is an "unmanaged" wrapper for a .NET project.

I don't use "!dec$ attributes dllimport::" (I can't see any help on it either?)

K
Back to top
View user's profile Send private message Visit poster's website
ebarbero



Joined: 01 Aug 2012
Posts: 20

PostPosted: Thu Aug 09, 2012 8:24 pm    Post subject: Re: Reply with quote

KennyT wrote:
I'm working in Win32. The DLL is an "unmanaged" wrapper for a .NET project.

I don't use "!dec$ attributes dllimport::" (I can't see any help on it either?)

K


What do you mean by .NET project? Ftn95, c#?

In fact I think it does not matter. Win32 compiler can only work with c/c++.

There is this page in the help:
http://www.silverfrost.com/ftn95-help/mixlan/callingc_c__fromftn95.aspx

But not one called calling c# from ftn95

There is one like that, but for the .net compiler, not for the win32 compiler

http://www.silverfrost.com/ftn95-help/netprog/callingdotnetmethods.aspx

Did that helped?
_________________
http://www.cadec-online.com/
Back to top
View user's profile Send private message Visit poster's website
KennyT



Joined: 02 Aug 2005
Posts: 318

PostPosted: Fri Aug 10, 2012 8:14 am    Post subject: Reply with quote

Perhaps I didn't explain the problem clearly enough!

I am building my application using win32. The third party application is written in .NET. Their programmer has supplied an "un-managed" wrapper for some of their functionality such that I can use the STDCALL technique to call them via my own set of wrappers, e.g.
Code:

!int ILogReadings_get_Index(ref long instance)
SUBROUTINE IP_ILogReadings_get_Index ( INSTANCE, RET)
    INTEGER*4 :: RET
    STDCALL IP_ILogReadings_get_Index_ 'ILogReadings_get_Index'(REF) : INTEGER*4
    INTEGER*8   :: instance
    RET =  IP_ILogReadings_get_Index_ ( INSTANCE)
END SUBROUTINE
 

This all works, provided their DLL exists in the c:\ root folder at run time, which is not really a long term solution, when it comes to distributing to customers!

So, the bottom line is:

Why must their DLL be in the root folder for my application to run? Why can't the runtime load find it in the application folder?

K
Back to top
View user's profile Send private message Visit poster's website
ebarbero



Joined: 01 Aug 2012
Posts: 20

PostPosted: Fri Aug 10, 2012 5:37 pm    Post subject: Reply with quote

I am sorry I misinterpreted your question.

It is really odd to ask for the dll to be in c:, but perhaps you can modify the path variable to point in the directory you have the dll. Would that solve the problem?
_________________
http://www.cadec-online.com/
Back to top
View user's profile Send private message Visit poster's website
KennyT



Joined: 02 Aug 2005
Posts: 318

PostPosted: Sat Aug 11, 2012 8:57 am    Post subject: Reply with quote

Some more information about how the third party app calls the DLL functions...

It appears that the DLL exports are "resolved" at runtime, rather than link time. Some test source they sent me has the folllowing call:

HINSTANCE hinstLib = LoadLibrary(TEXT("API.NativeExports.dll"));

Do we have the equivalent ability in FTN95?

edit: This extract from the FTN95 help pages sounds "interesting"!

Quote:

A Visual Basic program can use calls to the API functions LoadLibrary and FreeLibrary in order to ensure that the DLL does not unload whilst a Visual Basic form is loaded.

...

The FTN95 DLL is assumed to reside in the Windows system directory.


K
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8210
Location: Salford, UK

PostPosted: Sun Aug 12, 2012 8:14 am    Post subject: Reply with quote

I have never heard of anyone trying to access a .NET dll assembly from a Win32 executable before so I don't know if this can be done. Certainly, for me, you are working in uncharted waters.

The comment that you have picked up from the documentation about VB does not seem to be relevant.

DLL exports are always resolved at runtime. By default (for FTN95) they are resolved when the program is loaded but it is possible to to delay the resolving to the point when the function is called (depending on the commands used with SLINK). However, this does help with your initial problem.

Can you get the dll to work when you put it in the root folder as requested?

You can call LoadLibrary from FTN95 to see if the library is visible and loadable but there is no easy way to use the result of GetProcAddress but, again, this does not appear to be the issue here.
Back to top
View user's profile Send private message AIM Address
KennyT



Joined: 02 Aug 2005
Posts: 318

PostPosted: Sun Aug 12, 2012 9:12 am    Post subject: Reply with quote

Hi Paul,

Yes, the DLL works if placed in the root folder. If it's not there, I get the following message:

"The program can't start because \API.NativeExports.dll is missing from your computer. Try reinstalling the program to fix this problem".

"depends" also highlights the DLL as "not found".

I realise I'm a bit "out on a limb"!

As I understand it the 3rd party DLL is an "unmanaged" wrapper around "managed" functions but, as I don't use .NET, I don't really understand what that means!

Are there any other tools that can investigate whether the "\" is embedded in the DLL (ie their fault!) or somewhere that FTN95 or SLINK can have an effect on?

K

edit: I can call "LoadLibrary" and get a return value of 1661534208 (presumably just not being zero indicates success?) with just the local copy of the DLL being present.

2nd edit: Paul, you mention that the resolution of the externals depends on the slink commands used. Here's my link script for my DLL - what could I be doing different?

Code:

dll
lo test_sub
lo sub1    !these contain my "wrappers"
lo API.NativeExports.dll     
exportall

file test


K
Back to top
View user's profile Send private message Visit poster's website
KennyT



Joined: 02 Aug 2005
Posts: 318

PostPosted: Sun Aug 12, 2012 10:34 am    Post subject: Reply with quote

Did some more tests...

Code:
strings API.NativeExports.dll | grep -i native


and got this output!

API.NativeExports.dll
API.NativeExports
\API.NativeExports.dll

Which, I think, puts the ball back in the court of the 3rd party! Something, somewhere, when they�re building their DLL, is specifying that the �name� of the DLL when passed to the runtime loader, is:

\API.NativeExports.dll

K
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8210
Location: Salford, UK

PostPosted: Sun Aug 12, 2012 2:19 pm    Post subject: Reply with quote

If you use

rlo API.NativeExports.dll

in your SLINK script then the program will start running but will probably fail when the program calls a function in the dll.
Back to top
View user's profile Send private message AIM Address
KennyT



Joined: 02 Aug 2005
Posts: 318

PostPosted: Tue Aug 14, 2012 1:16 pm    Post subject: Reply with quote

Hopefully resolved. The 3rd-party has relinked his DLL and got rid of the "\".

thanks

K
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group