- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm using a Fortran main to call a subroutine (c_sub) coded in C. In the C program, functions defined in a library are used. Let's call the library "user.lib".
When I linked the program, it gave me the error LNK2001, unresolved external ***(which is the function defined in user.lib). It seems the program can't find the user.lib, even though I tried every way I know to tell the compiler where is the user.lib.
Is there a cure to this problem? Or Mixed Language programming can't link a Fortran program with a C program which uses C library?
Many thanks!
Jenny Zhen
When I linked the program, it gave me the error LNK2001, unresolved external ***(which is the function defined in user.lib). It seems the program can't find the user.lib, even though I tried every way I know to tell the compiler where is the user.lib.
Is there a cure to this problem? Or Mixed Language programming can't link a Fortran program with a C program which uses C library?
Many thanks!
Jenny Zhen
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The problem is more likely a mismatch in expectations of what the routine name is - if your C code is in a file with a .cpp file type, C++ name-mangling is applied unless you say 'extern "C"' Also, CVF defaults to the STDCALL conventions whereas Visual C uses the C conventions.
All this is described in great detail in the mixed-language chapter of the Programmer's Guide.
Steve
All this is described in great detail in the mixed-language chapter of the Programmer's Guide.
Steve

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