Software Archive
Read-only legacy content
17061 Discussions

F call C which uses a user made Lib

Intel_C_Intel
Employee
357 Views
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
0 Kudos
1 Reply
Steven_L_Intel1
Employee
357 Views
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
0 Kudos
Reply