Dear friends:
I download a c packge for my computation work. there is a function " aft2boundar(int *, double *)" in it.
i write a "main.cpp" with vs2010, when i compile, it gives me the following error
unresolved external symbol "int __cdecl aft2dboundary(int *, double*)
but i have include the aft2.h and aft2.c in my project. I do not know how to resolve it.
it seems cpp file can not coexitst with c files . am i right?

The package you downloaded should contain a *.lib file, you need to tell the compiler/IDE that it needs to find the function in that library.

There are a couple ways to do it

  1. In one of your *.cpp files add this to near the top of the program, after all includes
    #pragma comment(lib,"somelib.lib") Replace somelib.lib with the actual name of the librarfy

  2. Go to Project --> Properties (bottom of the menu) --> Configuration Properties --> Linker --> Input. On the right side is "Additional Dependencies". Add the name of the library there.

thank you very much for your reply.
i have include the head file and the source file of the function.

All c++ compilers mangle c++ function names (functions in *.cpp files), for example the function void foo() may be actuslly foo@4 in the object/library files. Since you are trying to mix C and C++ files you need to tell the c++ code that aft2dboundary() is a C function, not a c++ function. This is how to do that

// main.cpp
#include <aft2.h>

extern "C" void _cdecl aft2dboundary(int *, double*); // <<<< function pro9totype

int main()
   // blabla

it works, thank you