Skip to content

Comments

Updated Mac install guide#651

Open
billetd wants to merge 4 commits intodevelopfrom
docs/updated_mac_install
Open

Updated Mac install guide#651
billetd wants to merge 4 commits intodevelopfrom
docs/updated_mac_install

Conversation

@billetd
Copy link
Contributor

@billetd billetd commented Nov 14, 2025

I recently successfully installed RST on an M4 Pro Mac mini with surprisingly minimal problems. This update to the Mac install guide chronicles exactly what I needed to do to get it working.

This should hopefully help alleviate the problems with Mac installations, e.g. #609

The biggest changes are related to ensuring the x86 versions of Homebrew and netcdf are installed, along with a fix for the png.c compilation error. The latter is a hack, because for some reason it can't find png.h on compilation, even when XPATH is defined correctly (and png.h is in there). I'm not sure why this is the case, but no matter what you set XPATH too (even where png.h is directly in the top level), it doesn't work.

One thing to note is that I only did this with Homebrew, and not Macports. Many of the changes may apply to Macports enjoyers, but for now, I recommend using Homebrew.

@billetd billetd marked this pull request as ready for review November 14, 2025 18:38
@billetd billetd requested review from aburrell and mtwalach November 14, 2025 18:39
@billetd billetd self-assigned this Nov 14, 2025
Copy link
Contributor

@aburrell aburrell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this didn't work for me. Not because your hack didn't do what it was supposed to, but because in addition RST wasn't correctly linking to my libraries. What I needed to do was:

  1. Add -I/opt/local/include to my makebin.darwin file on line 10. This is where my png.h file was located and meant I got past the issue of finding it without needing to change the specific file called out in your tutorial below.

  2. Adding -L/opt/local/lib to LFLAGS on line 29 of makebin.darwin.

The installed libraries weren't being detected correctly (-lpng, -lcdf, -lnetcdf). I tested adding -L/opt/local/lib (my library location) to the individual makefiles after the offending flags and that worked. I then tested the more general fix, which also worked.

This leads me to suspect that your installation issue might be solved by only applying point (1). If so, we might be able to solve this problem by adding instructions to alter the makebin, which is more top level and therefore a more desirable solution in my opinion.

There is also a change in the way that the CDF libraries are installed (at least on Mac). We probably need to revisit the way our environment variables are set to better link to the available libraries and header file locations. That would be even better than asking users to alter the makebin files.

The individual comments below are suggestions for better implementing your fix. However, if altering makebin.darwin also works for you, I think that's the more appropriate hack.

not required).

2. Load the RST environment variables. Open and edit your `~/.bashrc` file to include:
3. When compiling RST later, `png.c`, located in `/RSTINSTALLLOCATION/codebase/base/src.lib/graphic/fbuffer.1.19/src/png.c`, doesn't seem to find the `png.h` header file correctly, even though it is located in the XPATH defined in the previous step. As a patch fix while we work out what to do more cleanly, you need to change a line to point directly to `png.h`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
3. When compiling RST later, `png.c`, located in `/RSTINSTALLLOCATION/codebase/base/src.lib/graphic/fbuffer.1.19/src/png.c`, doesn't seem to find the `png.h` header file correctly, even though it is located in the XPATH defined in the previous step. As a patch fix while we work out what to do more cleanly, you need to change a line to point directly to `png.h`
3. When compiling RST later, `png.c`, located in `$RSTPATH/codebase/base/src.lib/graphic/fbuffer.1.19/src/png.c`, doesn't seem to find the `png.h` header file correctly, even though it is located in the XPATH defined in the previous step. As a patch fix while we work out what to do more cleanly, you need to change a line to point directly to `png.h`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend putting this whole section in "Troubleshooting" with an example of the error message that pops up when things aren't working correctly.

2. Load the RST environment variables. Open and edit your `~/.bashrc` file to include:
3. When compiling RST later, `png.c`, located in `/RSTINSTALLLOCATION/codebase/base/src.lib/graphic/fbuffer.1.19/src/png.c`, doesn't seem to find the `png.h` header file correctly, even though it is located in the XPATH defined in the previous step. As a patch fix while we work out what to do more cleanly, you need to change a line to point directly to `png.h`

