1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

undefined reference to `lzo1z_decompress'

Discussion in 'C' started by hrdksanghavi, Jun 6, 2011.

  1. hrdksanghavi

    hrdksanghavi New Member

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

    I am trying to decompress a data buffer through LZO decompression algorithm.
    But it throws an error while building the code.

    "/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
    gmake[1]: Entering directory `/root/NetBeansProjects/Projects/CFNORawServer'
    "/usr/bin/gmake" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/cfnorawserver
    gmake[2]: Entering directory `/root/NetBeansProjects/Projects/CFNORawServer'
    gmake[2]: Warning: File `Include/lzoconf.h' has modification time 3.7e+04 s in the future
    mkdir -p build/Debug/GNU-Linux-x86
    rm -f build/Debug/GNU-Linux-x86/main.o.d
    gcc -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.c
    mkdir -p dist/Debug/GNU-Linux-x86
    gcc -o dist/Debug/GNU-Linux-x86/cfnorawserver build/Debug/GNU-Linux-x86/main.o
    build/Debug/GNU-Linux-x86/main.o: In function `main':
    /root/NetBeansProjects/Projects/CFNORawServer/main.c:127: undefined reference to `lzo1z_decompress'
    collect2: ld returned 1 exit status
    gmake[2]: *** [dist/Debug/GNU-Linux-x86/cfnorawserver] Error 1
    gmake[2]: Leaving directory `/root/NetBeansProjects/Projects/CFNORawServer'
    gmake[1]: *** [.build-conf] Error 2
    gmake[1]: Leaving directory `/root/NetBeansProjects/Projects/CFNORawServer'
    gmake: *** [.build-impl] Error 2
    BUILD FAILED (exit value 2, total time: 331ms)

    MY CODE IS :

    Code:
    memset(recv_str,0,sizeof(recv_str));
    from_len = sizeof(from_addr);
    memset(&from_addr,0,from_len);
    if((recv_len = recvfrom(sock, recv_str, 1024, 0, (struct sockaddr*)&mc_addr, &from_len)) < 0)
    {
    perror("recvfrom() failed");
    exit(1);
    }
    short compLen=0;
    short NOP=0;
    memcpy(&compLen,recv_str+4,2);
    compLen = ntohs(compLen);
    if(compLen > 0)
    {
    memcpy(&NOP,recv_str+2,2);
    NOP=ntohs(NOP);
    int i=0;
     
     
    for(i=0;i<NOP;i++)
    {
    unsigned char src[compLen];
    memcpy(&src,recv_str+6,compLen);
    short src_len = compLen;
    unsigned int dst_len = 1024;
    unsigned char dst[1024];
    int rCode;
    unsigned int eCode=0;
    rCode = lzo1z_decompress((lzo_bytep) src ,(lzo_uint)src_len ,(lzo_bytep) dst ,lzo_uintp)&dst_len ,0);
     
    }
     
    }
    Can any one help me out of this.

    Hardik.
     
    Last edited by a moderator: Jun 6, 2011
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    You need to add the library that defines lzo1z_decompress to your link line (that's the one starting "gcc -o"). Then the linker will be able to resolve that symbol. At the moment you are trying to build the program from just build/Debug/GNU-Linux-x86/main.o.
     
    hrdksanghavi likes this.

Share This Page