Using a c plus plus file in fortran coding

Using a c plus plus file in fortran coding

Our code is written in Fortran and we have added some licensing to it.  The way I added it is not realy working well, so I am using there source for licensing.  It is written in C ++ and whenI compile our code with their source I get all kinds of errors about the c++ file.  How can I make the c++ file work with my Fotran.  It also came with a .h file written in C++.

9 帖子 / 0 全新
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项

First of all, you need a C++ compiler - at a minimum, Microsoft Visual C++. Then you have to create a separate C++ static library project containing the C++ source and the .h file. Set the C++ project's Code Generation > Runtime Library property to match what you have for Fortran > Libraries > Use Runtime Library.  Right click on the Fortran project and select Dependencies.  Make the C++ project a dependent of the Fortran project.

Steve - Intel Developer Support

So this is the only time we will use C++.  Would someone with C++ compiler want to comile my two files for me?

Also I compile everyting from the command line.  I do not use Visual Studio to compile.  

This is the libraries I use in my fortran when compiling: 

$(f90) -nologo $(FFLAGS) $(FPSTOP) $(FL) -libs:qwin \
$(r)\$(r)5.$O lib\$(r)$(NM).lib lib\$(s)$(NM).lib \
lib\$(m)$(NM).lib lib\filechck.lib lib\$(e)$(NM).lib \
lib\graphics.lib libmmt.lib kernel32.lib ifqwin.lib gdi32.lib \
libifcoremt.lib libifport.lib \
user32.lib libirc.lib comdlg32.lib ifqw_mdi.lib libcmt.lib \
imagehlp.lib opengl32.lib glu32.lib lib\f90gl.lib lib\f90glu.lib \
lib\f90glut.lib lib\glut32.lib -link -out:$(r)5d.exe -nodefaultlib

You can download Visual Studio 2012 Express for free. It would be inappropriate for someone else to compile this for you. From the Visual C++ command line, use:

cl /c /MT yourfile.cpp

and then add the resulting .obj to your list of object files.

Steve - Intel Developer Support

Ok so i got the obj file made but what do I do with the .h file?  I have a call in one of my source files that goes to the c++ .h file.  I put an include statement in the .f90 file, but I get errors related to the  c++ .h file.

I'm going to guess that the .h file is meant to define the interface to the licensing API. It can be used only for C/C++ and has to be translated to Fortran. If you'll attach the .h file to a post here and tell me which routines you use, I'll see what I can do.

Steve - Intel Developer Support

Well in my code I make a call to CheckAuthorization.  then it looks to the .h file and to the filechck.dll file wich contains the licensing.

附件: 

附件尺寸
下载 copyprotection.h10.41 KB

Compile the attached source along with your Fortran files - it needs to be compiled before any others. Then add the line:

use copyprotection

following the program, subroutine or function statement wherever you want to call one of these routines.

Make sure that any strings you pass have NUL termination.

The source here compiles and I think it is correct.

附件: 

附件尺寸
下载 copyprotection.f9018.87 KB
Steve - Intel Developer Support

Thank you so much, I will download and try it.

发表评论

登录添加评论。还不是成员?立即加入