Closed parkergray221 closed 3 years ago
When I added an include for base64.cpp the compile error went away and both iterations work.
There is indeed a bug in the header, it is assuming that a size_t
definition is provided by <string>
but that doesn't have to be the case. #include <stddef.h>
should be added to the includes.
Hello,
I'm trying to use cpp-base64 to convert a png into base64. I'm trying to use the
std::string base64_encode(unsigned char const*, size_t len, bool url = false);
constructor.Whenever I try to compile my code I get the following error:
undefined reference to base64_encode[abi:cxx11](unsigned char const*, unsigned int, bool)
My compiler must be converting size_t type variables into unsigned int which triggers this undefined reference. Both attempts to use base64_encode below (one using vec.size() as the length argument and the other using an explicit size_t variable as the length argument) result in the same undefined reference. I'm not sure why my compiler is failing here, as vector.size() http://www.cplusplus.com/reference/vector/vector/size/ return a size_t variable and the explicitly defined size_t len should certainly be read as a size_t variable and not as an unsigned int. I think I must be missing a compiler flag but I don't know what exactly it is I'm missing. My code is below:
Thanks for any assistance you can give me!