auerswal / ssocr

Seven Segment Optical Character Recognition
https://www.unix-ag.uni-kl.de/~auerswal/ssocr/index.html
GNU General Public License v3.0
201 stars 38 forks source link

Mac install error #3

Closed robmarkcole closed 6 years ago

robmarkcole commented 6 years ago

macOS High Sierra 10.13.3

I've installed Imlib2 with brew, but on make install receive the error:

Robins-MacBook-Air:ssocr robincole$ make install
cc -D_FORTIFY_SOURCE=2 -Wall -W -Wextra -pedantic -Werror -pedantic-errors -fstack-protector-all -I/usr/local/Cellar/imlib2/1.4.10_1/include -O3   -c -o ssocr.o ssocr.c
ssocr.c:21:10: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>       /* needed by Imlib2.h */
         ^~~~~~~~~~~~
1 error generated.
make: *** [ssocr.o] Error 1
auerswal commented 6 years ago

Hi,

you need to install the development packages for Imlib2 and probably X11 to compile ssocr. Every Imlib2 version I used required including the Xlib.h header file to use the Imlib2.h header file, which is necessary for using Imlib2.

I am sorry, but I cannot be more specific than that, because I do not have a mac.

Thanks, Erik

haradaa9 commented 6 years ago

Hello, you can use it instead of make. make CC='gcc -I/opt/X11/include' Then make install and run it :)

I did it with macOS Sierra 10.12.6.

auerswal commented 6 years ago

@haradaa9 Thanks for that information. So the X11 headers are not in the default include path of the C compiler on (that version of) macOS, and imlib2-config --cflags does not know about this.

A cleaner solution would be to use make CPPFLAGS=-I/opt/X11/include to specify flags needed for the C preprocessor. The CPPFLAGS variable is not set by the ssocr Makefile, and the -I option tells the C preprocessor to add the given path to its search path for .h files, so it logically belongs to the CPPFLAGS variable.

This kind of problem is usually solved with something like GNU autoconf that knows about all the little differences between operating systems. I have been able to avoid that bloat so far, and I do not really like the idea of adding it. I'll think about this some more...

Thanks, Erik

auerswal commented 6 years ago

I have received an email regarding build problems on Mac OS X 10.10.5, caused by the same problem (X11 headers are not found in the default include path).

The solution was to use make CPPFLAGS=-I/opt/X11/include, but make CC='gcc -I/opt/X11/include' did not work.

auerswal commented 6 years ago

I have added information to the INSTALL file that macOS users may need to add the X11 include path manually.

Root cause for the problem is a misconfigured system, i.e. imlib2-config --cflags is supposed to emit the needed additional include path for X11 headers on macOS, since they are needed by Imlib2 (ssocr itself does not use any X11 functionality).

I am closing this issue.

watkit commented 2 years ago

Small bump to an old thread, in case someone comes looking for this.

I managed to get ssocr to build on a 2020 m1 Mac mini (ie Apple Silicon), but had to use this command to make it work: make CPPFLAGS=-I/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/

auerswal commented 2 years ago

Thanks for the information!

I expect that this is another solution for the fatal error: 'X11/Xlib.h' file not found error reported in this issue, and have just added this information to the INSTALL file.