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

Strange problem with Static Library

cesarpradosboda
Beginner
281 Views

Hi,

I want to make a small program that uses a static library made in FORTRAN&C, to see how the calls workfrom Fortran to functions made in C when I want work whit Build Environment for EM64T-based applications, I've made this:

LIBRARY
Code:Lib_c_64.h
#include 
#include
#include
#include
#include
int write_hello();

Code:Prog_c_64.c#include "Lib_c_64.h"
int write_hello()
{
printf("Ciaooooooo");
return 0;
}
Code:Prog.f90
SUBROUTINE WRITE_SM()
INTERFACE
INTEGER FUNCTION write_hello()
!DEC$ ATTRIBUTES C,ALIAS:'write_hello'::write_hello
END FUNCTION
END INTERFACE

INTEGERIO

IO = write_hello()

RETURN
END SUBROUTINE WRITE_SM
the library is created, I introduce it in the directory of the program that will used it, and "add existing item", the program that uses the library:
Code:Program.f90
 program Programi

 implicit none
CALL WRITE_SM()

 end program Programi
result:
Program fatal error LNK1120: 1 unresolved externals
Program error LNK2019: unresolved external symbol write_sm referenced in function MAIN__

I have controlled how the call is made, I've watched .lib with Dumpbin.exe and it makes it of this form:

   1 public symbols

        1 WRITE_SM
........
........
........

                                               Symbol    Symbol
 Offset    Type              Applied To         Index     Name
 --------  ----------------  -----------------  --------  ------
 0000000B  REL32                      00000000         C  write_hello


TheCOnfiguration Properties:

Disable Default Library Search Rules: NO

Calling Convention:C,REFERENCE

Name Case Interpretation:

if is Lower Case-->

Program error LNK2019: unresolved external symbol write_sm referenced in function MAIN__

if is Upper Case-->

Program error LNK2019: unresolved external symbol WRITE_SM referenced in function MAIN__

What do I make wrong?


0 Kudos
1 Reply
jim_dempsey
Beginner
281 Views
Try one of two options:
Option 1) In the "project" that contains Programi open the properties page and check the depends on box for the library you created.
Option 2) In the linker properties, input page, Additional Dependencies add your library name there.
Jim Dempsey
0 Kudos
Reply