我正在尝试使用以下编译命令编译Hadoop wordCout示例(C++
)
g++ -o a -L/home/pc/run/hadoop-install/hadoop/lib/native -lhadooppipes -lhadooputils -lpthread -I/home/pc/run/hadoop-install/hadoop/include wordCount.cpp -Wall
Hadoop版本为0.23.5。
操作系统是Ubuntu 12.04
但是,我收到如下链接错误:
g++ -o a -L/home/pc/run/hadoop-install/hadoop/lib/native -lhadooppipes -lhadooputils -lpthread -I/home/pc/run/hadoop-install/hadoop\
/include wordCount.cpp -Wall
6/tmp/cc3Cte9z.o: In function `main':
7wordCount.cpp:(.text+0x26): undefined reference to `HadoopPipes::runTask(HadoopPipes::Factory const&)'
8/tmp/cc3Cte9z.o: In function `WordCountMap::map(HadoopPipes::MapContext&)':
9wordCount.cpp:(.text._ZN12WordCountMap3mapERN11HadoopPipes10MapContextE[WordCountMap::map(HadoopPipes::MapContext&)]+0x2e): undefin\
ed reference to `HadoopUtils::splitString(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const\
*)'
10/tmp/cc3Cte9z.o: In function `WordCountReduce::reduce(HadoopPipes::ReduceContext&)':
11wordCount.cpp:(.text._ZN15WordCountReduce6reduceERN11HadoopPipes13ReduceContextE[WordCountReduce::reduce(HadoopPipes::ReduceContext\
&)]+0x26): undefined reference to `HadoopUtils::toInt(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&\
)'
12wordCount.cpp:(.text._ZN15WordCountReduce6reduceERN11HadoopPipes13ReduceContextE[WordCountReduce::reduce(HadoopPipes::ReduceContext\
&)]+0x5b): undefined reference to `HadoopUtils::toString(int)'
13collect2: ld returned 1 exit status
14make: *** [a] Error 1
任何人都知道哪里出错了?
答案 0 :(得分:0)
检查系统中的g ++版本,&gt;版本4,源文件的名称放在库链接的前面。因此,在您的系统中,正确的顺序可能是:
“g ++ wordCount.cpp -oa -L / home / pc / run / hadoop-install / hadoop / lib / native -lhadooppipes -lhadooputils -lpthread -I / home / pc / run / hadoop-install / hadoop / include -Wall“
希望这有帮助
/ Le Quoc Do