justinmeiners / classic-colors

Paint program for Unix. Inspired by MS Paint (Windows 95-98).
GNU General Public License v2.0
46 stars 3 forks source link

inability to compile on macbook m1 #8

Closed MagnetarRocket closed 3 years ago

MagnetarRocket commented 3 years ago

I'm unable to compile classic-colors on a m1 macbook air, attempting to see if this is also a problem with any other motif apps (mwm-utils, emwm, xnedit) all showed a similar problem (this is the classic-colors program):

In file included from ui_color.c:18: ./ui.h:26:10: fatal error: 'Xm/Xm.h' file not found

include <Xm/Xm.h>

     ^~~~~~~~~

1 error generated. make: *** [ui_color.o] Error 1

all showed that Xm.h was absent, now my preferences is working on a external HHD as I don't have much space on my mac, and i don't want to write to when possible on SSD's. also the file system on the external HHD is case-sensitive because i wanted to have a "fully unix disk".

now someone had found a way around this: https://stackoverflow.com/questions/46872922/broken-c-std-libraries-on-macos-high-sierra-10-13/47401866#47401866

But the main problem i have i think is a way to automate the above so i don't have to do this repeatedly, a shell script would be nice but i'm new to zsh shell scripting (don't ask me how loooooooong i've been doing most of my programing stuff on windows).

also i don't have a /usr/local/include directory.

justinmeiners commented 3 years ago

My guess is it's just your non-standard installation, and not anything about the M1.

also i don't have a /usr/local/include directory.

Since it's just motif (Xm.h), the stackoverflow links is probably not what you want. I think the include path (/usr/local/include) is just wrong. You can run:

brew --prefix openmotif

to find it. To fix it, try replacing or adding that path in config.mk (after running ./configure for the first time).

I would like to make detecting that path better in the future. If there are still problems, I can get a hold of an M1 and try it out.

MagnetarRocket commented 3 years ago

Output of brew --prefix openmotif is: /opt/homebrew/opt/openmotif

i've replaced /usr/local/include with that, and now i've got more cans of worms: `In file included from ui_color.c:18: In file included from ./ui.h:26: /opt/homebrew/opt/openmotif/include/Xm/Xm.h:63:10: fatal error: 'X11/extensions/Print.h' file not found

include <X11/extensions/Print.h>

     ^~~~~~~~~~~~~~~~~~~~~~~~

1 error generated. make: *** [ui_color.o] Error 1 `

is the newest error, looking for "print.h" in homebrew just brings up "pprint", which is a C++ "pretty print"app, digging around, i found that a x11 extension called "libxp" is the needed bit, going through brew again and the brew prefix command with the "libxp" name gave me this result: /opt/homebrew/opt/libxp

and of a non-standard installation, i took a look at brew's install documentation and found that /usr/local/ is for intel, apple sillicon is /opt, homebrew on my mac is installed there alongside x11, so what i'm doing is compiling off an external HHD connected by USB. According to documentation, my homebrew installation is in the correct directory. Using ls on / brings me: Applications Volumes etc sbin Library bin home tmp System cores opt usr Users dev private var /usr/local is a empty directory. /opt on a apple sillicon is: x11 homebrew also as of this time of this comment, apple's holding a keynote right now

justinmeiners commented 3 years ago

Looks like the motif path is right now, but the X11 path is wrong (or missing extensions). Let me do some poking around and I'll get back to you with some recommendation.

non-standard.

Yes, I didn't mean to imply you did anything out of the ordinary, just that my configure script stupidly assumes it's in the place I expect.

MagnetarRocket commented 3 years ago

fiddling around with the other motif apps(i think i have them all in my github stars section) in the makefile all show a similar problem of the motif libraries. the apps are in the links below:

new motif apps (came after the release of mac osx): https://github.com/justinmeiners/classic-colors (this app we're talking about now) https://github.com/alx210/mwm-utils (sir alx210 is a gold mine of motif apps) https://github.com/alx210/emwm https://github.com/alx210/ximaging https://github.com/unixwork/xnedit

