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 

linking with C++ DLLs

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



Joined: 14 Jun 2006
Posts: 37

PostPosted: Fri Jun 16, 2006 10:40 am    Post subject: linking with C++ DLLs Reply with quote

Does anyone know the answer to the following?

I have a created a FNT99 DLL (f95fun.dll) that calls functions in a C++ DLL (say cppfun.dll).


Compiler SWITCHES: /IMPORT_LIBcppfun.lib
(associated lib for the dll produced by VisualC++7)

Linker SWITCHES: -EXPORTALL


I have no compilation errors but the following run-time error:
"The procedure entry point __adjust_stack_f could not be located in the dynamic link library salflibc.dll"


cppfun.lib has a function

__imp__CloseFile@0

(i.e. a DLL import void function)

this has been declared in the fortran include as
stdcall CloseFile 'CloseFile' (val): integer*4

The linker complains:
Linking...
WARNING - Default LibMain being provided
WARNING the following symbols are missing:
Closefile


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


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

PostPosted: Sat Jun 17, 2006 1:21 am    Post subject: linking with C++ DLLs Reply with quote

Clint

If your code will compile with the Salford C++ compiler SCC then you will find it easier to use alongside FTN95. Also if only minor changes are required to make it compile with SCC then it is better to make these changes. You can create an SCC DLL from Plato and then create a reference to it in another project. The easiest approach is to use extern "C" rather than STDCALL in your C++ and to interface using C_EXTERNAL in your Fortran.

If you end up using Visual C++ then you should not use /IMPORT_LIB which is for Fortran DLLs.
There is a section on STDCALL (and importing from a STDCALL C++ DLL ) in the help file which you will need to work through.

Basically you need to create your own header files that are like win32api.ins etc.
Once you have these interfaces, you can link in the ordinary way. You can create a reference to the DLL in Plato but initially I would try leave the STDCALL switch (in the Reference properties) switched off because (if my memory serves me correctly) this switch is equivalent to using /IMPORT_LIB. I can check out the details if you have problems at this point.

You may need to check out my comments by looking in the help file but basically you need to work through the section in the help file that describes how to import a C/C++ DLL using either C_EXTERNAL or STDCALL interfaces.
Back to top
View user's profile Send private message AIM Address
clint



Joined: 14 Jun 2006
Posts: 37

PostPosted: Mon Jun 19, 2006 3:20 am    Post subject: linking with C++ DLLs Reply with quote

Thanks Paul,

The problem is that I need to use DLLs that have been generated by other projects using MS VC7 and produce further DLLs.

Unfortunately, searching for "STDCALL C++ DLL" in the salford help produced only 2 results:
Calling FTN95 DLL from Visual Basic
Comment Embedded directives.

The PDF files from the download are both F77 manuals and so it would be very helpful to get the FTN95 manuals.

cheers
Clint
Back to top
View user's profile Send private message
clint



Joined: 14 Jun 2006
Posts: 37

PostPosted: Mon Jun 19, 2006 5:52 am    Post subject: linking with C++ DLLs Reply with quote

The solution is to include the C++ DLL (cppfun.dll) in the slink.

Code:
slink.exe -OUT:"DebugWin32experiment.exe" DebugWin32test.obj cppfun.dll


How do you achieve this when integrated with Visual Studio or Plato? (Instead of editing link.lst by hand or manually calling slink)

How do you get the salford compiler to produce a lib file for other compilers what cannot extract the information directly from a DLL?

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


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

PostPosted: Tue Jun 20, 2006 12:48 am    Post subject: linking with C++ DLLs Reply with quote

Clint

You can access a DLL from Visual Studio or Plato by creating a Reference to it from the Project/Solution Explorer window (I assume that this information is in the "Getting started" sections of the help file).

To create a library archive, create a project for a DLL and then change its type (in the Project Properties) to a .LIB.
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