- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a program that was compiled in IFC. I am using a new licensing software program that creates a dll that needs to be integrated into my code. How do I integrate the dll into my code, so that it know it has to have that dll in order to run?
Link Copied
18 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unless you manage the loading and unloading of DLLs in your program, the standard approach is to use the export library that is built along with the DLL. Link your application with the export library, and the dependency on the DLL will be embedded in your EXE.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
THe dll is provided to me after I go onto a website and create the licensing scheme that I want. I do not have a .lib file. THey say that I need to integrate the dll into my program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i think what they mean for you to do isto add the dll to the resouce section of your solution/project.
Then when you compile/link (hopefully) anycalls to the dll will be resolved.
Then when you compile/link (hopefully) anycalls to the dll will be resolved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, that won't work. You can't link against a DLL directly.
What is needed here is to use the Windows API routines LoadLibrary and GetProcAddr to load the DLL, look up the routines, and then call the routines through pointers. There is an example of this in the sample DLL\DynamicLoad. You will need to know if the routines being called expect the STDCALL calling mechanism.
What is needed here is to use the Windows API routines LoadLibrary and GetProcAddr to load the DLL, look up the routines, and then call the routines through pointers. There is an example of this in the sample DLL\DynamicLoad. You will need to know if the routines being called expect the STDCALL calling mechanism.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Like this, cause it does not work.
relap5$(NM).exe : lib\envrl$(NM).lib lib\graphics.lib \
lib\matpro$(NM).lib lib\relap$(NM).lib relap\relap5.$O \
lib\scdap$(NM).lib tpfh2o$(NM) tpfd2o$(NM) lib\filechk.dll
relap5$(NM).exe : lib\envrl$(NM).lib lib\graphics.lib \ lib\matpro$(NM).lib lib\relap$(NM).lib relap\relap5.$O \ lib\scdap$(NM).lib tpfh2o$(NM) tpfd2o$(NM) lib\filechk.dll$(f90) -nologo $(FFLAGS) $(FPSTOP) $(FL) -libs:qwin \
relap\relap5.$O lib\relap$(NM).lib lib\scdap$(NM).lib \
lib\matpro$(NM).lib lib\relap5l.lib \
lib\envrl$(NM).lib lib\graphics.lib \
lib\libifcoremt.lib lib\libifport.lib lib\libifcoremt.lib \
lib\libifport.lib lib\libmmt.lib lib\kernel32.lib \
lib\ifqwin.lib gdi32.lib lib\user32.lib lib\libirc.lib \
comdlg32.lib ifqw_mdi.lib lib\libcmt.lib lib\imagehlp.lib \
lib\opengl32.lib lib\glu32.lib lib\f90gl.lib lib\f90glu.lib \
lib\f90glut.lib lib\glut32.lib \
-link -out:bin\relap5.exe -heap:1000000000 -stack:14000000 \
-incremental:no -nodefaultlib
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No - that doesn't work. See my reply just before yours.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sample showing how to associate a DLL into F90:
hMapiLib is INTEGER(HANDLE) and module-local.
[bash]LOGICAL FUNCTION MAPIBind() result (bOK) USE kernel32, only: LoadLibrary, GetProcAddress ! was dfwin hMapiLib = LoadLibrary("mapi32.dll"C) IF (hMapiLib /= 0) THEN bOK = .true. lpMAPIInitialize= GetProcAddress(hMapiLib,"MAPIInitialize"C) bOK = bOK .AND. (lpMAPIInitialize /= 0) lpMAPIUninitialize= GetProcAddress(hMapiLib,"MAPIUninitialize"C) bOK = bOK .AND. (lpMAPIUninitialize /= 0) lpMAPILogon = GetProcAddress(hMapiLib,"MAPILogon"C) bOK = bOK .AND. (lpMAPILogon /= 0) !... and many more END IF END FUNCTION MAPIBind SUBROUTINE MAPIUnBind() USE kernel32, only: FreeLibrary ! was dfwin INTEGER :: rval IF (hMapiLib /= 0) rval = FreeLibrary(hMapiLib) END SUBROUTINE MAPIUnBind [/bash]
hMapiLib is INTEGER(HANDLE) and module-local.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does it help if I got the .lib file associated with the dll?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not really a fortran programmer. I just handle the licensing and protection of the software. Our main programmer is out of town and I cannot reach him.
Our previous licensing software was easier, but limited to windows. Our new licensing software that we are trying out works on Windows, Mac, and Linux. The coding that you provided means nothing to me. Is there someway with the .lib and the .dll file that we can make this work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you have the lib, yes. You can try this.... Attached to this post is a ZIP file containing MAKILIB.EXE. Extract this to a folder containing the DLL. Open a command prompt window and set default (CD) to that folder. Type:
makilib yourdll.dll
This will create a .lib that can be linked with your program. You will still need to know how to call the routines - I assume the vendor documents that.
makilib yourdll.dll
This will create a .lib that can be linked with your program. You will still need to know how to call the routines - I assume the vendor documents that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I got the list of the calls.
FUNCTION CALLS
Function Call | Parameters | Description |
Main Function Calls | ||
CheckLicense | long *RandomNumber | Multipurpose license status evaluation |
AuditLicense | long *RandomNumber | Gets license status without X, Y and Z valuesNOTE:Do not use this in place ofCheckLicense. |
ValidateDLL | long *CustomerNumber, long *ProductNumber, long *ParmValue | Validate custom dll for Customer ID, Product ID and X, Y and Z authentication constants. |
InstallLicense | char *szUnlockCode | Updates the table with new program status |
InternetActivate | char *szLicenseCode, char *szpProxyPort, long PortNumber | Activates license using the server |
ReturnLicense | char *szLicenseCode, char *szpProxyPort, long PortNumber | Removes license and returns this to the server |
RemoveLicense | char *szpRemovalCode | Removes license from computer and returns proof of removal code. |
ExportLicense | char *szLicenseCode, char *szpReturnCode | Removes license from computer and returns a deactivation certificate that can be used to manully return the license to the server |
Uses, Module, Expiry Date function calls | ||
ViewUses | long *UsesNum | Returns the number of uses left in the specified counter. |
SubtractUses | long *Uses, long *UsesNum | Subtracts passed number from uses number. |
CheckFlags | long *ModuleNumber | Returns the contents of the flag table entry |
ViewExpirationDate | long *Month, long *Day, long *Year | Returns the expiration date |
GetGeneralPurpose | long *Value | Gets the General Purpose Value; this is described in the manual as theCustomer Data field |
PutGeneralPurpose | long *Value, long *RandomNumber, long *Checksum | Stores the General Purpose Value; this is described in the manual as theCustomer Data field |
StartDemo | wchar_t *szMessage, wchar_t * szCaption | Demo Minutes Start with demo end message |
EndDemo | None | Stop using up demo minutes. |
UpdateTime | None | Updates to the hard drive the number of minutes left in the evaluation period. |
ViewTime | None | Returns the number of minutes left, as an integer. |
StartDemoAdvanced | char *szProcessPath | Same as StartDemo, except runs whatever application is pointed to by the path name passed as a parameter. |
ID function calls | ||
GetComputerID | char *szpComputerID | Returns unique 20-character ID for computer |
DisplayInstallationID | char *szCodeInfo | Returns 12- or 32-character transaction ID |
Miscellaneous function calls | ||
DisplayVersion | None | Displays Nalpeiron copyright notice and version number |
ReturnVersion | None | Returns the version number as a 3 digit number i.e. 5.0.4 returns 504 |
EnterAuthenticationInformation | const char *szpProxyUsername, const char *szpProxyPassword | Enables basic http proxy authentication for functions that contact the server(version 5.9.3 or later) |
GetActivationMethod | None | Returns the method that was used to activate the product(version 5.9.3 or later) |
WaitForFinish | None | Suspends the thread until all threads spawned by the DLL have terminated(version 5.9.3 or later) |
ReturnServiceVersion | None | It returns a 3 digit number representing the service version. For example, service version 6.5.8 is returned as 658.Only available for Windows x86/x64 filechk DLLs with a version number of 6.5.8+. |
License Transfer to Media function calls | ||
InitializeMedia | char *szDriveLetter | Used by move license |
RemoveToMedia | char *szDriveLetter | Used by move license |
InstallFromMedia | char *szDriveLetter | Used by move license |
Service function calls | ||
StartTheService | None | Starts the service(version 6) |
StopTheService | None | Stops the service(version 6) |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Because of the mixed-case names, you'll need to either use !DEC$ ATTRIBUTES ALIAS, or preferably, interfaces with BIND(C) to declare these. The C interoperability features will help.
This is how you'd start out:
This is how you'd start out:
[fortran]module LicenseCheckMod use, intrinsic :: iso_c_binding implicit none interface function CheckLicense (RandomNumber) BIND(C,NAME="CheckLicense") import integer(C_LONG) :: CheckLicense integer(C_LONG) :: RandomNumber end function CheckLicense ... end interface[/fortran]You would have to pay attention to those functions that accept arguments by value, such as PortNumber in ReturnLicense, and add the VALUE attribute. Character string arguments should be declared as CHARACTER, DIMENSION(*).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I using a 64bit version of the licensing dll now and when I use the makilib file this is the message that I get:
d:\iss_relap\rs35\rs35dg64.intl\lib>MAKILIB filechck.dll
Processing: d:\iss_relap\rs35\rs35dg64.intl\lib\filechck.dll
?No .rdata section in filechck.dll?
d:\iss_relap\rs35\rs35dg64.intl\lib>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is likely that makilib does not know how to handle a 64-bit DLL. Using dynamic loading would be my recommendation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How do I use dynamic loading?
I am trying to create a def file and then a lib file using the lib.exe tool.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You use the Windows API routines LoadLibrary and GetProcAddress. This gives you the address of a routine in the DLL and you can use either the integer pointer extension or convert it from a C_FUNPTR to a Fortran procedure pointer and call it. See the DLL\DynamicLoad sample for an example of this.
The way I would handle it is, at the beginning of the program, call LoadLibrary on the DLL and then use a series of GetProcAddress calls to fill in procedure pointers in a module. Then the rest of the program can call through the procedure pointers.
The way I would handle it is, at the beginning of the program, call LoadLibrary on the DLL and then use a series of GetProcAddress calls to fill in procedure pointers in a module. Then the rest of the program can call through the procedure pointers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Where do I find theDLL\DynamicLoad sample?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You will find a Samples folder in the compiler's top-level folder. For example:
C:\Program Files (x86)\Intel\Composer XE 2011 SP1\Samples
In the en_US\Fortran subfolder of this you will find DLL.zip. Unzip this to your desktop or another writable folder and you'll find DynamicLoad in there.
C:\Program Files (x86)\Intel\Composer XE 2011 SP1\Samples
In the en_US\Fortran subfolder of this you will find DLL.zip. Unzip this to your desktop or another writable folder and you'll find DynamicLoad in there.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page