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

Not compiling on MacOS #57

Closed
cojacoo opened this issue Mar 12, 2019 · 5 comments
Closed

Not compiling on MacOS #57

cojacoo opened this issue Mar 12, 2019 · 5 comments
Assignees
Labels
bug C++ Need to change C++ files (.h, .cpp)
Milestone

Comments

@cojacoo
Copy link

cojacoo commented Mar 12, 2019

Dear Philipp,
thank you for this nice work. I tried to get CMF running on my machine but miserably failed to do so. Neither from source nor from pip, neither with Py3.6 nor with Py2.7 I can get gcc to compile. I actually guess it to be a compiler setting issue, but I do not see, where these are specified...
Could you point me to allow for optional compiler settings directing to a specific compiler (like gcc-8)?
Thank you.
Conrad

@philippkraft
Copy link
Owner

The problem is that I do not have access to any Mac - however it used to work some time ago wit clang. If you are free to choose your Python version, let us forget about Python 2.

Error messages for pip install cmf?

Can you post them here in the issues

Building from source

Should work like this:

git clone https://github.com/philippkraft/cmf
cd cmf
python3 setup.py install
cd demo
python3 tracer1d.py

Can you post me (and other users) errors?

Compiler configuration

Includes:

cmf/setup.py

Lines 202 to 204 in f5bf6a4

include_dirs = [os.path.join(*'cmf/cmf_core_src/math/integrators/sundials_cvode/include'.split('/'))]
# Include numpy
include_dirs += [get_numpy_include()]

POSIX specific settings (for Linux & Mac)

cmf/setup.py

Lines 227 to 238 in f5bf6a4

compile_args = ['-Wno-comment', '-Wno-reorder', '-Wno-deprecated', '-Wno-unused', '-Wno-sign-compare', '-ggdb',
'-std=c++11']
if sys.platform == 'darwin':
compile_args += ["-stdlib=libc++"]
link_args = ['-ggdb']
libraries = []
# Disable OpenMP on Mac see https://github.com/alejandrobll/py-sphviewer/issues/3
if openmp and not sys.platform == 'darwin':
compile_args.append('-fopenmp')
link_args.append("-fopenmp")
libraries.append('gomp')

Note the Mac specific setting here:

cmf/setup.py

Lines 229 to 230 in f5bf6a4

if sys.platform == 'darwin':
compile_args += ["-stdlib=libc++"]

Is this the problem? This might be specific for CLang (I don't know, it was a lot experimenting last time with a Mac).

All other flags are coming from the configuration of the compiler when Python was compiled. You might have better luck, if you do not use Mac OS' system Python but an extra version.

@cojacoo
Copy link
Author

cojacoo commented Mar 12, 2019

Thanks for your quick reply. Here is the error from calling pip install cmf (or calling python setup.py which results in the same):

python setup.py install
cmf 1.4.1
running install
running bdist_egg
running egg_info
writing cmf.egg-info/PKG-INFO
writing dependency_links to cmf.egg-info/dependency_links.txt
writing top-level names to cmf.egg-info/top_level.txt
reading manifest file 'cmf.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.dox' under directory 'cmf'
warning: no files found matching '*.png' under directory 'cmf'
warning: no files found matching '*.txt' under directory 'cmf'
writing manifest file 'cmf.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.7-x86_64/egg
running install_lib
running build_py
copying cmf/__init__.py -> build/lib.macosx-10.7-x86_64-3.6/cmf
running build_ext
building 'cmf._cmf_core' extension
...

gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/cojack/miniconda3/include -arch x86_64 -I/Users/cojack/miniconda3/include -arch x86_64 -Icmf/cmf_core_src/math/integrators/sundials_cvode/include -I/Users/cojack/miniconda3/lib/python3.6/site-packages/numpy/core/include -I/Users/cojack/miniconda3/include/python3.6m -c cmf/cmf_core_src/math/root_finding.cpp -o build/temp.macosx-10.7-x86_64-3.6/cmf/cmf_core_src/math/root_finding.o -Wno-comment -Wno-reorder -Wno-deprecated -Wno-unused -Wno-sign-compare -ggdb -std=c++11 -stdlib=libc++
In file included from cmf/cmf_core_src/math/root_finding.cpp:2:
cmf/cmf_core_src/math/root_finding.h:45:28: error: implicit instantiation of
      undefined template 'std::__1::basic_string<char,
      std::__1::char_traits<char>, std::__1::allocator<char> >'
                                sign_error(std::string msg) : std::runti...
                                                       ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iosfwd:193:32: note:
      template is declared here
    class _LIBCPP_TEMPLATE_VIS basic_string;
                               ^
In file included from cmf/cmf_core_src/math/root_finding.cpp:2:
cmf/cmf_core_src/math/root_finding.h:49:34: error: implicit instantiation of
      undefined template 'std::__1::basic_string<char,
      std::__1::char_traits<char>, std::__1::allocator<char> >'
                                not_finite_error(std::string msg) : std:...
                                                             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iosfwd:193:32: note:
      template is declared here
    class _LIBCPP_TEMPLATE_VIS basic_string;
                               ^
In file included from cmf/cmf_core_src/math/root_finding.cpp:2:
cmf/cmf_core_src/math/root_finding.h:53:33: error: implicit instantiation of
      undefined template 'std::__1::basic_string<char,
      std::__1::char_traits<char>, std::__1::allocator<char> >'
                                iteration_error(std::string msg) : std::...
                                                            ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iosfwd:193:32: note:
      template is declared here
    class _LIBCPP_TEMPLATE_VIS basic_string;
                               ^
3 errors generated.
error: command 'gcc' failed with exit status 1

@cojacoo
Copy link
Author

cojacoo commented Mar 12, 2019

I am not quite convinced if it has anything to do with the python version. I am using miniconda py3.6.
Moreover, I do not use clang (since I used to have a series of issues with this). To me the output points to the missing definition of "basic_string" in the Mac c++ library.? I hoped to change this by forcing the gcc compiler. However, the library remains pointed to the Xcode one.

@philippkraft
Copy link
Owner

Might be a missing include (not sure), which results in an error only in xcode library. Can you try to add to root_finding.h into line 39:

#include <string>

If it works, I will update cmf fast. root_finding.h is younger than my last try to compile cmf on a Mac.

@cojacoo
Copy link
Author

cojacoo commented Mar 12, 2019

Perfect! Quite a bunch of warnings are coming up but it compiles.
Thanks a lot for your quick help.

@philippkraft philippkraft added this to the v1.5 milestone Mar 12, 2019
@philippkraft philippkraft added bug C++ Need to change C++ files (.h, .cpp) labels Mar 12, 2019
@philippkraft philippkraft self-assigned this Mar 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug C++ Need to change C++ files (.h, .cpp)
Projects
None yet
Development

No branches or pull requests

2 participants