0
我下載了最新的zlib1.2.5軟件包,並將zlib的根目錄添加到C++ builder include path/lib path,並嘗試編譯以下代碼 ,但在compress,compressBound和uncompress方法中給出鏈接錯誤!zlib鏈接錯誤
[ILINK32 Error] Error: Unresolved external '_compressBound' referenced from C:\USERS\Dev\DOCUMENTS\RAD STUDIO\PROJECTS\DEBUG\UNIT1.OBJ
[ILINK32 Error] Error: Unresolved external '_compress' referenced from C:\USERS\Dev\DOCUMENTS\RAD STUDIO\PROJECTS\DEBUG\UNIT1.OBJ
[ILINK32 Error] Error: Unresolved external '_uncompress' referenced from C:\USERS\Dev\DOCUMENTS\RAD STUDIO\PROJECTS\DEBUG\UNIT1.OBJ
[ILINK32 Error] Error: Unable to perform link
// What else dirs do I need to add to lib path???
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#define __MACTYPES__
#include <zlib.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btn1Click(TObject *Sender)
{
AnsiString astrTemp = "";
// astrTemp = Memo1->Text;
unsigned long iLen = mmo1->Text.Length(); //原Memo2
unsigned long ulBuflen = compressBound(iLen); //
char *pcompress = new char[ulBuflen];
memset(pcompress,'\0',ulBuflen);
int iRet = compress(pcompress,&ulBuflen,AnsiString(mmo1->Text).c_str(),iLen);
if(iRet == Z_OK)
{
AnsiString astrTemp="";
for(int i=0;i<ulBuflen;i++)
{
astrTemp+=IntToHex((unsigned char)pcompress[i],2)+" ";
}
mmo1->Lines->Add(astrTemp);
}
astrTemp.SetLength(iLen);
uncompress(astrTemp.c_str(),&iLen,pcompress,ulBuflen);
mmo2->Text = astrTemp;
delete []pcompress;
}
//---------------------------------------------------------------------------
通過壓縮'stackoverflow.com'輸出'78 9C 2B 2E 49 4C CE CE 2F 4B 2D 4A CB C9 2F D7 4B CE CF 05 00 3F F3 06 F8' –