Object file compatibility

Object file compatibility

Are object/library files created with VS 2010 compatible with those created by VS 2005?

I am using Intel Fortran 11.0.075, for which I must use VS 2005.  I would like to use VS 2010 to compile C code that I will link to the Fortran.  My first attempts at linking  .lib files generated with the VS 2010 C compiler with my Fortran object file gives me a cryptic error:

Error    1    fatal error C1007 unrecognized flag '-typedil' in 'p2'        

I'm guessing that this results from the different VS versions.  Is there a way to get around this?



9 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

You may try linking with the newer linker (i.e, the one that came with VS 2010). If, as I suspect, you compiled the C source files into .OBJ files and then used your IFort 11.0.075 and VS 2005 setup to compile the Fortran parts and link, the old linker that came with VS 2005 may not recognize all the components of the .OBJ file created by the 2010 C compiler.

Thanks. I just tried that in the VS 2010 IVF console, and got this error:

LINK : fatal error LNK1104: cannot open file 'ifconsol.lib'

Do I need to tell the linker where the Fortran libraries are? If so, can you show me please how to do this at the command line.

I found out how to do this, and the linking proceeds past the point where the previous error occurred. One down.
I have now run into a different sort of problem, which you might also be able to help me with.
One C library contains calls to a couple of external functions, which are subroutines in the Fortran code. The linker is not finding these, e.g.:

cvReactDiff_bnd.lib(cvReactDiff_bnd.obj) : error LNK2001: unresolved external symbol _ReactJac

Maybe it's a naming issue. Should I define an interface to a Fortran subroutine that will be called from the C side?


On the naming issue, I see from dumpbin that the Fortran subroutine has the name _reactjac, while the linker is looking for _ReactJac. By changing the names in the C code to all lower case the link is successful! This is progress. (The program crashes, but that's another story.)

I'm wondering if there is a way to control the symbol naming in the interface, or are the subroutine names automatically converted to lower case.


There are Fortran compiler switches to control how external names are decorated -- see the /names: switch and the three possible arguments to the switch: as_is, lowercase, uppercase.

For more elaborate renaming, and specifying how subprogram arguments are to be passed, there are DEC$ directives to help. See the Mixed Language Programming chapter in the compiler User Guide.

Does your Fortran procedure have the BIND(C) attribute in its definition? If so, by default the binding name is lower case. You can use the optional NAME='xxx' part of that suffix to get specific about the case of the binding label. I do this always regardless of what case I want, simply because I can never remember what the default case is.

(If you are calling the procedure from C and the Fortran procedure doesn't have the BIND(C) attribute, then go and sit in the naughty corner.)

Yes Ian, I am using bind(C). NAME='xxx' is what I want, thanks.

Now another interesting situation has arisen (Fortran-C interoperation is such fun!). On the C side a function allocates two arrays A and B then calls the Fortran subroutine React(A,B) multiple times and successfully. Before returning the function frees the two arrays, and this causes the program to crash with access violation. If I change the C code to make the arrays non-allocated (I forget the right term) the program runs without crashing. Why does the Fortran side care what happens to the arrays A and B?

Found my very basic error: I forgot that the arrays that are 0-based in C need to be 1-based in Fortran. It's all working now.

Hi Dears
I have an object file (.OBJ) and 3 fortran files (.FOR).
The Object file is a solver which should be linked those 3 files.
How can i link those 3 files to the object file in Intel Visual FORTRAN? I use Visual studio 2008.

The simple way is to add the .OBJ file to the list of source files in Visual Studio - you can just drag and drop it on "Source Files" if you want. But you need to know which compiler compiled this object and what requirements it has for run-time libraries. If it was from any other Fortran compiler, you can't use it.

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today