- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We have problems calling a subroutine from a static Fortran library in C++ (Visual Studio 2019 and Intel Fortran Compiler 2023)
The Fortran code:
subroutine TestFunc() bind(C, NAME="TestFunc")
INTEGER a, b,r
a = 5
b = 3
r = a + b
end subroutine
The C++ code:
extern "C" {void TestFunc();}
int main()
{
TestFunc();
return 0;
}
I get always the error message "unresolved external symbol "_TestFunc" in function "_main")
I have tried out a lot of different extern "C" definitions und different project settings, such as path settings to the Fortran library. I also manually copied the Fortran lib file into different directories.
Where is my mistake?
I had also tried it with a dynamic Fortran library (with !DEC$ ATTRIBUTES DLLEXPORT::TestDllFortran). I get the same error message.
I read many similar issues in different forums. But nothing help.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One trivial reason why this does not work is that the link step does not include the library. Can you check the dependencies to make sure that it is part of the link step? I know it is trivial, but at the moment it is the only reason I can think of.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have create a new project-solution and project and now it works. I suspect that due to the many attempts I made, another setting was no longer correct.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page