静态调用dll时出现[Linker Error] Unresolved external错误
//---------------------------------------------------------------------------
#include <windows.h>
//---------------------------------------------------------------------------
// Important note about DLL memory management when your DLL uses the
// static version of the RunTime Library:
//
// If your DLL exports any functions that pass String objects (or structs/
// classes containing nested Strings) as parameter or function results,
// you will need to add the library MEMMGR.LIB to both the DLL project and
// any other projects that use the DLL. You will also need to use MEMMGR.LIB
// if any other projects which use the DLL will be performing new or delete
// operations on any non-TObject-derived classes which are exported from the
// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases,
// the file BORLNDMM.DLL should be deployed along with your DLL.
//
// To avoid using BORLNDMM.DLL, pass string information using "char *" or
// ShortString parameters.
//
// If your DLL uses the dynamic version of the RTL, you do not need to
// explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------
#pragma argsused
//在DLL中实现一个求解N的阶乘的功能函数
extern "C" __declspec(dllexport) int __stdcall fac(int n);
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
int __stdcall fac(int n)
{
if(n==0)
return 1;
else
return(n*fac(n-1));
}
调用dll的文件
#pragma hdrstop
#include "TestUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
extern "C" __declspec(dllimport) int __stdcall fac(int n);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int i;
i=fac(StrToInt(Edit1->Text));
ShowMessage("结果是:"+AnsiString(i));
}
Build时出现[Linker Error] Unresolved external 'fac' referenced from D:\静态调用DLL\TESTUNIT.OBJ
相关推荐
[Linker Error] Unresolved external 问题的解决方法
BCB里遇到过的问题 [Linker Error] Unresolved external 'mysql_init' referenced from C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.LXSERVER\桌面\TESTINSERTMYSQL\UNIT1.OBJ 的解决方案
Visual Studio 2022 C++项目配置本质:运行时、入口点与构建契约
C++项目构建不是简单写代码,而是明确二进制交付契约的过程。理解编译器运行时链接模型(如/MD、/MT、/clr)是保障ABI兼容与部署稳定的基础;掌握Win32与Console模板背后的PE子系统(Windows GUI vs CUI)差异,可避免入口点错配与控制台丢失;预编译头(pch.h)、framework.h和.vcxproj配置共同构成VS 2022的工程化骨架。本文聚焦MSVC在Visual Studio 2022中的底层行为逻辑,解析运行时库选择、项目模板约束及构建诊断方法,助力开发者从‘能
[Linker Error] Unresolved external 'mysql_init' referenced
BCB 编译链接MySQL出错,尽管包含了MySQL的所有头文件,以及libmysql.dll
vc中error LNK2001 resolved external symbol _WinMain@16的解决方法
阐述了C++中vc中error LNK2001 resolved external symbol _WinMain@16的解决方法的解决方法。
VC++编程常遇到的错误
VC++编程常遇到的错误及其解决方法VC++编程常遇到的错误及其解决方法


