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

Mixed Language _iob __argc __argv

jimdempseyatthecove
Honored Contributor III
390 Views

I am in the process of integrating AMD's Brook+ into an Intel Visual Fortran application. Brook+ compiles a script file into C++ then the C++ compiler produces the code. When compiling alone everything works as expected.

The problem comes in when renaming what used to be main to name to be used for entry by IVF. e.g. was_main. The original code assumes the "standard" C runtime library is loaded.

IVF is not happy when loading LIBCMTD.LIB, it prefers use of MSVCRTD.LIB.
However MSVCRTD.LIB does not contain _iob, __argc and __argv

I can declare these with external "C" and initialize to 0 and link and run the application. i.e. My IVF application (mockup now) has access to the GPGPU as a computation accelerator.

I am not sure of the consequences in doing so. The application can get by without command line arguments but I am not sure what happens with _iob initialized to null (and being of size INT_PTR).

Any advice on this would be appreciated.

Jim Dempsey

0 Kudos
1 Reply
Steven_L_Intel1
Employee
390 Views
C++ code cares a lot how you compile and link it as far as which run-time libraries you use. The linking project must specify the same libraries that the C++ code was compiled with. If the C++ code was built at the command line, the default is /MT (/libs:static /threads), but if it's built in Visual Studio, the default is /MD (/libs:dll) Fortran code is far less fussy in that it generates the same actual code (not counting linker directives) no matter which library option you specified, whereas C++ actually generates different code, as you found.

I am not sure why you say "IVF .. prefers use of MSVCRTD.LIB", since that is not the default. Decide which set of libraries you're going to use and do so consistently. In VS, the choice for Fortran is made under Properties > Fortran > Libraries. In C++, it's under C++ > Code Generation.
0 Kudos
Reply