Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Safenet Sentinel Hardware Keys

jirina
New Contributor I
1,253 Views

I would like to protect my application in Linux using Safenet Sentinel Hardware Keys (SHK). I am able to to create a sample program in C++ which communicates with the SHK correctly. This programs needs some special Sentinel libraries (.lib) and certain compiler and linker options. However, I am not able to use it in my Intel Fortran application. Does anybody have any experience with SHK in Intel Fortran under Linux? Unfortunately, sample programs from Safenet Sentinel are available only in ANSI C and Java in Linux.

0 Kudos
4 Replies
Steven_L_Intel1
Employee
1,253 Views

If it can be called from C, it can be called from Fortran. There may be some macros you have to untangle.

What specifically doesn't work?

0 Kudos
jirina
New Contributor I
1,253 Views

I went through the Intel Fortran documentation (the part dealing with mixing languages) and decided to try creating a static library in C++ named SHKLibraryFunctions.lib (*). To create this library, I used several .h files and SentinelKeys.lib from Safenet Sentinel. I had to specify additional dependencies: odbc32.lib odbccp32.lib wsock32.lib. There is just one function in the resulting library (*): extern "C" int CheckLicense ( ) { ... }

I tried creating a small console application in C++ to check whether I can use the function from the library and everything worked well (I added the library (*) as an additional dependency and called the function CheckLicense() to verify the required functionality).

However, I am not able to do the same in Intel Fortran. Primarily, I want to make this work in Linux. I added this to my source code:

[cpp]interface
integer*4 function CheckLicense ( )
!dec$ attributes C, decorate, alias: "CheckLicense" :: CheckLicense
end function
end interface[/cpp]

I then compiled my code with following options:

[cpp]ifort -fixed -extend_source 132 -openmp -fpscomp general -warn declarations -assume byterecl -align all -heap-arrays -static-intel -threads -c ...[/cpp]

After this stage with no error, I am trying to link:

[cpp]ifort -fixed -extend_source 132 -openmp -fpscomp general -warn declarations -assume byterecl -align all -heap-arrays -static-intel -threads ... (*.o files) -lSHKFunctionsLibrary.lib -o myapp.out[/cpp]

I am getting an error "undefined reference to 'CheckLicense'". Ronald Green adviced me to use 'nm' to examine the decoration of the symbol for CheckLicense and I got 'U CheckLicense'. Does it mean the symbol is undefined?

In addition, I tried using nm on (*) too, but I got an error 'file format not recognized'.

I tried to do the same in Windows and I am getting unresolved externals errors (LNK2019) in Windows. The main problem is that unresolved externals are reported to come from .obj files which are included in SentinelKeys.lib, i.e. something I cannot change or modify. Thus, the problem in Windows is different from the Linux one.

0 Kudos
Ron_Green
Moderator
1,253 Views
Quoting - jirina

I went through the Intel Fortran documentation (the part dealing with mixing languages) and decided to try creating a static library in C++ named SHKLibraryFunctions.lib (*). To create this library, I used several .h files and SentinelKeys.lib from Safenet Sentinel. I had to specify additional dependencies: odbc32.lib odbccp32.lib wsock32.lib. There is just one function in the resulting library (*): extern "C" int CheckLicense ( ) { ... }

I tried creating a small console application in C++ to check whether I can use the function from the library and everything worked well (I added the library (*) as an additional dependency and called the function CheckLicense() to verify the required functionality).

However, I am not able to do the same in Intel Fortran. Primarily, I want to make this work in Linux. I added this to my source code:

[cpp]interface
integer*4 function CheckLicense ( )
!dec$ attributes C, decorate, alias: "CheckLicense" :: CheckLicense
end function
end interface[/cpp]

I then compiled my code with following options:

[cpp]ifort -fixed -extend_source 132 -openmp -fpscomp general -warn declarations -assume byterecl -align all -heap-arrays -static-intel -threads -c ...[/cpp]

After this stage with no error, I am trying to link:

[cpp]ifort -fixed -extend_source 132 -openmp -fpscomp general -warn declarations -assume byterecl -align all -heap-arrays -static-intel -threads ... (*.o files) -lSHKFunctionsLibrary.lib -o myapp.out[/cpp]

I am getting an error "undefined reference to 'CheckLicense'". Ronald Green adviced me to use 'nm' to examine the decoration of the symbol for CheckLicense and I got 'U CheckLicense'. Does it mean the symbol is undefined?

In addition, I tried using nm on (*) too, but I got an error 'file format not recognized'.

I tried to do the same in Windows and I am getting unresolved externals errors (LNK2019) in Windows. The main problem is that unresolved externals are reported to come from .obj files which are included in SentinelKeys.lib, i.e. something I cannot change or modify. Thus, the problem in Windows is different from the Linux one.

You are correct, 'nm' reports "U CheckLicense" from your file because it is an undefined external reference. You will have to find a "Target" or as 'nm' will report "T CheckLicense" in one of the objects used in your final link. AND that target must have exactly the same upper/lower case and the same name WITHOUT any underscores for that symbol to be resolved.

But let's review: you added the Fortran interface, which is always the best thing to do. However, did you actually write the main code to implement CheckLicense? The interface alone will not create the target in the object. Even if you write a stub that does nothing but RETURN, you need to write the code for CheckLicense.

Until you get a target for CheckLicense, you will continue to get unresolved external references.

ron

0 Kudos
jirina
New Contributor I
1,253 Views

I added the Fortran interface for the function CheckLicense to let's say myApp.for. This function has been implemented in a C++ project which creates a static library (SHKFunctionsLibrary.lib). The function is declared to be 'extern "C" int CheckLicense ().

I thought that linking the static library and adding the interface would allow me to call the function somewhere in myApp.for. I checked the output from 'nm myApp.o' once more and found just 'U CheckLicense'. I am linking more object files, but I am not calling CheckLicense in any of them, so I think it does not make sense to search for 'T CheckLicense' in them right?

Thanks for your suggestions and ideas.

0 Kudos
Reply