Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29280 Discussions

Compiling Under Visual Studio 2008 Environment

rappal
Beginner
1,184 Views

I am using the Intel Compiler under the IDE of Visual Studio 2008. I had a three line program test.f for which I tried to create an executable. I was able to create an executable when I create a new Configuration Solution as shown below for rkr8. Then it creates an executable rkr.exe in directory rkr8.

1>------ Build started: Project: rkr, Configuration: rkr8 Win32 ------

1>Compiling with Intel Fortran Compiler 10.1.024 [IA-32]...

1>test.f

1>Compiling manifest to resources...

1>Microsoft Windows Resource Compiler Version 6.0.5724.0

1>Copyright (C) Microsoft Corporation. All rights reserved.

1>Linking...

1>Embedding manifest...

1>Microsoft Windows Resource Compiler Version 6.0.5724.0

1>Copyright (C) Microsoft Corporation. All rights reserved.

1>

1>Build log written to "file://C:Documents and SettingsMy DocumentsVisual Studio 2008Projectssample kr kr8BuildLog.htm"

1>rkr - 0 error(s), 0 warning(s)

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

However if I want to create a debug Configuration solution then I get the following link error and it does not create a debug executable in the debug version.

1>------ Build started: Project: rkr, Configuration: Debug Win32 ------

1>Linking...

