atextor / icat

icat (Image cat) outputs images in 256-color capable terminals.
152 stars 12 forks source link

with imlib2 dependency installed, the 'make' command failed. #17

Closed kasimok closed 1 year ago

kasimok commented 1 year ago

On a Apple Silicon Mac, the make command failed.

➜  icat git:(master) pkg-config --libs Imlib2        
-L/opt/homebrew/Cellar/imlib2/1.10.0/lib -lImlib2

So the lmlib2 is installed.

➜  icat git:(master) make      
cc -c -Wall -pedantic -std=c99 -D_BSD_SOURCE -I/opt/X11/include -o icat.o icat.c
icat.c:39:10: fatal error: 'Imlib2.h' file not found
#include <Imlib2.h>
         ^~~~~~~~~~
1 error generated.
make: *** [icat.o] Error 1
atextor commented 1 year ago

Hi @kasimok, since I don't have a Mac, I can't give a definitive answer, but let's try to narrow it down. Can you show the output of pkg-config --cflags Imlib2? If that output is not empty, it should contain an -I path. Please verify that this path contains the Imlib2.h file. If that is the case, try adding the -I... output from pkg-config at the end of line 10 in the Makefile (the one that ends with -I/opt/X11/include). If that fixes the problem, please tell me, so we can fix the build for other Mac users too :)

kasimok commented 1 year ago
➜  icat git:(master) pkg-config  --cflags Imlib2
-I/opt/homebrew/Cellar/imlib2/1.10.0/include
➜  icat git:(master) ls /opt/homebrew/Cellar/imlib2/1.10.0/include
Imlib2.h        Imlib2_Loader.h

After adding -I/opt/homebrew/Cellar/imlib2/1.10.0/include, the compiling still failed with this error:

cc -c -Wall -pedantic -std=c99 -D_BSD_SOURCE -I/opt/X11/include -I/opt/homebrew/Cellar/imlib2/1.10.0/include -o icat.o icat.c
In file included from icat.c:39:
/opt/homebrew/Cellar/imlib2/1.10.0/include/Imlib2.h:45:10: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>
         ^~~~~~~~~~~~
1 error generated.
make: *** [icat.o] Error 1

So I went to install XQuartz first, then the error becomes:

cc -c -Wall -pedantic -std=c99 -D_BSD_SOURCE -I/opt/X11/include -I/opt/homebrew/Cellar/imlib2/1.10.0/include -o icat.o icat.c
cc -o icat icat.o -lImlib2
ld: library not found for -lImlib2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [icat] Error 1
atextor commented 1 year ago

We're already there! So the compiler needs the output of pkg-config --cflags Imlib2 added and the linker needs the output of pkg-config --libs Imlib2 added. In Linux, these calls incidentally look a little different (imlib2 instead of Imlib2), so I've updated the condition and pushed a new Makefile. Please pull the updated Makefile from master and try again.

kasimok commented 1 year ago

It works