Silverfrost Forums

Welcome to our forums

How to Launch a ftn95 DLL from QT

4 Dec 2018 4:05 #22933

Hello together,

I currently look for possibilities to change from our old Compaq Visual Fortran compiler to FTN95. Our current Compaq project is the calculating core for a different software and therefor results in a DLL, which is then called from QT. Exactly here is now my problem: With our old Compaq visual Fortran compiler we could call the functions and declare the attributes as shown below.

SUBROUTINE cctdll(n,m,error,iarray,oarray,ebarray,ebtarray,fanarray,Textarray)

! Expose subroutine cctdll to users of this DLL
!

!DEC$ ATTRIBUTES C, REFERENCE, DLLEXPORT, ALIAS : 'CALC' :: CCTDLL

Now with the new compiler (FTN95) QT cannot find the functions/Subs anymore and gives the unresolved external symbol error.

Cannot resolve symbol 'CALC' in cctcalc.dll:cctcalc.dll

Is there anyone that has experiences with this mix of languages and can help me find the problem? Is it me or the compiler? Just for information here is the call from QT that worked so far.

		// Now call Fortran
		
		QLibrary myLib('cctcalc.dll');
		
		typedef int (*MyPrototype)(int, int, int*, double*, double*, double*, double*, double*, char* );
		
		MyPrototype myFunction = (MyPrototype) myLib.resolve('CALC');

Thank you for your help, I am quite new to Fortran and might ask some silly questions, don´t blame me for this 😛

QTran

4 Dec 2018 6:03 #22934

Basic information can be found in ftn95.chm under Win32 platform->Mixed language programming->Calling C/C++ from FTN95.

You will need to find out whether to use C_EXTERANL or STDCALL. After that the interfaces for the two protocols are the same.

25 Mar 2019 12:59 #23392

Hello,

after some time I figured out how to export the respective routines to my Library. But how can I tell the compiler now to Declare it as a C - Style function what was done before with this line?

! Expose subroutine cctdll to users of this DLL !

!DEC$ ATTRIBUTES C, REFERENCE, DLLEXPORT, ALIAS : 'CALC' :: CCTDLL

If anyone could help me, this would be very nice.

Than you in advance

25 Mar 2019 3:28 #23394

If you are creating a 32 bit DLL then you will use SLINK to do the linking process.

SLINK has an 'exportall' command that simply exports all routines. Otherwise you can list the routines to export.

If you have to create an alias then this must be done via SLINK commands and details can be found in ftn95.chm. Otherwise you could use the original names for the routines and change the QT code accordingly.

Please login to reply.