我用vc++中写的一个简单的dll,但在delphi中调用时总是出现找不到入口点的错误,我用delphi写了相同的dll,调用时就没有任何问题。函数声明为:
 function add (x:integer;y:integer):integer;stdcall;external 'math.dll'调用为: Total := add(a,b)函数声明变为:
 function add (x:integer;y:integer):integer;cdecl;external 'math.dll'
 function add (x:integer;y:integer):integer;safecall;external 'math.dll'
也不可以。为什么?

解决方案 »

  1.   

    我以前用vc写的静态库lib文件在CBuilder5下调用
    需要用
    D:\program files\Borland\CBuilder5\Bin\coff2omf.exe
    转换一下。不知道是否可用来解决你这个问题。
      

  2.   

    function add (x:integer;y:integer):integer;cdecl;external 'math.dll'
    没有问题,我就这样写,
    检查一下您的math.dll里有没有输出add函数(def文件中有没有add函数)。
      

  3.   

    这是DELPHI中函数的声明(这几种声明形式我都用过了):
    //function addition(x:real;y:real):real;stdcall;external 'testdll.dll' name 'firstdll'
     function add(x:integer;y:integer):integer;stdcall;external 'math.dll'
      //function add (x:integer;y:integer):integer;cdecl;external 'math.dll'
    //function add (x:integer;y:integer):integer;safecall;external 'math.dll'这是VC中函数的定义:
    MATH_API int _stdcall add(int x, int y)
    {
    int z = x + y ; return z ;}
      

  4.   

    VC中要写.def文件,防止VC对函数名进行转换
    格式
    EXPORTS
         函数名
         函数名
         ...
    写完之后加到工程里就可以了用VC自带的Depends工具可以看到DLL输出的函数名
      

  5.   

    VC导出函数加extern "C"关键字,另外在在DEF文件中声明。