- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Cananyonegiveme a thorough example of Fortran and C mixing including the commands for compiling/linking? I want Fortran to call C functions/subroutines. I followed the example on the manual and DOES NOT work. I have Intel Fortran 7.1 running on Win 2000. Thanks in advance.
This is what I have done:
Fortran Code:
PROGRAM test
REAL X, Y
REAL X, Y
EXTERNAL pointer_by2
X = 10
CALL pointer_by2(X,Y)
WRITE(*,*) X, Y
END
C Code:
#include
#include
#include
void pointer_by2_(const float *input,float *output)
{
*output=*input * 2.0;
}
{
*output=*input * 2.0;
}
Using a C compiler I have make an object file from the C Code example. Then, I have used the following command to link:
ifl -o myprog f_code.for c_code.o
I get the following error:
Intel Fortran Compiler for 32-bit applications, Version 7.1 Build 20030307Z
Copyright (C) 1985-2003 Intel Corporation. All rights reserved.
ifl: Command line warning: unrecognized source type 'p_test.o'; object file assu
med
ifl: Command line warning: unrecognized source type 'p_test.o'; object file assu
med
EPC Fortran-95 Version F95 Intel:200200:131124
Copyright (c) 1993-2000 EPCL. All Rights Reserved.
test_2.f90
program TEST
Copyright (c) 1993-2000 EPCL. All Rights Reserved.
test_2.f90
program TEST
13 Lines Compiled
Microsoft Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Microsoft Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
-out:myprog.exe
test_2.obj
p_test.o
p_test.o : warning LNK4078: multiple ".comment" sections found with different at
tributes (00000200)
test_2.obj : error LNK2001: unresolved external symbol _POINTER_BY2
myprog.exe : fatal error LNK1120: 1 unresolved externals
test_2.obj
p_test.o
p_test.o : warning LNK4078: multiple ".comment" sections found with different at
tributes (00000200)
test_2.obj : error LNK2001: unresolved external symbol _POINTER_BY2
myprog.exe : fatal error LNK1120: 1 unresolved externals
HELP!
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have followed the instructions for linux. The Windows compiler sets the link symbols to upper case by default, with no appended underscore. You should be OK if the C function is named POINTER_BY2().
I'm not sure which Windows C compiler would like to make a .o file rather than .obj, other than gcc, and I'm not sure that IFL will recognize -o. There is no supported compatibility between gcc and Intel compilers on Windows, but this may work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried changing from lowercase to uppercase, appending an underscore or removing the underscore, but it doesn't work. Can youcompile/link my two simple code examples and tell me if they work? If they work, can you email me the object file of the C example.
Thank you in advance.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page