0

I tried to create an executable file for LZ4HC (I used the source code from lz4 homepage), but when I was trying to execute the file, it displayed "Symbol error LZ4_compressBound undefined". Neither static linking nor dynamical linking wasn't worked.

gcc -shared -ggdb3 -fPIC -o lz4hc.h lz4hc.c

or

gcc -c lz4hc.c -o lz4hc.o
ar rcs lz4hc.a lz4hc.o

Why the symbol LZ4_compressBound is undefined after the linking?

Tsubaki
  • 61
  • 5

2 Answers2

0

Neither static linking nor dynamical linking wasn't worked.

gcc -shared -ggdb3 -fPIC -o lz4hc.h lz4hc.c

Above command complies lz4hc.c into a shared library named lz4hc.h. That is almost surely not what you wanted.

gcc -c lz4hc.c -o lz4hc.o
ar rcs lz4hc.a lz4hc.o

These command produce lz4hc.a (correctly) but do not perform any actual linking.

I am guessing that your actual link command looks something like gcc lz4hc.a main.o, in which case your question is a duplicate of this one (among 100s of other duplicates).

Community
  • 1
  • 1
Employed Russian
  • 199,314
  • 34
  • 295
  • 362
0

LZ4_compressBound() is defined within lz4.c.

The documentation states that, in order to use/link lz4hc, one also needs lz4 : https://github.com/lz4/lz4/tree/dev/lib#high-compression-variant

Cyan
  • 13,248
  • 8
  • 43
  • 78