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'

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


#include <cstdlib>
#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);
    file<<"size of the file: "<<size;
    oData = new char[size+1];
    unsigned char oPkt[size+1];
    file<<"oData Size:"<<strlen(oData)<<"\n";
    for(size_t i=0;i<strlen(oData);i++)

        oPkt[iDataSize] = oData[i];
        if(oData[i+1]=='#' && oData[i+2]=='#' && oData[i+3]=='#')
            unsigned char src[iDataSize];
            lzo_uint dst_len =1024;
            unsigned char dst[dst_len];
            int rCode;
            unsigned int eCode=0;
            rCode = lzo1x_decompress_safe(src,iDataSize,dst,&dst_len,&eCode);
            file<<"Pkt Size:"<<iDataSize<<"\t File Read Size"<<iFileSize<<"\n";
    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:


"/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.