c++builder XE 调用 vc6.0的dll
c++ builder环境Embarcadero RAD Studio XE
已使用implib.exe -a D:\testdll_vs2010.lib D:\\testdll_2.lib生成新的lib文件,make和build已通过,但是运行时说"找不到dll_add_vc6.lib".
vc头文件dll_add_vc6.h
#ifndef DLL_ADD_VC6_H
#define DLL_ADD_VC6_H
extern "C" _declspec(dllexport) int Add_vc6(int a, int b);
#endif
vc文件dll_add_vc6.cpp
#include"dll_add_vc6.h"
#include <stdio.h>
int Add_vc6(int a, int b)
{
int c = a + b;
return c;
}
编译生成的dll_add_vc6.lib和dll_sdd_vc6.dll复制后放到bcb所在的文件夹中,用implib.exe -a testdll_vs2010.lib testdll_2.lib重新生成的lib文件添加到bcb工程中。
c++builder文件
#include "dll_add_vc6.h"
#include <vcl.h>
#pragma hdrstop
#include "Unit_testdll_3cpp.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
extern "C" __declspec(dllexport) int Add_vc6(int a, int j);
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button2Click(TObject *Sender)
{
int a = StrToInt(Edit4->Text);
int b = StrToInt(Edit5->Text);
int c = Add_vc6(a, b);
Edit6->Text = IntToStr(c);
}