astrojuanlu / fenics-recipes

This repository contains conda recipes for the FEniCS libraries
The Unlicense
13 stars 15 forks source link

FFC fails to build on OS X - error: no member named 'shared_ptr' in namespace 'std' #16

Open johannesring opened 9 years ago

johannesring commented 9 years ago

Here is the full error message:

gcc -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Iufc -I/Users/johannr/anaconda/envs/_build/lib/python2.7/site-packages/numpy/core/include -I/Users/johannr/anaconda/envs/_build/include/python2.7 -c ufc/ufc_wrap.cpp -o build/temp.macosx-10.5-x86_64-2.7/ufc/ufc_wrap.o -arch x86_64 -std=c++11
ufc/ufc_wrap.cpp:3860:8: error: no member named 'shared_ptr' in namespace 'std'
  std::shared_ptr< ufc::function > tempshared1 ;
  ~~~~~^
ufc/ufc_wrap.cpp:3860:34: error: expected '(' for function-style cast or type construction
  std::shared_ptr< ufc::function > tempshared1 ;
                   ~~~~~~~~~~~~~ ^
ufc/ufc_wrap.cpp:3860:36: error: use of undeclared identifier 'tempshared1'
  std::shared_ptr< ufc::function > tempshared1 ;
                                   ^
ufc/ufc_wrap.cpp:3861:8: error: no member named 'shared_ptr' in namespace 'std'
  std::shared_ptr< ufc::function > *smartarg1 = 0 ;
  ~~~~~^
ufc/ufc_wrap.cpp:3861:34: error: expected '(' for function-style cast or type construction
  std::shared_ptr< ufc::function > *smartarg1 = 0 ;
                   ~~~~~~~~~~~~~ ^
ufc/ufc_wrap.cpp:3861:37: error: use of undeclared identifier 'smartarg1'
  std::shared_ptr< ufc::function > *smartarg1 = 0 ;
                                    ^
ufc/ufc_wrap.cpp:3873:7: error: use of undeclared identifier 'tempshared1'
      tempshared1 = *reinterpret_cast< std::shared_ptr<  ufc::function > * >(argp1);
      ^
ufc/ufc_wrap.cpp:3873:45: error: no type named 'shared_ptr' in namespace 'std'
      tempshared1 = *reinterpret_cast< std::shared_ptr<  ufc::function > * >(argp1);
                                       ~~~~~^
ufc/ufc_wrap.cpp:3873:55: error: expected '>'
      tempshared1 = *reinterpret_cast< std::shared_ptr<  ufc::function > * >(argp1);
                                                      ^
                                                      >
ufc/ufc_wrap.cpp:3873:38: note: to match this '<'
      tempshared1 = *reinterpret_cast< std::shared_ptr<  ufc::function > * >(argp1);
                                     ^
ufc/ufc_wrap.cpp:3873:72: error: expected '(' for function-style cast or type construction
      tempshared1 = *reinterpret_cast< std::shared_ptr<  ufc::function > * >(argp1);
                                                         ~~~~~~~~~~~~~ ^
ufc/ufc_wrap.cpp:3873:76: error: expected expression
      tempshared1 = *reinterpret_cast< std::shared_ptr<  ufc::function > * >(argp1);
                                                                           ^
ufc/ufc_wrap.cpp:3874:37: error: no type named 'shared_ptr' in namespace 'std'
      delete reinterpret_cast< std::shared_ptr<  ufc::function > * >(argp1);
                               ~~~~~^
ufc/ufc_wrap.cpp:3874:47: error: expected '>'
      delete reinterpret_cast< std::shared_ptr<  ufc::function > * >(argp1);
                                              ^
                                              >
ufc/ufc_wrap.cpp:3874:30: note: to match this '<'
      delete reinterpret_cast< std::shared_ptr<  ufc::function > * >(argp1);
                             ^
ufc/ufc_wrap.cpp:3874:64: error: expected '(' for function-style cast or type construction
      delete reinterpret_cast< std::shared_ptr<  ufc::function > * >(argp1);
                                                 ~~~~~~~~~~~~~ ^
ufc/ufc_wrap.cpp:3874:68: error: expected expression
      delete reinterpret_cast< std::shared_ptr<  ufc::function > * >(argp1);
                                                                   ^
ufc/ufc_wrap.cpp:3875:44: error: use of undeclared identifier 'tempshared1'
      arg1 = const_cast< ufc::function * >(tempshared1.get());
                                           ^
ufc/ufc_wrap.cpp:3877:7: error: use of undeclared identifier 'smartarg1'
      smartarg1 = reinterpret_cast< std::shared_ptr<  ufc::function > * >(argp1);
      ^
ufc/ufc_wrap.cpp:3877:42: error: no type named 'shared_ptr' in namespace 'std'
      smartarg1 = reinterpret_cast< std::shared_ptr<  ufc::function > * >(argp1);
                                    ~~~~~^
ufc/ufc_wrap.cpp:3877:52: error: expected '>'
      smartarg1 = reinterpret_cast< std::shared_ptr<  ufc::function > * >(argp1);
                                                   ^
                                                   >
ufc/ufc_wrap.cpp:3877:35: note: to match this '<'
      smartarg1 = reinterpret_cast< std::shared_ptr<  ufc::function > * >(argp1);
                                  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
error: command 'gcc' failed with exit status 1
Command failed: /bin/bash -x -e /Users/johannr/src/fenics-recipes/ffc/build.sh

The following patch fixes the problem:

diff --git a/ffc/build.sh b/ffc/build.sh
index f80d157..c1b84e9 100644
--- a/ffc/build.sh
+++ b/ffc/build.sh
@@ -1,5 +1,13 @@
 #!/bin/bash

