1

我正在尝试C++使用以下编译命令编译 Hadoop wordCout 示例()

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

有谁知道哪里出了问题?

4

1 回答 1

0

检查系统中的 g++ 版本,> 版本 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”

希望这可以帮助

/乐国岛

于 2013-01-10T07:50:12.277 回答