My Visual studio 2010 solution file for a typical purpose consists of one fortran project(of static library type and consists of source1.f90), one C/C++ project(of application type and contains main.cpp) and 13 C/C++ project(of static library type and contains different .cpp/.h files for different classes).
My purpose is to call the some of the functions in fortran source files from one of the C/C++ static library type project.But i am not being able to build the program and getting errors which reads like.
a) My first trial was to call the fortran subroutine from main.cpp. But i am getting the error reads like below,
Error 2 error LNK2019: unresolved external symbol "void __cdecl bar_ftn(int,char *)" (?bar_ftn@@YAXHPAD@Z) referenced in function _main G:\VS2010\uakron\sourcefiles\application\main.obj
Error 3 error LNK1120: 1 unresolved externals G:\VS2010\uakron\build\win\debug\application_app.exe 1
source1.f90 reads as;
subroutine bar_ftn ( len_input_file, input_file ) bind( c )
use, intrinsic :: iso_c_binding, only : c_int
integer(c_int), value, intent(in) :: len_input_file
character(len=1), intent(in) :: input_file(len_input_file)
! Local declarations (copy c char array into fortran character)
character(len=len_input_file) :: infile
integer :: i
print *, "in bar_ftn"
print *, len_input_file
end subroutine bar_ftn
main.cpp reads as;
using namespace std;
extern void bar_ftn ( int flag_len, char* flag );
int main(int argc, char *argv)
char ctext="helloworld abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz";
//Call the Fortran
bar_ftn( ctext_len, ctext );
b) On the other side i also called the fortran function from one of the class functions from one of the C/C++ static library project but i am getting the same type of error (LNK2019)
Any help would be highly appreciated.