Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems building on OSX #26

Closed
slarson opened this issue Apr 20, 2014 · 8 comments
Closed

Problems building on OSX #26

slarson opened this issue Apr 20, 2014 · 8 comments
Assignees
Labels

Comments

@slarson
Copy link
Member

slarson commented Apr 20, 2014

$ make all -f makefile.OSX
Building file: src/PyramidalSimulation.cpp
Invoking: clang C++ Compiler
g++ -O1 -Wall -c -I/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Headers/ -framework OpenCL -fmessage-length=0 -MMD -MP -MF"build/PyramidalSimulation.d" -MT"build/PyramidalSimulation.d" -o "build/PyramidalSimulation.o" "src/PyramidalSimulation.cpp"
clang: warning: -framework OpenCL: 'linker' input unused
src/PyramidalSimulation.cpp:10:10: fatal error: 'Python.h' file not found

include <Python.h>

     ^

1 error generated.
make: *** [build/PyramidalSimulation.o] Error 1

The makefile seems to presume that Python was installed with Homebrew.

@slarson slarson added the bug label Apr 20, 2014
@emcgowen
Copy link

This makefile works for OSX, assuming you have installed Xcode.

Ellen

RM := rm -rf

OSX_PATH = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
OSX_LIB = $(OSX_PATH)/usr/lib
FRAMEWORKS = $(OSX_PATH)/System/Library/Frameworks
PYTHON2.7 = $(FRAMEWORKS)/Python.framework/Versions/2.7
PYTHON_INC = $(PYTHON2.7)/include/python2.7

All of the sources participating in the build are defined here

SOURCES = src/PyramidalSimulation.cpp
src/main.cpp
src/owHelper.cpp
src/owOpenCLSolver.cpp
src/owPhysicsFluidSimulator.cpp
src/owWorldSimulation.cpp

SRCEXT := cpp
SRCDIR := src
BUILDDIR := build
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))

CPP_DEPS = $(OBJECTS:.o=.d)

LIBS := -framework Python -framework OpenGL -framework GLUT -framework OpenCL

All Target

all: Smoothed-Particle-Hydrodynamics

Tool invocations

Smoothed-Particle-Hydrodynamics: $(OBJECTS)
@echo 'Building target: $@'
@echo 'Invoking: clang C++ Linker'
g++ -L/usr/lib -L$(OSX_LIB) -F$(FRAMEWORKS) -o $(BUILDDIR)/Smoothed-Particle-Hydrodynamics $(OBJECTS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '

$(BUILDDIR)/%.o: $(SRCDIR)/%.cpp
@mkdir -p $(BUILDDIR)
@echo 'Building file: $<'
@echo 'Invoking: clang C++ Compiler'

use this to compile against homebrew installed python

change version number as necessary (2.7.n)

/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Headers/

    g++ -O1 -Wall -c -I$(PYTHON_INC) -F$(FRAMEWORKS) -framework OpenCL -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
    @echo 'Finished building: $<'
    @echo ' '

Other Targets

clean:
-$(RM) $(OBJECTS)$(CPP_DEPS) $(BUILDDIR)/Smoothed-Particle-Hydrodynamics
-@echo ' '

.PHONY: all clean dependents
.SECONDARY:

On Apr 20, 2014, at 11:32 AM, Stephen Larson notifications@github.com wrote:

$ make all -f makefile.OSX
Building file: src/PyramidalSimulation.cpp
Invoking: clang C++ Compiler
g++ -O1 -Wall -c -I/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Headers/ -framework OpenCL -fmessage-length=0 -MMD -MP -MF"build/PyramidalSimulation.d" -MT"build/PyramidalSimulation.d" -o "build/PyramidalSimulation.o" "src/PyramidalSimulation.cpp"
clang: warning: -framework OpenCL: 'linker' input unused
src/PyramidalSimulation.cpp:10:10: fatal error: 'Python.h' file not found
#include
^
1 error generated.
make: *** [build/PyramidalSimulation.o] Error 1

The makefile seems to presume that Python was installed with Homebrew.


Reply to this email directly or view it on GitHub.

@Neurophile
Copy link
Contributor

Many thanks to @emcgowen for providing a more OSX orthodox way of referencing the Frameworks (aka libraries). If I can get a spare moment I want to update the OSX makefile to build on the example posted above. To really be robust, the makefile needs to autodetect what version of Darwin the build is running on so it can use the appropriate paths.

There is a more serious issue that needs eventually to be addressed. The original build environment was set up to depend on a Homebrew install of Python. This was done because the project intends to eventually link to NEURON and NumPy/SciPy. Currently only NumPy is used, and only in a very rudimentary manner. My research on SciPy and especially NEURON on OSX indicates that the stock version of Python is not suitable for supporting these packages. This led to my choice of linking against a Homebrew version of Python, which has been reported as working with all of the above software. Macports Python is also reported to work, but I had to start somewhere.

Ideally, the makefiles for Linux and OSX should be unified with autodetect of platform enabled (example here: http://stackoverflow.com/questions/714100/os-detecting-makefile). We should also decide on a common directory structure. Naturally, I prefer the one I used in the OSX version.

@NHDaly
Copy link
Contributor

NHDaly commented Apr 29, 2014

In the meantime, in lieu of a platform autodetect, I added a couple of variables to the makefile in order to allow command-line specification of the python directories. (I have installed Python through MacPorts). This allowed me to compile okay! It's not a complete fix like @Neurophile was asking for, but it's a start.
See my pull request: #29

EDIT: The correct pull request is #31.

@wilzh40
Copy link
Member

wilzh40 commented Jul 24, 2014

I had another issue with compiling the makefile for OSX:
I installed python 2.7.8 through homebrew.

After modifying the directory to the right version of python, I keep on getting this error:
make: *** [build/PyramidalSimulation.o] Error 64

After some troubleshooting, I found that removing the line @mkdir -p $(BINARYTESTDIR) seemed to fix the error (temporarily) and allowed the files to compile into the build/ directory. However, it wouldn't compile completely because make: *** No rule to make target "/owPhysicTest.o", needed by "Smoothed-Particle-Hydrodynamics". Stop.

I realized $(BINARYTESTDIR) is not even defined, so the make file is essentially calling
mkdir -p and crashes. This is also why /owPhysicText.o would not compile. I am still struggling on figuring out a solution.

Any thoughts?

@skhayrulin
Copy link
Member

Hi @wilzh40 many thanks for let me know! I found that in makefile for Mac variable BINARYTESTDIR isn't defined, I've fixed it, unfortunately I have no possibility to check this on mac so please let me know how it work for you (test code from development branch).

@wilzh40
Copy link
Member

wilzh40 commented Jul 25, 2014

@skhayrulin
Works great with the fix, thanks!
If I run it from top-most level I see a blob moving around, I think it works! Do I have to do anything to make it a worm?

@skhayrulin
Copy link
Member

For this you should make little chages in code change const generateWormBodyConfiguration at this line. Then rebuild code (make clean then make in terminal). It should run simulation with worm body configuration. If any question or problem please let me know.

@wilzh40
Copy link
Member

wilzh40 commented Jul 25, 2014

@skhayrulin
Works great, but only after some troubleshooting. I had to set the PYTHONPATH as well as pip install numpy : now it loads a worm at 3 fps! (I need to get a new computer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants