Page 1 of 1

Compiling ExamplePendulum.cpp using g++ on Mac 10.11

Posted: Tue May 03, 2016 2:21 am
by tpataky
Hi, I've been able to successfully build and install simbody on Mac 10.11, and I'm able to successfully run the examples:

Code: Select all

cd /usr/local/SimTK/share/doc/simbody/examples/bin
./SimbodyInstallTest
./ExamplePendulum
I'm now trying to compile and run ExamplePendulum.cpp using g++ as follows:

Code: Select all

g++ ExamplePendulum.cpp -I /usr/local/SimTK/include/simbody/ -I /usr/local/SimTK/include/simbody/simbody/internal -I /usr/local/SimTK/include/simbody/SimTKcommon -I /usr/local/SimTK/include/simbody/SimTKcommon/internal -I /usr/local/SimTK/include/simmath -I /usr/local/SimTK/include/simmath/internal
But I get the errors below.
Are the include directories incorrect?
Please help!

Code: Select all

In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:439:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:628:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:1565:24: error: 
      no member named 'memcpy' in namespace 'std::__1'; did you mean 'wmemcpy'?
                _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
                ~~~~~~~^
/usr/include/wchar.h:152:10: note: 'wmemcpy' declared here
wchar_t *wmemcpy(wchar_t * __restrict, const wchar_t * __restrict, size_t);
         ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:439:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:628:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:1596:24: error: 
      no member named 'memcpy' in namespace 'std::__1'; did you mean 'wmemcpy'?
                _VSTD::memcpy(const_cast<_Vp*>(__begin2), __begin1, _Np ...
                ~~~~~~~^
/usr/include/wchar.h:152:10: note: 'wmemcpy' declared here
wchar_t *wmemcpy(wchar_t * __restrict, const wchar_t * __restrict, size_t);
         ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:439:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:628:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:1629:24: error: 
      no member named 'memcpy' in namespace 'std::__1'; did you mean 'wmemcpy'?
                _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));
                ~~~~~~~^
/usr/include/wchar.h:152:10: note: 'wmemcpy' declared here
wchar_t *wmemcpy(wchar_t * __restrict, const wchar_t * __restrict, size_t);
         ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:439:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:628:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:3158:10: error: 
      no member named 'memcpy' in namespace 'std'; did you mean 'wmemcpy'?
    std::memcpy(&__r, __p, sizeof(__r));
    ~~~~~^
/usr/include/wchar.h:152:10: note: 'wmemcpy' declared here
wchar_t *wmemcpy(wchar_t * __restrict, const wchar_t * __restrict, size_t);
         ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:439:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:1767:16: error: 
      no member named 'memmove' in namespace 'std::__1'; did you mean
      'wmemmove'?
        _VSTD::memmove(__result, __first, __n * sizeof(_Up));
        ~~~~~~~^
/usr/include/wchar.h:153:10: note: 'wmemmove' declared here
wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
         ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:439:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:1805:16: error: 
      no member named 'memmove' in namespace 'std::__1'; did you mean
      'wmemmove'?
        _VSTD::memmove(__result, __first, __n * sizeof(_Up));
        ~~~~~~~^
/usr/include/wchar.h:153:10: note: 'wmemmove' declared here
wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
         ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:439:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:1904:16: error: 
      no member named 'memmove' in namespace 'std::__1'; did you mean
      'wmemmove'?
        _VSTD::memmove(__result, __first, __n * sizeof(_Up));
        ~~~~~~~^
/usr/include/wchar.h:153:10: note: 'wmemmove' declared here
wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
         ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:439:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:1942:16: error: 
      no member named 'memmove' in namespace 'std::__1'; did you mean
      'wmemmove'?
        _VSTD::memmove(__result, __first, __n * sizeof(_Up));
        ~~~~~~~^
/usr/include/wchar.h:153:10: note: 'wmemmove' declared here
wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
         ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:439:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:2063:16: error: 
      no member named 'memset' in namespace 'std::__1'; did you mean 'wmemset'?
        _VSTD::memset(__first, (unsigned char)__value_, (size_t)(__n));
        ~~~~~~~^
/usr/include/wchar.h:154:10: note: 'wmemset' declared here
wchar_t *wmemset(wchar_t *, wchar_t, size_t);
         ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:639:32: error: 
      use of undeclared identifier 'memcmp'; did you mean 'wmemcmp'?
        {return __n == 0 ? 0 : memcmp(__s1, __s2, __n);}
                               ^
/usr/include/wchar.h:151:5: note: 'wmemcmp' declared here
int     wmemcmp(const wchar_t *, const wchar_t *, size_t);
        ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:639:39: error: 
      cannot initialize a parameter of type 'const wchar_t *' with an lvalue of
      type 'const char_type *' (aka 'const char *')
        {return __n == 0 ? 0 : memcmp(__s1, __s2, __n);}
                                      ^~~~
