- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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;
}
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
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__
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?
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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