replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Creating and calling of DLL subroutine in FTN95 Express
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 

Creating and calling of DLL subroutine in FTN95 Express

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



Joined: 05 Aug 2014
Posts: 4

PostPosted: Wed Aug 06, 2014 7:16 pm    Post subject: Creating and calling of DLL subroutine in FTN95 Express Reply with quote

Hello,

I'm just getting started with FTN95 Express v5.4.0.0 under Win7 64Bit. Now I got stuck with the following problem.

As a test case I created a Fortran DLL within Debug Win32 mode where I kept all the default project settings and just added the linker option '-exportall'. The DLL consists of the following subroutine:

Code:
SUBROUTINE HELLO
!DEC$ ATTRIBUTES DLLEXPORT :: HELLO

WRITE(*,*) 'HELLO WORLD'

RETURN
END SUBROUTINE HELLO


This subroutine should be called by the following Fortran program which I tried to build as well in Debug Win32 mode. Again I kept the default settings and just added the path and file name of the DLL under 'Import libraries'.

Code:
PROGRAM MAIN
!DEC$ ATTRIBUTES DLLIMPORT :: HELLO

CALL HELLO

END PROGRAM MAIN


However the compilation failed with the following error message:

Quote:
Project Build
/////////////

C:\Users\christoph\Documents\Silverfrost FTN95 Express\Projects\FortranEXE\FortranEXE\main.f95

Compiling...

Compiling file: main.f95
FTN95.EXE "C:\Users\christoph\Documents\Silverfrost FTN95 Express\Projects\FortranEXE\FortranEXE\main.f95" /NO_BANNER /DEBUG /FULL_DEBUG /P6 /IMPORT_LIB C:\Users\christoph\Documents\Silverfrost FTN95 Express\Projects\FortranDLL\FortranDLL\Debug\Win32\FortranDLL.dll /FPP/REF "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll" /REF "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll" /REF "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.XML.dll" /VS8 /DELETE_OBJ_ON_ERROR /ERROR_NUMBERS /UNLIMITED_ERRORS /BINARY "Debug\Win32\main.obj"
Compiler output:
*** More than one source file specified with names
C:\Users\christoph\Documents\Silverfrost FTN95
Express\Projects\FortranEXE\FortranEXE\main.f95 and FTN95
1 ERROR [C:\Users\christoph\Documents\Silverfrost FTN95 Express\Projects\FortranEXE\FortranEXE\main.f95 FTN95 5.40.0] - Compilation failed.

There were compile errors, no link performed


FortranEXE build failed.

/////////////////////////////////////


I can't figure out the problem, so any hint would be appreciated.

Thanks and best regards
Christoph
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Aug 06, 2014 10:23 pm    Post subject: Reply with quote

I don't know exactly what is going wrong but the command line for the main program looks odd.

It references .NET libraries when apparently you are not using .NET.
Also IMPORT_LIB should not appear if you are using FTN95 to create the DLL.
Back to top
View user's profile Send private message AIM Address
christoph81



Joined: 05 Aug 2014
Posts: 4

PostPosted: Thu Aug 07, 2014 6:58 pm    Post subject: Reply with quote

Perhaps I should remark that I create DLL and main program in different solutions. So I thought I've to tell the compiler where to find the DLL and added its path in the project settings under Source -> Import libraries (I just found out that this should be done only for libraries created with CVF ?)

However when I try to build the main program without that the follwing error message appears:

Quote:
Project Build
/////////////

C:\Users\christoph\Documents\Silverfrost FTN95 Express\Projects\FortranEXE\FortranEXE\main.f95

Compiling...

Compiling file: main.f95
FTN95.EXE "C:\Users\christoph\Documents\Silverfrost FTN95 Express\Projects\FortranEXE\FortranEXE\main.f95" /NO_BANNER /DEBUG /FULL_DEBUG /P6 /FPP/REF "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll" /REF "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll" /REF "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.XML.dll" /VS8 /DELETE_OBJ_ON_ERROR /ERROR_NUMBERS /UNLIMITED_ERRORS /BINARY "Debug\Win32\main.obj"

Linking...

