Open tpham3783 opened 7 years ago
According to this comment of the Author, this library is meant to be used as the source code itself rather than binaries. :smile:
PREFIX?=/usr
INSTALL?=install
SRC=$(wildcard *.cpp)
SRC:=$(filter-out lodepng_unittest.cpp,$(SRC))
SRC:=$(filter-out lodepng_benchmark.cpp,$(SRC))
OBJS=$(SRC:.cpp=.o)
CXXFLAGS:=-fPIC -Os
TARGET=liblodepng.a liblodepng.so
all: $(TARGET)
echo "Built libraries $(TARGET) successfully."
liblodepng.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $^
liblodepng.so: $(OBJS)
$(CXX) -o $@ -shared $^
install: $(TARGET)
$(INSTALL) lodepng.h lodepng_util.h $(DESTDIR)/$(PREFIX)/include
clean:
rm -f $(OBJS) $(TARGET)
It could be. @lvandeve may have the right answer for you. I just replied as this reminds me the comment. :sweat:
Yes, it is only one source file and one header and is intended to be added directly as source files to your project. The source file also has no dependencies. It can also be renamed to have the .c extension to use as pure C only. There is a second source file lodepng_util but it is only needed for edge cases.
There is no makefile, it opens a whole can of worms and requires a lot of maintenance as platforms and popular make systems change. For this simple project, the actual C source is in fact simpler to be multiplatform than a makefile :)
I would suggest to integrate the source files in the build system you are using, it's only 1 file and one header after all.
What about adding a LODEPNG_API
macro to give the user the ability of adding __declspec(dllexport)
if needed? (Some other one-file libraries do it that way (eg. dear imgui))
Hi,
I wonder why isn't there any recipe to generate a static or dynamic library for this library? Should we add one?