1>LIBCMTD.lib(wincrt0.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

1>Debug kr.exe : fatal error LNK1120: 1 unresolved externals

1>

1>Build log written to "file://C:Documents and SettingsMy DocumentsVisual Studio 2008Projectssample krDebugBuildLog.htm"

1>rkr - 2 error(s), 0 warning(s)

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

This happens with the release solution also. I do not know why I am not able to create a debug or release version except if the configuration is a new solution.

Rappal

0 Kudos
6 Replies
Steven_L_Intel1
Employee
1,184 Views
It's not clear from what you have said here, but the error message is a symptom of choosing the wrong project type - Windows Application rather than Console Application. Try creating a new project with type Fortran Console Application and see if that works better for you.
0 Kudos
ohadg
Beginner
1,184 Views

Hi Steve,

I have similar problem. I made a mixed C++ Fortran using Intel's VF10.1 and Microsoft VS2008.

The fortran project is a static library project and the C++ is console. I put the F77SUB.lib as additional dependency in my linker->input with the appropriate path.

Iappriciate your help.

Ohad

This is the c++ file:

// F77CPP.cpp : Defines the entry point for the console application.

//

#include

"stdafx.h"

#include

"fortran.h"

SUBROUTINE F77SUB(REAL* IN,REAL* OUT);

int

_tmain(int argc, _TCHAR* argv[])

{

REAL IN;

REAL OUT;

IN=1.0;

OUT=1.0;

F77SUB(&IN,&OUT);

return 0;

}

and this is the Fortran File:

SUBROUTINE F77SUB(IN,OUT)

IMPLICIT NONE

REAL IN

REAL OUT

OUT=5.0*IN

RETURN

END

These arethe compilation errors:

1>------ Rebuild All started: Project: F77SUB, Configuration: Debug Win32 ------

1>Deleting intermediate files and output files for project 'F77SUB', configuration 'Debug|Win32'.

1>Compiling with Intel F ortran Compiler 10.1.021 [IA-32]...

1>F77CPP.FOR

1>Creating library...

1>

1>Build log written to "file://C:F77CPPF77SUBDebugBuildLog.htm"

1>F77SUB - 0 error(s), 0 warning(s)

2>------ Rebuild All started: Project: F77CPP, Configuration: Debug Win32 ------

2>Deleting intermediate and output files for project 'F77CPP', configuration 'Debug|Win32'

2>Compiling...

2>stdafx.cpp

2>Compiling...

2>F77CPP.cpp

2>c:f77cppf77char.h(97) : warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

2> c:program filesmicrosoft visual studio 9.0vcincludestring.h(157) : see declaration of 'strncpy'

2>Compiling manifest to resources...

2>Microsoft Windows Resource Compiler Version 6.0.5724.0

2>Copyright (C) Microsoft Corporation. All rights reserved.

2>Linking...

2>F77CPP.obj : error LNK2019: unresolved external symbol _F77SUB@8 referenced in function _wmain

2>C:F77CPPDebugF77CPP.exe : fatal error LNK1120: 1 unresolved externals

2>Build log was saved at "file://c:F77CPPF77CPPDebugBuildLog.htm"

2>F77CPP - 2 error(s), 1 warning(s)

========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========

and this is my linking command line:

/OUT:"C:F77CPPDebugF77CPP.exe" /INCREMENTAL /NOLOGO /LIBPATH:"C:F77CPPF77SUBDebug" /MANIFEST /MANIFESTFILE:"DebugF77CPP.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:F77CPPDebugF77CPP.pdb" /SUBSYSTEM:CONSOLE /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT F77SUB.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

0 Kudos
Steven_L_Intel1
Employee
1,184 Views
What is the contents of fortran.h? It is evidently defining a macro SUBROUTINE that is incorrect for use with Intel Fortran. My guess is that it includes __stdcall - if so, remove it.
0 Kudos
ohadg
Beginner
1,184 Views

Hi Steve,

Thanks for the quick response!

I took fortran.hfrom:

http://arnholm.org/software/cppf77/cppf77.htm

and it contains the following lines:

#ifndef

FORTRAN_FROM_CPLUSPLUS

#define

FORTRAN_FROM_CPLUSPLUS

/*

Definitions for calling FORTRAN 77 from C++

===========================================

Author: Carsten Arnholm, 25-AUG-1995 (first Windows NT impl.)

Rev1 : Carsten Arnholm, 21-DEC-1995 (Unix updates)

Rev2 : Carsten Arnholm, 03-MAR-1996 (f77cmplx.h, f77matrx.h)

manual is available in: http://arnholm.org/software/cppf77/cppf77.htm

*/

typedef

int INTEGER; // INTEGER 4 bytes

typedef

float REAL; // REAL 4 bytes

typedef

double DOUBLE_PRECISION; // DOUBLE PRECISION 8 bytes

typedef

int LOGICAL; // LOGICAL 4 bytes

#include

"f77char.h" // character n bytes

#include

"f77cmplx.h" // complex

#include

"f77matrx.h" // fmatrix class

// values for LOGICAL

#define

FALSE 0

#define

TRUE 1

// Macros for portable handling of linkage & calling conventions

#ifdef

F77_STUB_REQUIRED

// Typically, this branch is for Unix computers

// C++ stub functions:

#define SUBROUTINE inline void

#define INTEGER_FUNCTION inline INTEGER

#define REAL_FUNCTION inline REAL

#define LOGICAL_FUNCTION inline LOGICAL

#define DOUBLE_PRECISION_FUNCTION inline DOUBLE_PRECISION

// FORTRAN functions

#define SUBROUTINE_F77 extern "C" void

#define INTEGER_FUNCTION_F77 extern "C" int

#define REAL_FUNCTION_F77 extern "C" float

#define LOGICAL_FUNCTION_F77 extern "C" int

#define DOUBLE_PRECISION_FUNCTION_F77 extern "C" double

#else

// MS Windows using Microsoft compilers

// FORTRAN functions

#define SUBROUTINE extern "C" void __stdcall

#define INTEGER_FUNCTION extern "C" INTEGER __stdcall

#define REAL_FUNCTION extern "C" REAL __stdcall

#define LOGICAL_FUNCTION extern "C" LOGICAL __stdcall

#define DOUBLE_PRECISION_FUNCTION extern "C" DOUBLE_PRECISION

__stdcall

#endif

#endif

f77char.h f77cmplx.h, and f77matrx.h are described in the above link.

Thanks!

Ohad

0 Kudos
ohadg
Beginner
1,184 Views

I deleted the line "__stdcall" and now I get the following massages:

1>------ Rebuild All started: Project: F77SUB, Configuration: Debug Win32 ------

2>------ Rebuild All started: Project: F77CPP, Configuration: Debug Win32 ------

1>Deleting intermediate files and output files for project 'F77SUB', configuration 'Debug|Win32'.

2>Deleting intermediate and output files for project 'F77CPP', configuration 'Debug|Win32'

1>Compiling with Intel Fortran Compiler 10.1.021 [IA-32]...

1>F77CPP.FOR

2>Compiling...

1>Creating library...

2>stdafx.cpp

1>

1>Build log written to "file://c:F77CPPF77SUBDebugBuildLog.htm"

1>F77SUB - 0 error(s), 0 warning(s)

2>Compiling...

2>F77CPP.cpp

2>c:f77cppf77char.h(97) : warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

2> c:program filesmicrosoft visual studio 9.0vcincludestring.h(157) : see declaration of 'strncpy'

2>Compiling manifest to resources...

2>Microsoft Windows Resource Compiler Version 6.0.5724.0

2>Copyright (C) Microsoft Corporation. All rights reserved.

2>Linking...

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

2>Build log was saved at "file://c:F77CPPF77CPPDebugBuildLog.htm"

2>F77CPP - 1 error(s), 1 warning(s)

========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========

0 Kudos
ohadg
Beginner
1,184 Views

I got It - I just added the :

C:Program FilesIntelCompilerFortran10.1.021IA32Lib

into the addtional library path in the linker.

It works great!

No I'll try more complicated code which worked already under VC++6 and VF6.

Thanks !

Ohad

0 Kudos
Reply