I’m trying an example of using C library in Swift project. Below is the reference link
https://medium.com/bumble-tech/bundling-c-library-in-swift-framework-3d9dae950774
C library files link https://sourceforge.net/projects/giflib/files/
As instructed in the tutorial link, unzip the code and go to folder via terminal and use make command, it does not work.I'm trying to do this on MAC oS Big Sur. Below is the error
**ABC-MacBook-Pro:giflib-5.2.1 abc$ make**
cc -std=gnu99 -fPIC -Wall -Wno-format-truncation -O2 -shared -Wl,-install_name -Wl,libutil.so.7 -o libutil.so qprintf.o quantize.o getarg.o
Undefined symbols for architecture x86_64:
"_GifErrorString", referenced from:
_PrintGifError in qprintf.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libutil.so] Error 1
CodePudding user response:
Change
USOURCES = qprintf.c quantize.c getarg.c
to this
USOURCES = qprintf.c quantize.c getarg.c gif_err.c
inside Makefile
. Also, change these lines:
$(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,libgif.so.$(LIBMAJOR) -o libgif.so $(OBJECTS)
...
...
$(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,libutil.so.$(LIBMAJOR) -o libutil.so $(UOBJECTS)
to
$(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-install_name -Wl,libgif.so.$(LIBMAJOR) -o libgif.so $(OBJECTS)
...
...
$(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-install_name -Wl,libutil.so.$(LIBMAJOR) -o libutil.so $(UOBJECTS)
will do the work
> make
cc -std=gnu99 -fPIC -Wall -Wno-format-truncation -O2 -c -o dgif_lib.o dgif_lib.c
warning: unknown warning option '-Wno-format-truncation' [-Wunknown-warning-option]
...
...
cc -std=gnu99 -fPIC -Wall -Wno-format-truncation -O2 gifwedge.c libgif.a libutil.a libgif.a -lm -o gifwedge
warning: unknown warning option '-Wno-format-truncation' [-Wunknown-warning-option]
1 warning generated.
For skipping xmlto
execution, remove
# $(MAKE) -C doc