old motif apps (came before the release of mac osx, these are so old i don't think they would compile on a modern unix system even if i wanted them): https://github.com/ThomasAdam/moxfm https://github.com/edorig/xrolodex

MagnetarRocket commented 3 years ago

In fact, i have the bad feeling the homebrew infrastructure did not anticipate the case that an app would be compiled on apple silicon at all as i'm getting library errors from the makefiles of alx210's apps along the lines of " Intrinsic.h file not found" alongside the libxp library that i currently have. and of my problem, it's still not solved and i might have dug into a deeper rabbit hole of motif apps not compiling; and xnedit's automated makefile is quite complicated to the point i can't see were it failed; one may have to dig into brew's openmotif packages on their site to see how they compiled for apple silicon.

edit: i think a possible solution might be of creating a wrapper to redirect where make looks for stuff

danlshields commented 3 years ago

As a workaround, CFLAGS="-I/opt/homebrew/include" LDFLAGS="-L/opt/homebrew/lib" make works

MagnetarRocket commented 3 years ago

The colors and scroll bar are atypical, but those are settable in the .Xdefaults file

Screen Shot 2021-10-20 at 10 12 30 PM
justinmeiners commented 3 years ago

Nice! I am about to merge in a configure fix which will do everything automatically.

It asks brew where motif is installed.

What we also discovered (which may be affecting other motif programs) is that libxp is required when motif is built with printing support. It is installed with openmotif on brew, but we needed to look for it with pkg-config as well.

justinmeiners commented 3 years ago

Just merged, that should fix it for you. Love the screenshot! Can I ask what kind of project you are working on?

MagnetarRocket commented 3 years ago

Just testing, no project in mind. Mac osx does not have a native simple raster editor like paint, and i have the strange wanting of more motif apps on xquartz. In fact, i've had been trying to port CDE (Common Desktop Environment) over to the mac since 2016, but i need to know how to do simple steps now, alx210's apps are next on my list of apps to try, and maybe soon, someone at NASA would smile once i get CDE on the mac.

edit: Oh, the project's an slimmed version (in default install size + RAM) of raspbian that's for classrooms of k-12 CompSci, Without GTK+ and LXDE in favor of a self-made [motif + QT + Tk] x11 environment, been using and compiling motif apps on my mac and on my pi 400 to see if the apps would fit in the (insane?) idea i have.

MagnetarRocket commented 3 years ago

As a workaround, CFLAGS="-I/opt/homebrew/include -L/opt/homebrew/lib" make works

my full "config.mk" file if anybody is curious is:

CFLAGS += -std=c99
CFLAGS += -I/opt/homebrew/Cellar/libxext/1.3.4/include -I/opt/homebrew/Cellar/libxt/1.2.1/include -I/opt/homebrew/Cellar/libsm/1.2.3/include -I/opt/homebrew/Cellar/libice/1.0.10/include -I/opt/homebrew/Cellar/libxpm/3.5.13/include -I/opt/homebrew/Cellar/libx11/1.7.2/include -I/opt/homebrew/Cellar/libxcb/1.14_1/include -I/opt/homebrew/Cellar/libxau/1.0.9/include -I/opt/homebrew/Cellar/libxdmcp/1.1.3/include -I/opt/homebrew/Cellar/xorgproto/2021.5/include 

LDFLAGS += -L/usr/local/lib -L/opt/homebrew/Cellar/libxext/1.3.4/lib -L/opt/homebrew/Cellar/libxt/1.2.1/lib -L/opt/homebrew/Cellar/libxpm/3.5.13/lib -L/opt/homebrew/Cellar/libx11/1.7.2/lib
LDLIBS += -lm -lX11 -lXext -lXm -lXt -lXpm -lX11

# clfags has the problem of not seeing certain files. Old direct path is openmotif/include/
CFLAGS += -I/opt/homebrew/include -L/opt/homebrew/lib
CFLAGS += -D_POSIX_C_SOURCE=200809L -D X11_PATH_PREFIX=\"/opt/homebrew/Cellar/libx11/1.7.2\"
CFLAGS += -D DEBUG_LOG=0 -O3 -ffast-math -fno-strict-aliasing
CFLAGS += -D FEATURE_SHM
MagnetarRocket commented 3 years ago

Oh, the CFLAGS=-I/opt/homebrew/include -L/opt/homebrew/lib thing, doing this to alx210's apps make them work expect for the session manager apps of Mwm-utils, have a simplfied varient of it removing the lock-screen apps, tool-box does not see toolboxrc just yet.

justinmeiners commented 3 years ago

Mac osx does not have a native simple raster editor like paint

This was one of motivations. What I found in the process is that paint programs have a lot of unexpected details to work through.

the project's an slimmed version (in default install size + RAM) of raspbian

That sounds great! Good luck.

my full "config.mk" file

Thanks for posting. I am still a bit unclear. Does the new configure script generate a working version for you? Just want to confirm so I can close the issue.

MagnetarRocket commented 3 years ago

The new one works out of the box, thanks (on a different m1 macbook air that i also own); also (including alx210's apps, the fix here also works there, seems to be a motif problem on mac, will often reference this issue to fix any motif apps besides CDE in the future):

Screen Shot 2021-10-21 at 1 27 06 AM

P.s. - I think i can say this is fixed, but like i said, i will reference this many times to properly compile motif apps on mac osx as the include and lib fixes apply not only to this, but many other motif apps i think.