ClonePtr.h issue

Simbody is useful for internal coordinate and coarse grained molecule modeling, large scale mechanical models like skeletons, and anything else that can be modeled as bodies interconnected by joints, acted upon by forces, and restricted by constraints.
POST REPLY
User avatar
Samuel Flores
Posts: 188
Joined: Mon Apr 30, 2007 1:06 pm

ClonePtr.h issue

Post by Samuel Flores » Thu Jun 01, 2017 1:45 am

Guys,

I am now further along. Now when compiling MMB I am getting a hard error in ClonePtr.h, appended below. It seems like something that should have come up when I compiled simbody or molmodel, but those all compiled just fine. Thanks in advance for any advice.

Sam

nl110-99-73:build Sam$ /usr/bin/g++ -DMMBlib_EXPORTS -I/Users/Sam/svn/RNAToolbox/trunk/include -isystem /usr/local/SimTK/include/simbody -I/usr/local/SimTK/include -I/usr/local/openmm/include/openmm/reference -I/usr/local/openmm/include/openmm -I/usr/local/openmm/include -I/usr/local/seqan-library-1.4.1/include -std=c++11 -O3 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.5 -fPIC -DMMB_BUILDING_SHARED_LIBRARY -o CMakeFiles/MMBlib.dir/src/DisplacementContainer.cpp.o -c /Users/Sam/svn/RNAToolbox/trunk/src/DisplacementContainer.cpp
In file included from /Users/Sam/svn/RNAToolbox/trunk/src/DisplacementContainer.cpp:12:
In file included from /Users/Sam/svn/RNAToolbox/trunk/include/DisplacementContainer.h:14:
In file included from /Users/Sam/svn/RNAToolbox/trunk/include/BiopolymerClass.h:18:
In file included from /Users/Sam/svn/RNAToolbox/trunk/include/Mutation.h:4:
In file included from /Users/Sam/svn/RNAToolbox/trunk/include/Utils.h:22:
In file included from /usr/local/SimTK/include/simbody/SimTKsimbody.h:43:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon.h:32:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/basics.h:44:
/usr/local/SimTK/include/simbody/SimTKcommon/internal/ClonePtr.h:72:19: error: non-friend class member 'nullptr_t' cannot have a qualified name
ClonePtr(std::nullptr_t) noexcept : ClonePtr() {}
~~~~~^
/usr/local/SimTK/include/simbody/SimTKcommon/internal/ClonePtr.h:72:29: error: expected ';' at end of declaration list
ClonePtr(std::nullptr_t) noexcept : ClonePtr() {}
^
/usr/local/SimTK/include/simbody/SimTKcommon/internal/ClonePtr.h:358:53: error: no type named 'nullptr_t' in namespace 'std'
inline bool operator==(const ClonePtr<T>& lhs, std::nullptr_t)
~~~~~^
/usr/local/SimTK/include/simbody/SimTKcommon/internal/ClonePtr.h:364:29: error: no type named 'nullptr_t' in namespace 'std'
inline bool operator==(std::nullptr_t, const ClonePtr<T>& rhs)
~~~~~^

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: ClonePtr.h issue

Post by Christopher Dembia » Thu Jun 01, 2017 2:58 pm

