Mac Compilation fixes
As it stands there are some problems compiling for macOS Sierra.
I managed to get things working with these fixes:
- Use homebrew to install clBLAS with: brew install clBLAS
- Use homebrew to install gcc since clang doesn't work with: brew install gcc
- add -lstdc++ to the main CMakeLists.txt CMAKE_CXX_FLAGS and -I/usr/local/include in both spots
- Also remove -Wl,--no-as-needed from CMAKE_CXX_FLAGS
- Change all the LINK_DIRECTORIES line from: LINK_DIRECTORIES("${CMAKE_SOURCE_DIR}/../clBLAS/src/build/library/" "${CMAKE_SOURCE_DIR}/../clBLAS/build/staging/Release") to: LINK_DIRECTORIES("/usr/local/Cellar/clblas/2.6/lib" )
Apply this diff to math_types.h: diff --git a/include/jcl/math/math_types.h b/include/jcl/math/math_types.h index 358b8a0..8e3abdd 100644 --- a/include/jcl/math/math_types.h +++ b/include/jcl/math/math_types.h @@ -11,7 +11,7 @@
#pragma once
-#if defined(WIN32) || defined(_WIN32)
+#if defined(WIN32) || defined(_WIN32) || defined(APPLE)
#include
}; // unnamed namespace
-typedef std::tr1::mt19937 RandEngine;
// The following pre-processor defines are ugly, but unfortunately
// Visual Studio does not support aliased declarations.
// Usage: NORM_DIST
With these changes, run this script to compile from within the root git repo for mac:
./build must be deleted to change compiler
[ -e "./build" ] && { echo "[D] Deleting ./build..."; rm -rf ./build; } mkdir build cd build
Using clang will not allow -fopenmp as a compiler option.
export CC=/usr/local/bin/gcc-6 export CXX=/usr/local/bin/g++-6 cmake .. make -j8
So these are changes that can be made to compile for Mac. I don't have a Windows/Linux machine to test compilation compatibility for everything to verify not breaking the other builds. But if anyone using Mac shows up, this should work for you. All tests passed after compiling.
Thanks so much @falconscript ! Yeah, I haven't tried compiling jtorch on Mac OS X in a very long time (> a year) and I'm not surprised that it is now broken.
Do you want to submit a pull-request? Or are you happy to keep this as an issue for people reference if they have issues?