外部工程:
a.cpp定义函数:
extern "C" int GetScreen()
{
...
  return 0;
}
a.h定义
...
int GetScreen();
...
先用“插入工程到工作区”将那工程加进现有工作区中,然后设置了“从属性”从属现有工程。
现有工程中Dlg.cpp:
#include "../bn/a.h"
...
{
nRet=GetScreen();
}报错:
Dlg.obj : error LNK2001: unresolved external symbol _GetScreen

解决方案 »

  1.   

    在.h中也必须用extern "C"修饰,否则就不匹配了#ifdef __cplusplus
    extern "C"{
    #endif
    int GetScreen();
    #ifdef __cplusplus
    };
    #endif找个系统头文件,应该可以看到
      

  2.   

    a.h中内容全部都包括在这个里面,刚才上面没写
    #ifdef __cplusplus
    extern "C" {
    #endif
    extern int sizex;
    int   GetScreen(); 
    .......
    #ifdef __cplusplus
    } // End of extern "C"
    #endif这个外部工程能编译,是生成lib的
    还有a.h里面的变量sizex这种用都没报错,就函数出错
    别人的程序也是这么用的没问题,不知道是我工程设置少了什么东西么
      

  3.   

    lib需要链接进工程,不是加入workspace就行的