I wonder if you need to include <cstddef> (http://en.cppreference.com/w/cpp/types/nullptr_t).

User avatar
Samuel Flores
Posts: 188
Joined: Mon Apr 30, 2007 1:06 pm

Re: ClonePtr.h issue

Post by Samuel Flores » Fri Jun 02, 2017 1:03 am

I did include it in my Utils.h:

21 #include <cstddef>
22 #include "SimTKsimbody.h"
23 #include "SimTKmolmodel.h"

Based on your comment I also added it to ClonePtr.h , though I would think that would have come up before if that were the issue:

27 #include "SimTKcommon/internal/common.h"
28
29 #include <cstddef>
30 #include <memory>

Neither of these changes fixed the issue (see compiler output below). I was able to get rid of the error by declaring nullptr_t in ClonePtr.h:

36 namespace std {
37 typedef decltype(nullptr) nullptr_t;
38 }

.. However then I had other namespace issues elsewhere (see below). I feel like the problem must be something very simple and fundamental.

/usr/bin/c++ -DMMBlib_EXPORTS -I/Users/Sam/svn/RNAToolbox/trunk/include -isystem /usr/local/SimTK/include/simbody -I/usr/local/SimTK/include -I/openmm -I/openmm/reference -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.5 -fPIC -DMMB_BUILDING_SHARED_LIBRARY -o CMakeFiles/MMBlib.dir/src/DisplacementContainer.cpp.o -c /Users/Sam/svn/RNAToolbox/trunk/src/DisplacementContainer.cpp
In file included from /Users/Sam/svn/RNAToolbox/trunk/src/Utils.cpp:11:
In file included from /Users/Sam/svn/RNAToolbox/trunk/include/Utils.h:22:
In file included from /usr/local/SimTK/include/simbody/SimTKsimbody.h:43:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon.h:32:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/basics.h:38:
/usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:792:1: error: unknown type name 'constexpr'
constexpr bool detect64BitPlatform() { return (sizeof(size_t) > sizeof(int)); }
^
/usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:792:11: error: expected unqualified-id
constexpr bool detect64BitPlatform() { return (sizeof(size_t) > sizeof(int)); }
^


I find it interesting that the first namespace issue does not come up until ClonePtr.h, line 359. There is some commentary in there about namespace lookups.

321 //==============================================================================
322 // SimTK namespace-scope functions
323 //==============================================================================
324 // These namespace-scope functions will be resolved by the compiler using
325 // "Koenig lookup" which examines the arguments' namespaces first.
326 // See Herb Sutter's discussion here: http://www.gotw.ca/publications/mill08.htm.


Thanks

Sam

/usr/bin/g++ -DMMBlib_EXPORTS -I/Users/Sam/svn/RNAToolbox/trunk/include -isystem /usr/local/SimTK/include/simbody -I/usr/local/SimTK/include -I/usr/local/openmm/include/openmm/reference -I/usr/local/openmm/include/openmm -I/usr/local/openmm/include -I/usr/local/seqan-library-1.4.1/include -std=c++11 -O3 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.5 -fPIC -DMMB_BUILDING_SHARED_LIBRARY -o CMakeFiles/MMBlib.dir/src/Utils.cpp.o -c /Users/Sam/svn/RNAToolbox/trunk/src/Utils.cpp
In file included from /Users/Sam/svn/RNAToolbox/trunk/src/Utils.cpp:11:
In file included from /Users/Sam/svn/RNAToolbox/trunk/include/Utils.h:22:
In file included from /usr/local/SimTK/include/simbody/SimTKsimbody.h:43:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon.h:32:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/basics.h:44:
/usr/local/SimTK/include/simbody/SimTKcommon/internal/ClonePtr.h:73:19: error: non-friend class member 'nullptr_t' cannot have a qualified name
ClonePtr(std::nullptr_t) noexcept : ClonePtr() {}
~~~~~^
/usr/local/SimTK/include/simbody/SimTKcommon/internal/ClonePtr.h:73:29: error: expected ';' at end of declaration list
ClonePtr(std::nullptr_t) noexcept : ClonePtr() {}
^
/usr/local/SimTK/include/simbody/SimTKcommon/internal/ClonePtr.h:359:53: error: no type named 'nullptr_t' in namespace 'std'
inline bool operator==(const ClonePtr<T>& lhs, std::nullptr_t)
~~~~~^
/usr/local/SimTK/include/simbody/SimTKcommon/internal/ClonePtr.h:365:29: error: no type named 'nullptr_t' in namespace 'std'
inline bool operator==(std::nullptr_t, const ClonePtr<T>& rhs)
~~~~~^

User avatar
Samuel Flores
Posts: 188
Joined: Mon Apr 30, 2007 1:06 pm

Re: ClonePtr.h issue

Post by Samuel Flores » Fri Jun 02, 2017 2:54 am

Turns out it wanted me to set -stdlib=libc++ for some reason..

having some additional problems, but the above seems to be fixed now

thanks
sam

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: ClonePtr.h issue

Post by Christopher Dembia » Fri Jun 02, 2017 12:36 pm

I'm glad you resolved the issue. The correct C++ standard library to use with Clang (which is what you are using on a Mac; g++ is simply a symlink to clang++) is libc++ (this standard library is created by LLVM and goes with Clang). The libstdc++ standard library goes with GCC.

POST REPLY