+if [ `uname` == Darwin ]; then
+  MACOSX_VERSION_MIN=10.8
+  export CXXFLAGS="-mmacosx-version-min=${MACOSX_VERSION_MIN}"
+  export CXXFLAGS="${CXXFLAGS} -stdlib=libc++"
+  export LINKFLAGS="-mmacosx-version-min=${MACOSX_VERSION_MIN}"
+  export LINKFLAGS="${LINKFLAGS} -stdlib=libc++"
+fi
+
 $PYTHON setup.py install --prefix=$PREFIX

 # Add more build steps here, if they are necessary.
astrojuanlu commented 9 years ago

Thanks for the patch @johannesring and sorry for the delay! I will include it ASAP.

GaZ3ll3 commented 9 years ago

this indeed fix the share_ptr problem, but cannot pass the tests. The problem is building with LLVM clang flag stdlibc++ says this needs MACOS_DEVELOPMENT_TARAGET to be larger than or equal to 10.7. while the Apple's document seems only documented that this env value can only be 10.6 or below...

I use --no-test to jump over the tests part and continue with dolfin and fenics(already built other parts on mac-osx), there are two patches in you dolfin conda package, however, the error said

Source cache directory is: /Users/XXX/anaconda/conda-bld/src_cache
Found source in cache: dolfin-1.5.0.tar.gz
Extracting download
Applying patch: u'/Users/XXX/Documents/fenics-install/fenics-recipes-osx/dolfin/conditional_cholmod.patch'
patching file cmake/modules/FindUMFPACK.cmake
Applying patch: u'/Users/XXX/Documents/fenics-install/fenics-recipes-osx/dolfin/0001-Fix-issue-525-where-the-micro-and-minor-part-of-the-.patch'
can't find file to patch at input line 15
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|From 747e8acefb0f4402cba6444a59391892fd3dd0a7 Mon Sep 17 00:00:00 2001
|From: Johan Hake <hake.dev@gmail.com>
|Date: Wed, 27 May 2015 08:53:38 +0200
|Subject: [PATCH] Fix issue 525 where the micro and minor part of the python
| version could not be larger than 9.
|
|---
| dolfin/swig/version.i | 2 +-
| 1 file changed, 1 insertion(+), 1 deletion(-)
|
|diff --git a/dolfin/swig/version.i b/dolfin/swig/version.i
|index 8dace25..6d65aac 100644
|--- a/dolfin/swig/version.i
|+++ b/dolfin/swig/version.i
--------------------------
File to patch: 

seems the second patch does not work anymore.

astrojuanlu commented 9 years ago

This patch will be no longer needed when 1.6.0 are tagged (which hopefully will happen soon), so @GaZ3ll3 may I ask you to try this again this week? I will likely create a new branch tomorrow for the new version of FEniCS.

GaZ3ll3 commented 9 years ago

@Juanlu001 I patched that by typing the path(on osx), if on linux, it works well. I tried to run your build on my osx with conda, building dependencies of dolfin is fine, while building dolfin, it will throw some errors that seems not easily to be resolved.

I found a list of dependencies of fenics from hashdist, looked for some conda packages to replace them, I am not sure if porting those dependencies into conda-package is doable.

https://gist.github.com/GaZ3ll3/90f15dd293563d82856a

garth-wells commented 8 years ago

I'm seeing this error on someone's OSX machine, but I haven't seen it on any other OSX systems, including my own. OS and XCode are up-to-date. Any ideas what could be causing the problem on one particular machine?

astrojuanlu commented 8 years ago

I've just discovered these recipes to build FEniCS using Homebrew by @dpo and @lukeolson

https://github.com/optimizers/homebrew-fenics

I don't know how does it work but for some reason they don't need any OS-specific commands or options - probably Homebrew takes care of it.

On the other hand, there are official and recent OS X binaries for FEniCS but I haven't found the sources or build instructions:

http://fenicsproject.org/download/osx_details.html

These two would be interesting sources of inspiration to fix the conda recipes for OS X too.

garth-wells commented 8 years ago

On 5 January 2016 at 09:00, Juan Luis Cano Rodríguez < notifications@github.com> wrote:

I've just discovered these recipes to build FEniCS using Homebrew by @dpo https://github.com/dpo and @lukeolson https://github.com/lukeolson

https://github.com/optimizers/homebrew-fenics

I don't know how does it work but for some reason they don't need any OS-specific commands or options - probably Homebrew takes care of it.

I've seen this before on one OSX machine (which was not mine). The problem was that clang was using an old libstdc++ rather than the newer libc++. I don't know how it was changed from the standard libc++ to libstdc++, nor how to change it back. It seems that with older versions of xcode it was possible to change this via the xcode gui.

Garth

On the other hand, there are official and recent OS X binaries for FEniCS but I haven't found the sources or build instructions:

http://fenicsproject.org/download/osx_details.html

These two would be interesting sources of inspiration to fix the conda recipes for OS X too.

— Reply to this email directly or view it on GitHub https://github.com/Juanlu001/fenics-recipes/issues/16#issuecomment-168938548 .

dpo commented 8 years ago

I'm getting close to a stable point, with a couple last bugs to iron out in the build process. Check the dolfin160 branch at https://github.com/optimizers/homebrew-fenics/tree/dolfin160. All dolfin dependencies build, including ffc. I'm still having an issue with dolfin itself, related to mumps.

astrojuanlu commented 8 years ago

Thanks for the info @dpo. Not sure how could we take advantage of the brew recipes with conda but still good to know it's possible to get it to work. Please keep us posted.