Question

I downloaded the latest zlib1.2.5 package and added root directory of zlib to c++ builder include path/lib path and tried to compile the following code but gives linking errors in compress, compressBound and uncompress methods!!!

[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;
}
//---------------------------------------------------------------------------
Was it helpful?

Solution

Oops!! I forgot to make them. Use make -f win32/Makefile.borand it's done!!

Working fine so far!!!! Also, don't forget to add dependencies!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top