View previous topic :: View next topic |
Author |
Message |
clint
Joined: 14 Jun 2006 Posts: 37
|
Posted: Fri Jun 16, 2006 10:40 am Post subject: linking with C++ DLLs |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7938 Location: Salford, UK
|
Posted: Sat Jun 17, 2006 1:21 am Post subject: linking with C++ DLLs |
|
|
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 |
|
|
clint
Joined: 14 Jun 2006 Posts: 37
|
Posted: Mon Jun 19, 2006 3:20 am Post subject: linking with C++ DLLs |
|
|
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 |
|
|
clint
Joined: 14 Jun 2006 Posts: 37
|
Posted: Mon Jun 19, 2006 5:52 am Post subject: linking with C++ DLLs |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7938 Location: Salford, UK
|
Posted: Tue Jun 20, 2006 12:48 am Post subject: linking with C++ DLLs |
|
|
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 |
|
|
|