RInside示例构建使用clang ++在OS X上Mavericks无法找到STL标准库链接 [英] RInside example build using clang++ on OS X Mavericks cannot find STL standard library on linking
问题描述
我最近使用OS X 10.9.1的命令行工具移动到C ++ 11和Xcode 5,使用Homebrew安装了boost 1.55,并将编译器从g ++更改为clang ++(如本帖中所述:使用Xcode 5.0和Rcpp时出错 )。编译器在R中运行时改变了固定的Rcpp。但是我在编译RInside例子时遇到问题(以前工作正常)。
I recently moved to C++11 and Xcode 5 with command line tools on OS X 10.9.1, installed boost 1.55 using Homebrew and changed the compiler from g++ to clang++ (as mentioned in this post: Error when with Xcode 5.0 and Rcpp). The compiler change fixed Rcpp when running in R. But I am having issues with compiling the RInside examples (which used to work just fine).
我重新下载RInside解压缩tar,转到examples / standard目录,并做了 make clean
和 make all
。看起来任何STL没有链接到这个目录。如何使RInside链接到合适的STL在Makefile?
I re-downloaded RInside and unzipped the tar, went to the examples/standard directory and did a make clean
and make all
. It looks like any STL is not being linked to from this directory. How do I make RInside link to the appropriate STL in the Makefile?
我在一个单独的项目中使用来自Netbeans的STL,并使用clang ++工作。但是,当我尝试在Netbeans RInside项目,我得到同样的问题:架构x86_64
未定义的符号。我需要下载64位版本的STL或RInside某处吗?
I am using STL from Netbeans in a seperate project and building using clang++ works there. However, when I try an RInside project on Netbeans I get the same issue: Undefined symbols for architecture x86_64
. Do I need to download a 64 bit version of STL or of RInside somewhere ?
我仍然需要更新/更改配置某处,我下载错误的包
Am I still in need of updating/altering a config somewhere, did I download a wrong package or is it a setting in the Makefile for the examples that needs to change?
这里是中的第一个调用make all
:
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 -mtune=native -g -O2 -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
输出的开头:
Undefined symbols for architecture x86_64:
"std::string::find_last_of(char, unsigned long) const", referenced from:
demangler_one(char const*) in libRcpp.a(api.o)
"std::string::find(char const*, unsigned long) const", referenced from:
short_file_name(char const*) in libRcpp.a(api.o)
"std::string::size() const", referenced from:
std::basic_string<char, std::char_traits<char>, std::allocator<char> > std::operator+<char, std::char_traits<char>, std::allocator<char> >(char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in libRcpp.a(api.o)
MemBuf::add(std::string const&) in libRInside.a(MemBuf.o)
"std::string::c_str() const", referenced from:
RInside::parseEval(std::string const&, SEXPREC*&) in libRInside.a(RInside.o)
SEXPREC* Rcpp::pairlist<Rcpp::Function, Rcpp::traits::named_object<SEXPREC*>, Rcpp::traits::named_object<SEXPREC*> >(Rcpp::Function const&, Rcpp::traits::named_object<SEXPREC*> const&, Rcpp::traits::named_object<SEXPREC*> const&) in libRInside.a(RInside.o)
short_file_name(char const*) in libRcpp.a(api.o)
string_to_try_error(std::string const&) in libRcpp.a(api.o)
Rcpp::RObject::AttributeProxy::set(SEXPREC*) const in libRcpp.a(api.o)
demangle(std::string const&) in libRcpp.a(api.o)
Rcpp::RObject::AttributeProxy::get() const in libRcpp.a(api.o)
错误消息:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
推荐答案
我得到了一个例子,从我的Netbeans工作后,降级到Xcode 4.6.3在OS X 10.9.1和使用clang ++和C + + 11(没有其他更改的设置在Netbeans)。它也工作在g ++(或clang ++)使用C ++ 98。看起来像Xcode 5中的默认库是 libc ++
(LLVM C ++标准库,支持C ++ 11),但我需要链接的是 libstdc ++
(GNU C ++标准库 - 早期Xcode版本的默认库)。在〜/ .R / Makevars文件中修改了之后 CXXFLAGS = - stdlib = libstdc ++ -std = c ++ 11 -mtune = native -g -O3 -Wall -pedantic -Wconversion
以及 clang ++
更改我得到了要构建的示例。我通过重新升级到Xcode 5并在Netbeans中获得相同的错误,而不是在样例(现在由于 libstdc ++
标志构建)上确认了这种行为。当我添加 -stdlib = libstdc ++
作为Netbeans中的附加标志时,它再次构建。
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.
其他人打了一个问题建立示例。在Netbeans中,编译和链接步骤是:
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++
示例build是:
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
这篇关于RInside示例构建使用clang ++在OS X上Mavericks无法找到STL标准库链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!