lvandeve / lodepng

PNG encoder and decoder in C and C++.
zlib License
2.06k stars 421 forks source link

Provide header only version #47

Closed McNopper closed 7 years ago

McNopper commented 7 years ago

It would be great, if a header only version does exist or could easily be created.

When doing a lot of cross platform development, a header only version avoids maintaining and building the libraries for new versions.

lvandeve commented 7 years ago

Lodepng is already easily included in projects as a single source file plus header, without being a separate library. Does that help for this use case?

McNopper commented 7 years ago

It would be much more convenient, if it would be just header only like GLI or GLM is.

See, sometimes I need to build for WIndows, Linux (Desktop and embedded), Android (all platforms), Integrity and QNX. Then, you also have 32 / 64 bit and so on. So, as soon as a new release comes out, all these libs need to be built.

When using GLI or GLM, you just include the header and that's it. Would be just great, if this would be possible somehow with lodepng as well.

stinos commented 7 years ago

It's not too hard to write a script which fetches the latest version and creates a header-only by taking lodepng.h and appending lodepng.cpp to it (except the #include "lodepng.h" line)

lvandeve commented 7 years ago

In addition, the script would have to make all functions static or inline.

Would that work? Or #including the .cpp file and placing an anonymous namespace around it?

McNopper commented 7 years ago

I need to try it out, if this works out.

stinos commented 7 years ago

In addition, the script would have to make all functions static or inline.

Hmm, only if it's included from multiple files I think. Else it will just work.

McNopper commented 7 years ago

Oh, I made some further research. I found a repo, which provides a header only solution: https://github.com/nothings/stb