How to link Libb64 libraries at compiling?

1.4k views Asked by At

I need to use Base64 encoding/decoding in my C program and I tried to use some functions of Libb64 library. When I compile the code, it gives the error below:

... undefined reference to 'base64_init_encodestate'
... undefined reference to 'base64_encode_block'
... undefined reference to 'base64_encode_blockend'
collect2: error: ld returned 1 exit status

I tried to compile code with parameters like -libb64, -llibb64, -lbase64 but it didn't work.

What is the link parameter should I add when compiling? Or are there any ways solve this problem?

1

There are 1 answers

2
Shiv On BEST ANSWER

You can try -lb64. It is a guess and may not work. Try it and if it does not work I will actually install and answer with accuracy.

Edit 1: Although it solved your problem but this is not real answer. Whenever you install a library on Linux(it is an assumption that you are using Linux) then it gets installed by the name of libxyz.so and your switch to compiler/linker should be -lxyz. In case you do not know the name of library then check with something like Synaptic to know what files are installed by that package. If you are installing by source then look at the libraries generated in the source directory from where you are installing. I do not know exact commands for yum, apt-get or pacman or emerge which are package managers for different distributions but you can read the man page and know that as well.