- Go to `png.c` and change line 32 `#png.h>` to `#include </opt/X11/include/png.h>` or `#include </usr/X11/include/png.h>`, for ARM and x86-based Macs, respectively. If your compilation still errors on `png.c`, make sure this is pointed to `png.h` correctly on your machine.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too specific. My png.h header was not located under X11. Instead, I recommend directing users to find the location of their png.h header using something like: find /opt/ -type f -name 'png.h' or find /usr/ -type f -name 'png.h'

@mtwalach
Copy link
Contributor

Hey @billetd and @aburrell! 👋
Thanks for taking the time to try and solve this. I just wanted to let you know that I am very happy to look at this but I'm a little snowed under at the moment. It's on my to do list and will do it as soon as I can but it might be next week.

@billetd
Copy link
Contributor Author

billetd commented Nov 18, 2025

I agree @aburrell that a more top level solution would be better. I tried out your fix, pointing to the location of png.h in makebin.darwin, but that did not work for me. There is also already -I$(XPATH)/include on that line, which points directly to my png.h file. I also never had an issue with it finding netcdf or cdf, when my paths were set correctly.

These errors are likely very device specific, and may vary depending on how much the installation environment has changed since the user got their Mac. As an example, this install with these errors was on a brand new Mac mini. When I tried to reproduce it on my older Macbook, I got different errors, but that is probably related to the fact that I had a weird homebrew setup.

@aburrell
Copy link
Contributor

@billetd ok, based on the fix that worked for me not working for you, I double down on my suggestion to put the fix for this in the "Troubleshooting" section of the install guide. Ideally, including some details about what systems are more likely to fail as well.

@mtwalach mtwalach mentioned this pull request Dec 2, 2025
11 tasks
@mtwalach
Copy link
Contributor

mtwalach commented Dec 3, 2025

@aburrell and @billetd I appreciate the support with this but still struggling to install this. Currently failing at dmaptoncdf.1.11 because it can't find netcdf.h. I tried fiddling with the "makebin.darwin" file as Angeline suggested but no luck. Any other ideas?

... make clean rm -f *.o rm -f version.h rm -f errstr.h rm -f hlpstr.h rm -f dmaptoncdf make make.version /rst/codebase/general/src.bin/dmap/dmaptoncdf.1.11 make.help ./doc/dmaptoncdf.doc.xml cc -Wall -pedantic -O3 -D_GNU_SOURCE -D_DARWIN -I/opt/X11/include -I/opt/local/include -D_SVGLIB_ -I/rst/include/base -I/rst/include/general -I/usr/local/include -c dmaptoncdf.c dmaptoncdf.c:34:10: fatal error: 'netcdf.h' file not found 34 | #include "netcdf.h" | ^~~~~~~~~~ 1 error generated. make: *** [dmaptoncdf.o] Error 1 Compilation Aborted.

my netcdf.h file is here: /usr/local/include/netcdf.h so I don't understand why it can't find it..

@aburrell
Copy link
Contributor

aburrell commented Dec 3, 2025

If you try Dan's hack of changing the line in the file to be #include "/usr/local/include/netcdf.h" does it work? If it does, there might be something we can do in the makefiles. If not, it's probably a compiler problem.

@mtwalach
Copy link
Contributor

mtwalach commented Dec 3, 2025

@aburrell still the same problem. 👎

@aburrell
Copy link
Contributor

aburrell commented Dec 3, 2025

@mtwalach what are your system and compiler details?

@mtwalach
Copy link
Contributor

mtwalach commented Dec 3, 2025

Apple clang version 17.0.0 (clang-1700.0.13.5) Target: x86_64-apple-darwin24.6.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

It's an Apple M3 with Sequoia 15....is that the info you're after?

@billetd
Copy link
Contributor Author

billetd commented Dec 3, 2025

Assuming you have your NETCDF_PATH set correctly (and you've opened a new terminal), you could also try changing line 34 of dmaptoncdf.c to point directly to where your installed x86 version of netcdf is. If make_build fails at the same point again, then it's a problem with your netcdf install. If it gets past it, then your NETCDF_PATH isn't working with RST, for some reason...

If it's the latter, could be worth double checking your .zshrc file is loading in your paths correctly. Or manually going to everything that wants netcdf and pointing it to the right header manually.

@aburrell
Copy link
Contributor

aburrell commented Dec 3, 2025

Yes, that's a good chunk of it. If you use GCC instead of clang, it might work. I'm on intel, but also have Sequoia.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants