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 

dll problem

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



Joined: 02 Sep 2007
Posts: 11

PostPosted: Thu Jan 10, 2008 4:40 pm    Post subject: dll problem Reply with quote

Hi,
we would like to create a project containing a simple fortran exe and a simple fortran dll.

when we try to execute we have "Error 29, Call to missing routine : _SUBSIMPLE@0 at 0x00401027"

the code is:
(exe)

F_stdcall SubSimple
call SubSimple()
stop
end

( dll )
SUBROUTINE SubSimple
PRINT *,"Simple subroutine called"
END SUBROUTINE

We also try with exportall switch, without success.

How can we solve?
Have you some example of fortran exe calling fortran dll?
thanks.
Back to top
View user's profile Send private message
Keith Waters



Joined: 07 Aug 2007
Posts: 29
Location: London or Somerset, UK

PostPosted: Sat Jan 12, 2008 1:13 am    Post subject: Reply with quote

Wild guess – try all lowercase subroutine name (or all upper).
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sat Jan 12, 2008 8:53 am    Post subject: Reply with quote

If you are compiling the DLL using FTN95 then you do not need F_STDCALL. Alternatively you must use F_STDCALL in both your DLL and executable.

FTN95 code is not case-sensitive. Only uppercase names are passed to the linker. This only becomes an issue if you are accessing a Fortran DLL from non-Fortran code.
Back to top
View user's profile Send private message AIM Address
cecio



Joined: 02 Sep 2007
Posts: 11

PostPosted: Mon Jan 14, 2008 8:04 pm    Post subject: Re: Reply with quote

I try with lovercase and uppercase, with and without F_STANDARD.....

No way....

may my problem be in some project parameters?

have you some solution example (like "visualcinteroperability" with fortran instead of C) ?

thanks
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Tue Jan 15, 2008 8:18 am    Post subject: Reply with quote

Your sample looks OK if you take out the F_STDCALL line.

Your DLL must be in the same folder as your exe or alternatively it could be in a folder that is included in the PATH environment variable.
Back to top
View user's profile Send private message AIM Address
cecio



Joined: 02 Sep 2007
Posts: 11

PostPosted: Tue Jan 15, 2008 6:28 pm    Post subject: Re: Reply with quote

may i post the zip file of my project?

Thanks
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Jan 16, 2008 8:44 am    Post subject: Reply with quote

We would need to make a charge for this service.
You can send an email to Silverfrost to ask for details.

Here is a simple example that may help. Remember to keep the results in one folder.

File lib1.f90

Code:
subroutine sub1
print*,"Hello from sub1"
end


File main.f90

Code:
program main
call sub1
end


Building from a command line
Code:
ftn95 lib1 /link lib1.dll
ftn95 main /link /ref lib1.dll


Another way to build from a command line
Code:
ftn95 lib1
slink lib1.obj -dll -exportall
ftn95 main
slink main.obj lib1.dll


In both cases the executable is main.exe
Back to top
View user's profile Send private message AIM Address
cecio



Joined: 02 Sep 2007
Posts: 11

PostPosted: Thu Jan 17, 2008 4:23 pm    Post subject: Re: Reply with quote

Thanks PaulLaidler

with your instructions and command line it works.
But i need to understand some things....

why you link main.obj whith lib1.dll?

I think my problem is here.

Is there a way to indicate in the source ( and not at link time) where is my dll?

( in vb6 i add line like:
Declare Function iajfltdll Lib "pcroutdll.dll" (i4 As Long, dd As Single) As Integer )

Thanks
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Thu Jan 17, 2008 6:39 pm    Post subject: Reply with quote

The linker needs to know where the DLL is both for its own use and to embed this information in the executable.

There is a LIBRARY directive that you can write into the code but this only works when you use /LINK or /LGO on the FTN95 command line.

The recommended route is to create a project in either Plato3 or Visual Studio and then all of this information goes into the project data.
Back to top
View user's profile Send private message AIM Address
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