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

Fortran with C

ali_z_
Beginner
1,345 Views

Hi everybody,

I use intel visual fortran composer xe 2013 with VS2012.

I have 3 questions:

1-I have a problem debugging a simple fortran code that calls a C function. When i compile the fortran code on VS2012 i get the following message: Error    2     error LNK2019: unresolved external symbol _print_C referenced in function _MAIN__    Source1.obj.  I attached the fortran and c files.

2-When i compile any fortran code on VS2012 i have no problem at all, but if i use a command prompt and type ifort example.f90 i receive the following message 'ifort' is not recognized as an internal or external command. I know i should do something to link ifort into compiling with a command prompt window but i don't know what it is. I read the documentation and i couldn't find what i need.

3-I bought the fortran composer xe like 2 years ago, now i was checking and there's something called parallel xe 2015, so is this the new version of composer xe or something different ?

Thanks in advance,

Li

 

 

0 Kudos
1 Solution
Steven_L_Intel1
Employee
1,345 Views

1. Your sources are fine. You probably haven't configured the Fortran and C projects to build together. Both projects should be in the same Visual Studio solution. Right click on the Fortran project, select Build Dependencies > Project Dependencies.  Check the box for "Depends on" for your C static library project (you do need to make the C project a static library).

2. You need to run the environment script to establish all the environment variables. We provide shortcuts to do this under Start > All Programs > Intel Parallel Studio XE > Compiler and Performance Libraries > Command Prompt...

3. It's a name change.

View solution in original post

0 Kudos
5 Replies
Steven_L_Intel1
Employee
1,346 Views

1. Your sources are fine. You probably haven't configured the Fortran and C projects to build together. Both projects should be in the same Visual Studio solution. Right click on the Fortran project, select Build Dependencies > Project Dependencies.  Check the box for "Depends on" for your C static library project (you do need to make the C project a static library).

2. You need to run the environment script to establish all the environment variables. We provide shortcuts to do this under Start > All Programs > Intel Parallel Studio XE > Compiler and Performance Libraries > Command Prompt...

3. It's a name change.

0 Kudos
TimP
Honored Contributor III
1,345 Views

When you install ifort, there will be a shortcut (on the Start menu, for win7 and earlier) to open a cmd prompt with both the ifort and (if a qualifying Visual Studio was present during install) the CL paths set up.

Then a sequence such as

cl -c hello.c

ifort source1.f90 hello.obj

should build a working source1.exe.

The document about how to use ifort in Visual Studio should explain how to set up a C project as a dependency of a Fortran project.

Yes, the xe2015 releases are current; next week xe2016 is due for release.

0 Kudos
ali_z_
Beginner
1,345 Views

Thank you Steve, the fortran and C code is working now, thanks. However, regarding my second question ifort command in a command prompt still not working i still receive 'ifort' is not recognized as an internal or external command. When i open the folder Composer XE2013 Sp1/compiler i have two other folders include and lib there's no command prompt file that i can use here.

Tim thanks, I'm using windows 8.1 and intel visual composer xe 2013 ?

0 Kudos
Steven_L_Intel1
Employee
1,345 Views

What I said was to use the shortcut in the Start menu under Intel Parallel Studio XE 2013 SP1 > Command Prompt (this may be under another level). Alternatively, from any command prompt, type"

call "%IFORT_COMPILER14%\bin\ifortvars,bat" intel64 vs2012

This will set up the environment for you.

0 Kudos
ali_z_
Beginner
1,345 Views

Thank you so much Steve !!

0 Kudos
Reply