Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28445 Discussions

Need help with C calling Fortran unresolved external symbol errors......

gregip1
Beginner
431 Views

I'm currently developing in the Microsoft Visual Studio .NET 2003 environment. I have this C application that calls a Fortran static library.When I goto compile the Fortran library, I get no errors and it creates .lib file. So when I goto compile and link the C program with the Fortran......to seems like it has troublelinking in the my Fortran library.

it generates a unresolved external symbol error LNK2019: _for_emit_diagnostic

That error seems to be a internal function that it is complaining about that I am not familiar with...... I'm thinking that it has to be some kind of switch or setting that I'm need to turn on or off in my properties setting in my project. I my properties settings for my C program I have the __cdecl(/Gd) "Calling Convention" set.

Any help would be deeply appreciated.......

0 Kudos
5 Replies
jimdempseyatthecove
Honored Contributor III
431 Views

I am not familiar with the internals of Intel Fortran. This being said, what this looks like is _for_emit_diagnostic is part of the Fortran Runtime Library. Your application is linking with the C Runtime Library (as it should). Perhaps you have a diagnostic switch set on the Fortran compiler (e.g. check for array subscrips out of range or un-initialized variable check). If incompatible option then you will either a) have to compile the Fortran code without this option, or b) locate the fortran library that contains _for_emit_diagnostic and include that in your link (then include anything that come in as a requirement of _for_emit_diagnostic, ...)

Jim Dempsey

0 Kudos
gregip1
Beginner
431 Views

Jim,

Thanks for the info, I set the "check array and string bound" switch to no in my fortran project settings.... and that solved the problem with the _for_emit_diagnostic unresolved external, but now I have another unresolved external. Its complaining about my "GETENV" function that I call in myFortran library when my C program goes to link.I have the "USE IFPORT" statement in my fortran code for the "GETENV" function..... Am I missing here?

Thanks,

Greg

0 Kudos
TimP
Honored Contributor III
431 Views
getenv isn't standard Fortran. That's why it's included in IFPORT and requires one of the libifport*.lib for linking. You could use tools such as dumpbin, nm, or strings to check which .lib file you need to resolve a symbol.
0 Kudos
gregip1
Beginner
431 Views

tim,

thanks for the info..... Before I mademy previouspost, I looked in the IVF help about IFPORT and its associated it with "ifport.lib"....so I lookedin the Fortron lib directory for it and noticed that it was not there...to busy concentrating on"ifport.lib"....I did not bother to look for "libifport.lib".....so that's when I decided to make the post.....Ihave to try this first thingnext week.....

Have a good fourth......

Greg

0 Kudos
Steven_L_Intel1
Employee
431 Views
Two things you need to do:

1. In the Fortran project, go to the Libraries property page and set the property Disable Default Library Search Rules to "No".
2. In Tools..Options.. Projects.. VC++ Directories, add the path to the Intel Fortran IA32LIB folder to the list for Library files.

Rebuild the solution.
0 Kudos
Reply