Building on OSX
rtolps opened this issue · 28 comments
Sorry, total noob here. I'm really exited to use the program (I use blender a lot and the ancient lattice-Boltzmann fluid simulator built in leaves much to be desired). Can you please help me build and run this on OS X? I hope you can turn this into a blender plugin in the future. The results look really great. Does it use open VDB?
Hey, I'm glad you're interested in the program. I do not have an OS X machine to build and test on so I'm not sure if the program will compile and run without errors. Let me know if you run into any errors and I will try my best to fix them.
To compile program you will need to install the GCC compiler and install GNU Make. This link gives instructions for how to install GCC and GNU Make on OS X.
The program uses the OpenCL library, so you will need make sure you have the library and header files on your machine. OS X may already have the files that you need, but I am not entirely sure.
You will also need to edit the Makefile and change the OPENCLINCLUDE and OPENCLLIB variables to point to where your OpenCL include directory is, and where your OpenCL library file is.
Let me know if you run into any problems, and I will try to help!
The program does not use OpenVDB. The particle meshing methods are all contained within the program.
I would gladly fire up a VM you can ssh or vnc into if you wanted to tweak it for OS X.
You people are amazing. You should try developing for blender.
Can't find OpenCL.framework in /libraries/frameworks any mac developers here to help?
Thank you very much for the offer, magnusviri. I may take you up on it if I need to.
I have acquired access to a Mac computer to test on over this coming weekend, so I'll try to work out how to get this program running on OS X as soon as I can.
How did it go? Any luck building it.
Hello rtolps,
I was able to build the program on OS X, but I am encountering an error ( _Assertion failed: (particleAdvector.initialize()) ) when trying to run the program, and I am currently working on resolving that error. Updates for the program to build on OS X are currently located in the osx_build branch.
Here is what I have done to get the program to build on OS X (El Capitan Version 10.11.4):
Install Xcode from the Apple App Store. Installing Xcode gave me access to GNU Make, the clang c++ compiler, and the OpenCL headers and libraries.
I found that my machine was missing the cl.hpp header, so you might need to download cl.hpp from khronos.org and place it in:
For Xcode < 4.3
/Developer/SDKs/MacOSX <Version>.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/Headers
For Xcode >=4.3
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX <Version>.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/Headers
You will probably need the cl.hpp file version that matches the version of OpenCL on your machine. I needed version 1.1.
Once I had done that, I was able to build the program using the command
make -f Makefile-OSX
And run with the command
./fluidsim
I'll keep you updated on my progress with getting this program to run on OS X.
Best Regards,
Ryan
Update: The program now builds and runs on the OS X machine that I am testing on. The updates to the program are now merged into the master branch.
Let me know if you run into any problems building/running the program.
Best Regards,
Ryan
What program/library or terminal extension do I need to run the makefile? Terminal doesn't recognise any of the commands.
The GNU Make program is used to run the makefile. The program was installed automatically when I installed Xcode. It looks like some users may have to enable the download within Xcode.
when you say run with the command do you mean in the same line? (make command should work, I realized what I did wrong. I was lazy and double clicked, maybe you should make a "build/run this program" batch file for noobs who want to build it without opening terminal?).
I'm afraid if I type it in wrong I'll screw up.
Hello rtolps,
When I said run with ./fluidsim, I meant to execute that command after the make -f Makefile-OSX command finishes running. The make command invokes the GNU Make program and tells it to run the script located in the the Makefile-OSX file. Once the make command finished running, it will create the executable simulation file fluidsim. The command ./fluidsim simply just executes that file.
If you want, you can create a shell script named something like "runandbuild.sh", place it in the fluid simulation directory, and copy these lines into the file:
#!/bin/bash
make -f Makefile-OSX
./fluidsim
The first line tells your system to use the bash program, which is what your terminal runs, to execute the commands in the script. Make sure that the file has permission to execute and it should run when you double click it.
If you want to become more familiar with using the command line interface, you may read the articles listed under "The Command Line" in Apple's guide on using the terminal.
The simulation program has no graphic user interface, and all information/errors during the simulation run time is output through the terminal.
I hope this information helps!
Greatest Regards,
Ryan
I got this error
src/clscalarfield.h:28:14: fatal error: 'OpenCL/cl.hpp' file not found #include <OpenCL/cl.hpp>
I downloaded and installed the header file into the Xcode library folder. what's going on?
Wait does the cl.hpp need to be in the src folder with all the other header files??
I checked within MacOSX .sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/Headers the cl.hpp file is there
But there is two files, cl.h and cl.hpp
The cl.hpp file should not go in the src/ folder. The cl.hpp file should be in the same folder as the cl.h file, so it sounds like it is in the right place. The problem seems to be that the compiler is not searching the OpenCL header directory.
Sorry, I'm not able to test anything right now, so I'm not able to give a solution to this error at the moment. What OS X version and Xcode version are you running?
You could try modifying the Makefile-OSX file to explicityly specify which directory to search for headers by replacing this line (line 4):
CXXFLAGS=$(OPTIMIZE) -std=c++11 -Wall
with this line:
CXXFLAGS=$(OPTIMIZE) -I"PATH_TO_HEADER_DIRECTORY" -std=c++11 -Wall
where PATH_TO_HEADER_DIRECTORY is the directory that contains the cl.hpp and cl.h files.
example:
CXXFLAGS=$(OPTIMIZE) -I"/Developer/SDKs/MacOSX <Version>.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/Headers" -std=c++11 -Wall
Still not working even though I held its hand. At this point I am willing to give you remote access to my computer so you can fix this unless I made a simple mistake with a quick fix. Have you tried testing it on a brand new macbook pro retina 2015? (possibly do it in the apple store when no one is looking or something).
`Last login: Tue May 10 16:40:42 on ttys001
Roberts-MBP:~ rstolppi$ cd ~/Downloads/GridFluidSim3D-osx_build
Roberts-MBP:GridFluidSim3D-osx_build rstolppi$ make -f Makefile-OSX
c++ -O3 -I"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/Headers" -std=c++11 -Wall -c -o src/aabb.o src/aabb.cpp
c++ -O3 -I"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/Headers" -std=c++11 -Wall -c -o src/anisotropicparticlemesher.o src/anisotropicparticlemesher.cpp
c++ -O3 -I"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/Headers" -std=c++11 -Wall -c -o src/clscalarfield.o src/clscalarfield.cpp
In file included from src/clscalarfield.cpp:24:
src/clscalarfield.h:28:14: fatal error: 'OpenCL/cl.hpp' file not found
#include <OpenCL/cl.hpp>
^
1 error generated.
make: *** [src/clscalarfield.o] Error 1
Roberts-MBP:GridFluidSim3D-osx_build rstolppi$
`
I installed TeamViewer, I'm desperate. Before I go ahead and let a helpful, trustworthy-looking random stranger into my computer, can you like make a .dmg file and put it on dropbox or something?
Hello rtolps,
I am sorry that the program still will not build for you!
I am not very familiar with program distribution so I would not able to create a .dmg file to install this program. I am also not very familiar with the OS X operating system, so unfortunately I don't think I'd be able to solve this issue if I was given remote access to your machine.
There is one last thing you could try that comes to mind. Try replacing the same line as before with this line:
CXXFLAGS=$(OPTIMIZE) -F"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/" -std=c++11 -Wall
I believe that line will tell the compiler to search that specific framework directory in the case that it is not already looking there.
If you still get the same build error, I would suggest posting a question to Stack Overflow asking why the OpenCL/cl.hpp file cannot be found by the compiler.
Best Regards,
Ryan
IT WORKS OMG
Is there any chance you can make it so that I can export simulations from blender. Pls make like a python plugin or something for blender for easy import export. And change that code in the makefile to whatever you suggested to me because it worked like a charm. Now I got to figure out how to import the animation.
Another suggestion, I've mentioned Openvdb for particle meshing (it's much faster and has overall better results) but how about making the cache format the same as blender's "animated mesh" format for easier import through the El'Beem simulator. Even better, use alembic cache library for simulations (Blender will get support for it supposedly soon) in addition to the library for blender's animated mesh cache for fluids.
Hello rtolps,
I am very glad to hear that the program is building and running for you! I have updated the master branch with a FRAMEWORKSPATH variable that can be edited to add a directory to the compiler search path.
Thanks for the suggestions! I am currently not very experienced in using Blender, so I will have to look into these features and options in the future.
I will be closing this issue now that it has been solved.
Best Regards,
Ryan
Got it:
cmake ../ -DOpenCL_INCLUDE_DIR:PATH="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenCL.framework"
make -j12