我下载了最新的zlib1.2.5软件包并将zlib的根目录添加到c ++ builder include path / lib路径并尝试编译以下代码 但是在compress,compressBound和uncompress方法中给出了链接错误!!!
[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;
}
//---------------------------------------------------------------------------
答案 0 :(得分:0)
糟糕!!我忘了制作它们。
使用make -f win32/Makefile.bor
并完成!!
到目前为止工作正常!!!! 另外,不要忘记添加依赖项!