Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26758 Discussions

how to solve the problem <unresolved symbol __imp____iob_func> when VS2015 links the lib built before in fortran

Li_L_
New Contributor I
2,266 Views

i read many posts about this problems like 

http://stackoverflow.com/questions/30412951/unresolved-external-symbol-imp-fprintf-and-imp-iob-func-...

and i got the solutions based on C++ : put the words in the C++ script

FILE _iob[] = { *stdin, *stdout, *stderr }; 
extern "C" FILE * __cdecl __iob_func(void) { return _iob; }
for some reasons i can't rebuild the libs with vs2015 and all of my code is fortran
so is there any solutions about this problem with intel fortran 2017
 
BTW, actually i tried to build the above code as a lib with the VC++.
but it doesn't work after linking that lib.
I wonder my poor C++ knowledge leads this situation
so a detailed mix-language solution is welcome

 

0 Kudos
1 Solution
Steven_L_Intel1
Employee
2,266 Views

I think this problem is caused by an incompatibility Microsoft introduced in Visual C++ for VS2015. Objects compiled with earlier versions of Visual C++ can't link with the VS2015 static libraries (and vice versa). Intel Visual Fortran works around this in a rather complicated way as far as the Fortran library is concerned, but this doesn't help with C/C++ sources that make direct references to C library globals. 

If you can't recompile all the C/C++ code in the newer Visual C++, then the only thing I can suggest is to back off to VS2013 if you can. This is not an Intel Fortran problem. Note that unlike Intel Fortran, Microsoft Visual C++ generates different object code depending on your setting of the run-time library selection.

View solution in original post

7 Replies
mecej4
Black Belt
2,266 Views

You probably have some OBJ files that were compiled with /MD and some with /MT (or /libs:static and /libs:dll or equivalent directives in your code). As a result, some of the code expects to be linked with one version of the RTL (run time library) and the rest expects another version. Or, you have some third party library that you are using which expects one RTL and your code the other.

Find out what your third party library expects, and recompile to match. If you do not use such a library, simply recompile all your sources with the same compiler options and build.

You do not need to write C++ code in an attempt to solve the problem.

Li_L_
New Contributor I
2,266 Views

mecej4 wrote:

You probably have some OBJ files that were compiled with /MD and some with /MT (or /libs:static and /libs:dll or equivalent directives in your code). As a result, some of the code expects to be linked with one version of the RTL (run time library) and the rest expects another version. Or, you have some third party library that you are using which expects one RTL and your code the other.

Find out what your third party library expects, and recompile to match. If you do not use such a library, simply recompile all your sources with the same compiler options and build.

You do not need to write C++ code in an attempt to solve the problem.

although i really doesn't want to recompile the third library, i think i have to do that after reading you suggestions

anyway thank you for your detailed explanation

i learned much!

mecej4
Black Belt
2,266 Views

You don't have to recompile the third party library, even if you have the source code for it, unless you deliberately decide that it is beneficial to do so.

Simply find out what option was used when the library was built, and simply use that option when compiling your code and linking with the library. Usually, the documentation that came with the library will clearly state what you need to do to use the library with your code.

Steven_L_Intel1
Employee
2,267 Views

I think this problem is caused by an incompatibility Microsoft introduced in Visual C++ for VS2015. Objects compiled with earlier versions of Visual C++ can't link with the VS2015 static libraries (and vice versa). Intel Visual Fortran works around this in a rather complicated way as far as the Fortran library is concerned, but this doesn't help with C/C++ sources that make direct references to C library globals. 

If you can't recompile all the C/C++ code in the newer Visual C++, then the only thing I can suggest is to back off to VS2013 if you can. This is not an Intel Fortran problem. Note that unlike Intel Fortran, Microsoft Visual C++ generates different object code depending on your setting of the run-time library selection.

View solution in original post

Li_L_
New Contributor I
2,266 Views
Steve Lionel (Intel) wrote:

I think this problem is caused by an incompatibility Microsoft introduced in Visual C++ for VS2015. Objects compiled with earlier versions of Visual C++ can't link with the VS2015 static libraries (and vice versa). Intel Visual Fortran works around this in a rather complicated way as far as the Fortran library is concerned, but this doesn't help with C/C++ sources that make direct references to C library globals. 

If you can't recompile all the C/C++ code in the newer Visual C++, then the only thing I can suggest is to back off to VS2013 if you can. This is not an Intel Fortran problem. Note that unlike Intel Fortran, Microsoft Visual C++ generates different object code depending on your setting of the run-time library selection.

i have decided to embrace the future and started the big compiling work. thank you for your suggestion!
Andrew_Smith
New Contributor III
2,266 Views

I had this same issue with the old IMSL libary. I use this code in VS2015 compiled as an object library linked into my Fortran exe:

#include "stdio.h"
extern "C" { FILE _iob[3] = {__acrt_iob_func(0), __acrt_iob_func(1), __acrt_iob_func(2)}; }

Li_L_
New Contributor I
2,266 Views

Andrew Smith wrote:

I had this same issue with the old IMSL libary. I use this code in VS2015 compiled as an object library linked into my Fortran exe:

#include "stdio.h"
extern "C" { FILE _iob[3] = {__acrt_iob_func(0), __acrt_iob_func(1), __acrt_iob_func(2)}; }

oh, i got it!

i failed with the code you paste, but i succeeded with mine

 

ps: it takes me much time to understand the .pch in vc++ project and disable it

 

 

Reply