rice-solar-physics/ebtelplusplus

Boost not found on Intel Macs

jwreep opened this issue · 2 comments

On Intel Macs (M1/2/3 chips), boost is installed in /opt/homebrew/ rather than /usr/local/, and the compiler doesn't find the library by default:

(base) reep@atrcw17 ebtelPlusPlus % scons
scons: Reading SConscript files ...
Using Mac OS X compile options.
scons: done reading SConscript files.
scons: Building targets ...
g++ -o source/loop.o -c -std=c++11 -O3 -I/opt/local/include -I/usr/include/malloc source/loop.cpp
In file included from source/loop.cpp:6:
In file included from source/loop.h:9:
source/helper.h:18:10: fatal error: 'boost/array.hpp' file not found
#include "boost/array.hpp"
         ^~~~~~~~~~~~~~~~~
1 error generated.
scons: *** [source/loop.o] Error 1
scons: building terminated because of errors.

This can be remedied in SConstruct by checking to see if we're on an Intel Mac:

if 'darwin' in sys.platform:
    print("Using Mac OS X compile options.")
    if 'HOMEBREW_PREFIX' in os.environ:
        env.Append(CPPPATH=['/opt/local/include','/usr/include/malloc','/opt/homebrew/include'])
        env.Append(LIBPATH=['/opt/homebrew/lib'])
    else:
        env.Append(CPPPATH=['/opt/local/include', '/usr/include/malloc'])
        env.Append(LIBPATH=['/opt/local/lib'])
    env.Append(LIBS=['boost_program_options-mt'])

I can set up a pull request for this, but it would be good to validate that this works without issue on a non-Intel Mac, which I don't currently have access to.

Does

$ scone --includepath=/opt/homebrew/include --libpath=/opt/homebrew/lib 

work?

I'm not super keen to continue to increase the complexity of the scons build, primarily because I want to throw the whole thing away ASAP in favor of just providing installable binaries available through a Python interface. See #79 for more details.

Yup, that works.

I'll close the issue because there are two separate solutions here. It'd be good to see those updates, though.