I try to use lz4 compress and decompress in my own C code. I include"lz4.h" from the downloaded file. But it still shows undefined references when I try to use the functions. I am using codeblocks, and I move the lz4.h file to the same folder of my project. I also create the PATH of the lib file which includes lz4.h(it is from Github "lz4_dev")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "lz4.h"
int main()
{
time_t start,end;
int compress, decompress;
int num_f=0;
int i;
const char* const src;
int srcSize=16385;
int dstCapacity = LZ4_compressBound(srcSize);
char* compressed_data = malloc((size_t)dstCapacity);
FILE * fc;
num_f = splitFile("/home/ziruo/research/test.txt",16384);
start = time(NULL);
for( i = 1; i <= num_f; i++)
{
fc = fopen(("/home/ziruo/research/text.txt.%03d",i),"r");
fgets(src,16384,fc);
printf("%s",src);
LZ4_compress_default(src,compressed_data,srcSize,dstCapacity);
}
//LZ4LIB_API int LZ4_compress_default(const char* src, char* dst, int srcSize, int dstCapacity);
end = time(NULL);
compress=difftime(end,start);
printf("%d",compress);
//printf("%d\n",splitFile("/home/ziruo/research/test.txt",16384));
return 0;