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

Mixed Languages: undefined reference

hart
Beginner
497 Views
I would like to call a C function from Fortran code and followed the instructions in the Fortran Compilers Users Guide. The result is as follows:
lfa4(~/test) ifc -V
Intel Fortran Compiler for 32-bit applications, Version 7.1   Build 20030424Z
Copyright (C) 1985-2003 Intel Corporation.  All rights reserved.

GNU ld version 2.11.90.0.29 (with BFD 2.11.90.0.29)
  Supported emulations:
   elf_i386
   i386linux
/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x18): undefined reference to `main'
lfa4(~/test) cat sayhello.c
#include 

void sayhello(void)
{
        printf("Hello world!");
}
lfa4(~/test) icc -c sayhello.c
lfa4(~/test) cat hello.f
      PROGRAM F2C
      CALL SAYHELLO()
      END
lfa4(~/test) ifc hello.f sayhello.o
   program F2C

3 Lines Compiled
/tmp/ifcuIM5Pn.o: In function `main':
/tmp/ifcuIM5Pn.o(.text+0x1c): undefined reference to `sayhello_'


What would the correct steps be to call my C-function sayhello? Kind Regards
0 Kudos
2 Replies
webhart
Beginner
497 Views
The solution to my problem is clearly described in the documentation for the compiler version 7 (Intel Fortran Compiler for Linux* Systems User's Guide, Document No. FL-710-01). The description in the version 8 documentation (Intel Fortran Compiler for Linux* Systems User's Guide Volume I: Building Applications, Document Number: 253259-001) is very difficult to understand.
0 Kudos
Steven_L_Intel1
Employee
497 Views
Please let me know which sections of the documents you are looking at so I can ask our writers to improve the text.
0 Kudos
Reply