/usr/include/wchar.h:151:28: note: passing argument to parameter here
int     wmemcmp(const wchar_t *, const wchar_t *, size_t);
                               ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:640:63: error: 
      use of undeclared identifier 'strlen'
    static inline size_t length(const char_type* __s) {return strlen(__s);}
                                                              ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:642:54: error: 
      use of undeclared identifier 'memchr'; did you mean 'wmemchr'?
        {return __n == 0 ? NULL : (const char_type*) memchr(__s, to_int_...
                                                     ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cwchar:186:49: note: 
      'wmemchr' declared here
inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wmemchr(const wchar_t* _...
                                                ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:642:61: error: 
      cannot initialize a parameter of type 'const wchar_t *' with an lvalue of
      type 'const char_type *' (aka 'const char *')
        {return __n == 0 ? NULL : (const char_type*) memchr(__s, to_int_type(__a...
                                                            ^~~
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cwchar:186:72: note: 
      passing argument to parameter '__s' here
inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wmemchr(const wchar_t* __s, wch...
                                                                       ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:644:48: error: 
      use of undeclared identifier 'memmove'; did you mean 'wmemmove'?
        {return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);}
                                               ^
/usr/include/wchar.h:153:10: note: 'wmemmove' declared here
wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
         ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:644:56: error: 
      cannot initialize a parameter of type 'wchar_t *' with an lvalue of type
      'char_type *' (aka 'char *')
        {return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);}
                                                       ^~~~
/usr/include/wchar.h:153:28: note: passing argument to parameter here
wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
                           ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:648:50: error: 
      use of undeclared identifier 'memcpy'; did you mean 'wmemcpy'?
            return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
                                                 ^
/usr/include/wchar.h:152:10: note: 'wmemcpy' declared here
wchar_t *wmemcpy(wchar_t * __restrict, const wchar_t * __restrict, size_t);
         ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:648:57: error: 
      cannot initialize a parameter of type 'wchar_t *' with an lvalue of type
      'char_type *' (aka 'char *')
            return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
                                                        ^~~~
/usr/include/wchar.h:152:38: note: passing argument to parameter here
wchar_t *wmemcpy(wchar_t * __restrict, const wchar_t * __restrict, size_t);
                                     ^
In file included from ExamplePendulum.cpp:32:
In file included from /usr/local/SimTK/include/simbody/Simbody.h:38:
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:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/common.h:248:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:61:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/string.h:34:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/ExceptionMacros.h:77:
In file included from /usr/local/SimTK/include/simbody/SimTKcommon/internal/Exception.h:34:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:651:46: error: 
      use of undeclared identifier 'memset'; did you mean 'wmemset'?
        {return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a...
                                             ^
/usr/include/wchar.h:154:10: note: 'wmemset' declared here
wchar_t *wmemset(wchar_t *, wchar_t, size_t);
         ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

Re: Compiling ExamplePendulum.cpp using g++ on Mac 10.11

Posted: Tue May 03, 2016 11:57 am
by chrisdembia
This may be an issue with c++11 or the c++ standard library you're using. On a fresh OSX 10.11, g++ actually gives you clang++; can you clarify if you are using clang or if you installed GCC yourself and are actually using GCC?

Try adding the compiler flag `-std=c++11`. You *may* also need to add the flag `-stdlib=libc++`.

It seems like you are trying to write your own compiler command. It would be better to use Simbody's SampleCMakeLists.txt (https://github.com/simbody/simbody/blob ... eLists.txt). Note that this CMakeLists.txt is also missing the flags above; you would need to add them in using something like `set(CMAKE_CXX_FLAGS "-std=c++11")`

Re: Compiling ExamplePendulum.cpp using g++ on Mac 10.11

Posted: Tue May 03, 2016 6:15 pm
by tpataky
Hi Chris, thanks so much for your fast reply! I've now got everything working, but I'll follow up with details just in case anyone else is new to cmake like me.

First, you're correct, the actual compiler I was using was clang. I tried to write my own compiler command because I've used gcc and g++ to build simple libraries before, but I had never tried to write my own CMakeLists.txt file before. In case anyone else is new to cmake I found this tutorial helpful:
http://mathnathan.com/2010/07/getting-s ... ith-cmake/

To build the ExamplePendulum model I created the following file structure:
  • /test/mypendulum/CMakeLists.txt
    /test/mypendulum/ExamplePendulum.cpp
    /test/mypendulum/build
The CMakeLists.txt content was:

Code: Select all

cmake_minimum_required(VERSION 2.8)
project(mypendulum)

set(my_source_files ExamplePendulum.cpp)

find_package(/usr/local/SimTK/lib/cmake/simbody/Simbody REQUIRED)

include_directories(${Simbody_INCLUDE_DIR})
link_directories(${Simbody_LIB_DIR})
add_executable(mypendulum ${my_source_files} ${my_header_files})
target_link_libraries(mypendulum ${Simbody_LIBRARIES})
Using the default "find_package(Simbody REQUIRED)" from SampleCMakeLists.txt generated cmake errors even though I followed the install instructions and installed to "/usr/local/SimTK", so I thought that location would have been predictable. With the CMakeLists.txt file above building worked by:

Code: Select all

cd /test/mypendulum/build
cmake ..
make
./mypendulum

Thanks again for your help!

Re: Compiling ExamplePendulum.cpp using g++ on Mac 10.11

Posted: Tue May 03, 2016 10:28 pm
by chrisdembia
Thanks for sharing. It is best to place your build directory outside of your source tree. The instructions that say to install to `/usr/local/SimTK` are a bit dated. If you build your own project that uses Simbody, it won't find Simbody on its own unless Simbody is installed to `/usr` (or maybe `/usr/local` works also). You'll have to specify the installation directory of Simbody as the CMake variable `CMAKE_PREFIX_PATH` when configuring your own project. Personally, I install Simbody into my home directory (`~/simbody`).