Tag Archives: MSGPACKC

Solution to compile error of program written by msgpack-c

Background:

Msgpack, like JSON, can be used across platforms, operating systems, multiple languages, and can be compressed efficiently

msgpack——It’s like JSON,but fast and small.

Msgpack will package the data into binary data. Its data format is similar to JSON, but it has done a lot of optimization on numbers, multi byte characters, arrays, etc. during storage, reducing useless characters and binary format. It also ensures that there is no increase in additional storage space caused by characterization, so the size of transmitted data is reduced to a great extent.

If the size of JSON data is compared to the size of watermelon, protobuf is the size of apple, and msgpack is the size of red bean, so msgpack has obvious advantages!

 

Msgpack official website: https://msgpack.org/

Write a program using msgpack-c:

After writing, an error is reported when compiling with GCC

gcc cJSON.c main.c -o main.o -lm

 

 

 

  Later, go online to find:

gcc cJSON.c main.c -o main.o -lm -lmsgpack

 

 

 

  It is said on the Internet that there is no libmsgpack.so file under the search

find/-name libmsgpack.so   can’t find

Later, I tried fuzzy search: find/- name * libmsgpack *, and the result was libmsgpackc.so file

 

 

Then run: GCC cjson. C main. C – O main. O – lmsgpackc – LM   No error reported

Finally, an error is reported when running the compiled file: error while loading shared libraries: libmsgpackc. So. 2: cannot open shared object file: no such file or directory

 

  Then I checked the Internet,

Run first     echo $LD_ LIBRARY_ Path if there is no display, run the following command:

  LD_ LIBRARY_ PATH=/usr/local/lib

export LD_ LIBRARY_ PATH

Finally, run./main. O and find it successful