I got the example to work from my Netbeans after downgrading to Xcode 4.6.3 on OS X 10.9.1 and using clang++ and C++11 (no other changes to the settings in Netbeans). It also worked on g++ (or clang++) using C++98. It looks like the default library in Xcode 5 was libc++
(LLVM C++ standard library with C++11 support) but what I needed for this to link was libstdc++
(GNU C++ standard library - default library for earlier Xcode versions). After changing that in the ~/.R/Makevars file CXXFLAGS="-stdlib=libstdc++ -std=c++11 -mtune=native -g -O3 -Wall -pedantic -Wconversion"
along with the clang++
change I got the examples to build. I confirmed the behavior by re-upgrading to Xcode 5 and getting the same error in Netbeans but not on the samples (which now built because of the libstdc++
flag). When I added -stdlib=libstdc++
as an additional flag in Netbeans it built again.
Just as an fyi in case someone else hits a problem building the examples. In Netbeans the compile and links steps are:
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/callingrproject
mkdir -p build/Debug/GNU-MacOSX
rm -f "build/Debug/GNU-MacOSX/main.o.d"
clang++ -stdlib=libstdc++ -c -g -I. -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/library/Rcpp/include -I/Library/Frameworks/R.framework/Resources/library/RInside/include -I/usr/local/Cellar -std=c++98 -MMD -MP -MF "build/Debug/GNU-MacOSX/main.o.d" -o build/Debug/GNU-MacOSX/main.o main.cpp
mkdir -p dist/Debug/GNU-MacOSX
clang++ -o dist/Debug/GNU-MacOSX/callingrproject build/Debug/GNU-MacOSX/main.o -L/Library/Frameworks/R.framework/Resources/lib -L/Library/Frameworks/R.framework/Resources/library/Rcpp/lib -L/Library/Frameworks/R.framework/Resources/library/RInside/lib -L/Library/Frameworks/R.framework/Libraries -L/Library/Frameworks/R.framework/Resources/lib -L/Library/Frameworks/R.framework/Resources/library -L/Library/Frameworks/R.framework/Resources/modules -lRcpp -lRInside -lRlapack -lRblas -F/Library/Frameworks/R.framework/.. -framework R -stdlib=libstdc++
The example build was:
clang++ -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Versions/3.0/Resources/library/Rcpp/include -I/Library/Frameworks/R.framework/Versions/3.0/Resources/library/RInside/include -stdlib=libstdc++ -std=c++11 -mtune=native -g -O3 -Wall -pedantic -Wconversion -Wall -I/usr/local/include rinside_callbacks0.cpp -F/Library/Frameworks/R.framework/.. -framework R -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/Library/Frameworks/R.framework/Resources/lib -lRlapack /Library/Frameworks/R.framework/Versions/3.0/Resources/library/Rcpp/lib/libRcpp.a /Library/Frameworks/R.framework/Versions/3.0/Resources/library/RInside/lib/libRInside.a -o rinside_callbacks0