Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   undefined reference to `lzo1z_decompress' (http://www.go4expert.com/forums/undefined-reference-lzo1zdecompress-t25980/)

hrdksanghavi 6Jun2011 14:09

undefined reference to `lzo1z_decompress'
 
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.

xpi0t0s 7Jun2011 12:56

Re: undefined reference to `lzo1z_decompress'
 
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.


All times are GMT +5.5. The time now is 08:39.