Command line for link:
slink.exe -OUT:"Debug\Win32\FortranEXE.exe" @"C:\Users\christoph\Documents\Silverfrost FTN95 Express\Projects\FortranEXE\FortranEXE\link.lst" "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll" "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll" "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.XML.dll"
Linker output:
WARNING the following symbols are missing:
HELLO C:\Users\christoph\Documents\Silverfrost FTN95 Express\Projects\FortranEXE\FortranEXE\Debug\Win32\main.obj
(C:\USERS\CHRISTOPH\DOCUMENTS\SILVERFROST FTN95 EXPRESS\PROJECTS\FORTRANEXE\FORTRANEXE\MAIN.F95)
Creating executable: Debug\Win32\FortranEXE.exe


FortranEXE build succeeded.

/////////////////////////////////////


After copying the DLL into the directory of the executable and running the program I get the following error message:

Quote:
Run-time Error
*** Error 29, Call to missing routine : _HELLO at 0x00401021.

main - in file main.f95 at line 4 [+0026][recur= 1]


It's not clear for me if / how I have to define the location of the DLL in the project settings.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Thu Aug 07, 2014 7:23 pm    Post subject: Reply with quote

You should be able to put two projects into one "solution" and make one dependent on the other.

They should both be Win32 or both .NET., not a mix.
Back to top
View user's profile Send private message AIM Address
christoph81



Joined: 05 Aug 2014
Posts: 4

PostPosted: Fri Aug 08, 2014 6:19 pm    Post subject: Reply with quote

I created a solution containing both projects and made the main program dependent on the DLL. Both are Debug Win32. Anyway I get the warning messages and the run-time error occurs.

Quote:
------ Build started: Project: FortranApplicationExtension1, Configuration: Debug Win32 ------
Building project FortranApplicationExtension1...
Updating References...
Compiling file: hello.f95
Linking...
WARNING - Default LibMain being provided
Creating dynamic link library: Debug\Win32\FortranApplicationExtension1.dll

Build log saved at: "file://C:\Users\christoph\Documents\Silverfrost FTN95 Express\Projects\Solution1\FortranApplicationExtension1\Debug\Win32\buildlog.txt"
FortranApplicationExtension1 build succeeded.
------ Build started: Project: FortranApplication1, Configuration: Debug Win32 ------
Building project FortranApplication1...
Updating References...
Compiling file: main.f95
Linking...
WARNING the following symbols are missing:
HELLO C:\Users\christoph\Documents\Silverfrost FTN95 Express\Projects\Solution1\FortranApplication1\Debug\Win32\main.obj
(C:\USERS\CHRISTOPH\DOCUMENTS\SILVERFROST FTN95 EXPRESS\PROJECTS\SOLUTION1\FORTRANAPPLICATION1\MAIN.F95)
Creating executable: Debug\Win32\FortranApplication1.exe

Build log saved at: "file://C:\Users\christoph\Documents\Silverfrost FTN95 Express\Projects\Solution1\FortranApplication1\Debug\Win32\buildlog.txt"
FortranApplication1 build succeeded.
========== Build: 2 succeeded or up-to-date, 0 failed, 0 skipped ==========


I also switched the configuration to Debug .Net but that didn't work either.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Fri Aug 08, 2014 8:22 pm    Post subject: Reply with quote

This looks better. Now you need to find a way to reference the DLL when linking the exe.
Back to top
View user's profile Send private message AIM Address
christoph81



Joined: 05 Aug 2014
Posts: 4

PostPosted: Sat Aug 09, 2014 7:12 pm    Post subject: Reply with quote

Ok, I think my main mistake was that I didn't add the dll to the references of the main program. Now I'm able to build and run the program.

But when I tried to debug the application the debugging is interrupted and exits without any error message. So I went one step back (building both projects in two different solutions) and the debugging of the "stand alone application" works without any problems.

Do I have to specify something in the debug options when handling both projects in the same solution? I couldn't find that point in the documentation.

Thanks a lot for your support so far, Paul. I'm aware that are very basic questions.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sun Aug 10, 2014 8:44 am    Post subject: Reply with quote

Quote:
Do I have to specify something in the debug options when handling both projects in the same solution?


Not that I know of.
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