undefined reference to `lzo1x_decompress_safe'

Discussion in 'C' started by hrdksanghavi, Oct 20, 2011.

  1. hrdksanghavi

    hrdksanghavi New Member

    Joined:
    Jun 6, 2011
    Messages:
    6
    Likes Received:
    2
    Trophy Points:
    0
    Hello,

    I am getting an undefined reference error for an decomression method. the code is as followed.

    Code:
    #include <cstdlib>
    #include<iostream>
    #include <cstring>
    #include <cstddef>
    #include <fstream>
    #include <lzo/lzo1x.h>
    #include "LZOFiles/lzoutil.h"
    #include "LZOFiles/lzo1z.h"
    #include "LZOFiles/lzo1x.h"
    
    using namespace std;
    
    int lzo1x_decompress_safe(const unsigned char* src, lzo_uint src_len, unsigned char* dst, lzo_uint* dst_len, void* wrkmem);
    
    //int lzo1z_decompres(const unsigned char* src, lzo_uint src_len, unsigned char* dst, lzo_uint* dst_len, void* wrkmem);
    
    int main(int argc, char** argv) {
    
        ifstream inFile;
        size_t size=0;
        
        inFile.open("RawDataTBT201110071111.txt", ios::in|ios::binary|ios::ate);
        char* oData=0;
        //unsigned char oPkt =0;
        //unsigned char src=0;
        //unsigned char dst=0;
        short iDataSize=0;
        int iFileSize=0;
        std::ofstream file("output.txt", std::ios_base::out);
        inFile.seekg(0,ios::end);
        
        size=inFile.tellg();
        file<<"size of the file: "<<size;
        
        inFile.seekg(0,ios::beg);
        
        oData = new char[size+1];
        unsigned char oPkt[size+1];
        
        inFile.read(oData,size);
        oData[size]='\0';
        file<<"oData Size:"<<strlen(oData)<<"\n";
        
        for(size_t i=0;i<strlen(oData);i++)
        {
            
    
            oPkt[iDataSize] = oData[i];
            
            file<<oPkt[iDataSize]<<"\t";
            if(oData[i+1]=='#' && oData[i+2]=='#' && oData[i+3]=='#')
            {
                unsigned char src[iDataSize];
                lzo_uint dst_len =1024;
                unsigned char dst[dst_len];
                
                memcpy(src,oPkt,iDataSize);
                int rCode;
                unsigned int eCode=0;
                rCode = lzo1x_decompress_safe(src,iDataSize,dst,&dst_len,&eCode);
                
                file<<"\n";
                iFileSize+=iDataSize;
                file<<"Pkt Size:"<<iDataSize<<"\t File Read Size"<<iFileSize<<"\n";
                iDataSize=-1;
                i=i+2;
                
                realloc(oPkt,strlen(oData)-i);
            }
            iDataSize++;
        }
        return 0;
    }
    
    
    am getting error for lzo1x_decompress_safe(), but if i use lzo1z_decompres() then i m not getting any error. But I want to use lzo1x_decompress_safe() method in my program.

    Kindly help me in this. The error msg is as follow:

    Thanks & Regards,
    Hardik Sanghavi.
     
  2. hrdksanghavi

    hrdksanghavi New Member

    Joined:
    Jun 6, 2011
    Messages:
    6
    Likes Received:
    2
    Trophy Points:
    0
    No one in this forum have any idea regarding the problem........
     
  3. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    I only know what the error means, which is that the linker cannot find lzo1x_decompress_safe in any of the libraries you've linked in. The solution to the problem is to link in a library that defines this symbol.

    As for why the library doesn't define that symbol, or what library you need that defines it, you'll have to ask the people who wrote the library. Maybe it's lzo1x_d2.o, not lzo1x_d1.o?
     
    hrdksanghavi likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice