Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   undefined reference to `lzo1x_decompress_safe' (http://www.go4expert.com/forums/undefined-reference-lzo1xdecompresssafe-t26973/)

hrdksanghavi 20Oct2011 11:08

undefined reference to `lzo1x_decompress_safe'
 
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:

Quote:

"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory `/root/NetBeansProjects/Projects/FileRead'
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/fileread
gmake[2]: Entering directory `/root/NetBeansProjects/Projects/FileRead'
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/main.o.d
g++ -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.cpp:73: warning: ignoring return value of ‘void* realloc(void*, size_t)’, declared with attribute warn_unused_result
mkdir -p dist/Debug/GNU-Linux-x86
g++ -o dist/Debug/GNU-Linux-x86/fileread build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/LZOFiles/lzo1z_d1.o
build/Debug/GNU-Linux-x86/main.o: In function `main':
/root/NetBeansProjects/Projects/FileRead/main.cpp:65: undefined reference to `lzo1x_decompress_safe'
collect2: ld returned 1 exit status
gmake[2]: *** [dist/Debug/GNU-Linux-x86/fileread] Error 1
gmake[2]: Leaving directory `/root/NetBeansProjects/Projects/FileRead'
gmake[1]: *** [.build-conf] Error 2
gmake[1]: Leaving directory `/root/NetBeansProjects/Projects/FileRead'
gmake: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 1s)
Thanks & Regards,
Hardik Sanghavi.

hrdksanghavi 4Nov2011 11:19

Re: undefined reference to `lzo1x_decompress_safe'
 
No one in this forum have any idea regarding the problem........

xpi0t0s 7Nov2011 16:41

Re: undefined reference to `lzo1x_decompress_safe'
 
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?


All times are GMT +5.5. The time now is 15:36.