AppData\Local\Temp\cc59LXDc.o:test1.cpp:对“constructNewObjectOfClass(JNIEnv_*,jthrowable**,char const*,char const*,…)和#x27”的未定义引用; :通过C++代码访问Hadoop集群文件(HDFS读/写)。Windows7操作系统。 下面是我的示例代码 #include "hdfs.h" #include "hdfs.cpp" int main(int argc, char **argv) { hdfsFS fs =hdfsConnect( "localhost" , 9000); return 0 }

AppData\Local\Temp\cc59LXDc.o:test1.cpp:对“constructNewObjectOfClass(JNIEnv_*,jthrowable**,char const*,char const*,…)和#x27”的未定义引用; :通过C++代码访问Hadoop集群文件(HDFS读/写)。Windows7操作系统。 下面是我的示例代码 #include "hdfs.h" #include "hdfs.cpp" int main(int argc, char **argv) { hdfsFS fs =hdfsConnect( "localhost" , 9000); return 0 },c++,hadoop,hdfs,libhdfs,C++,Hadoop,Hdfs,Libhdfs,注意:我已经启动并运行了单节点hadoop集群 g++ test1.cpp 获取上述命令的以下错误堆栈跟踪: C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x60): undefined r eference to `constructNewObjectOfClass(JNIEnv_*, _jthrowable**, char const*, cha r const*, ...)' C:\Users\anant\A

注意:我已经启动并运行了单节点hadoop集群

g++ test1.cpp
获取上述命令的以下错误堆栈跟踪:

C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x60): undefined r
eference to `constructNewObjectOfClass(JNIEnv_*, _jthrowable**, char const*, cha
r const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0xe1): undefined r
eference to `classNameOfObject(_jobject*, JNIEnv_*)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x242): undefined
reference to `hdfsConnectAsUser'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x296): undefined
reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x2d7): undefined
reference to `constructNewObjectOfClass(JNIEnv_*, _jthrowable**, char const*, ch
ar const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x38b): undefined
reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject*
, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x437): undefined
reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject*
, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x4cc): undefined
reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject*
, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x5e4): undefined
reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject*
, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x671): undefined
reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject*
, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x6f8): undefined
reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x77f): undefined
reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject*
, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x7e5): undefined
reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x95e): undefined
reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject*
, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0xa62): undefined
reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject*
, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0xb0f): undefined
reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject*
, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0xba0): undefined
reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject*
, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0xc45): undefined
reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject*
, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0xce9): more undef
ined references to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jo
bject*, char const*, char const*, char const*, ...)' follow
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0xe53): undefined
reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0xedd): undefined
reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0xf74): undefined
reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject*
, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0xff2): undefined
reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x10fd): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x11d8): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x1300): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x13cf): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x1522): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x1587): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x1636): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x167f): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x1710): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x17ae): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x17f8): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x189f): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x18ed): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x19ab): undefined
 reference to `constructNewObjectOfClass(JNIEnv_*, _jthrowable**, char const*, c
har const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x1a8c): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x1ad5): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x1b93): undefined
 reference to `constructNewObjectOfClass(JNIEnv_*, _jthrowable**, char const*, c
har const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x1c74): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x1cbd): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x1d54): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x1dd2): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x1eb5): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x1f57): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x1fc9): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x2057): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x212b): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x21ca): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x2224): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x22bf): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x231a): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x23b9): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x240d): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x252f): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x257e): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x25d5): undefined
 reference to `constructNewObjectOfClass(JNIEnv_*, _jthrowable**, char const*, c
har const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x267c): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x26e9): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x2818): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x28aa): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x2948): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x2a0d): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x2b48): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x2e40): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x2ebe): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x2f1a): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x2f56): undefined
 reference to `globalClassReference(char const*, JNIEnv_*)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x2ff6): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x3045): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x3081): undefined
 reference to `globalClassReference(char const*, JNIEnv_*)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x3121): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x31b2): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x3241): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x32c2): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x3347): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x33e7): more unde
fined references to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _j
object*, char const*, char const*, char const*, ...)' follow
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x3ade): undefined
 reference to `getJNIEnv()'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x3b83): undefined
 reference to `invokeMethod(JNIEnv_*, jvalue*, _jthrowable**, MethType, _jobject
*, char const*, char const*, char const*, ...)'
C:\Users\anant\AppData\Local\Temp\cc59LXDc.o:test1.cpp:(.text+0x3ce6): undefined
 reference to `getJNIEnv()'
collect2.exe: error: ld returned 1 exit status

你安装库了吗


添加链接器设置并添加链接器搜索目录。

我第一次正在执行C++代码。我已经在Windows7 64上安装了g++了。我所做的只是启动并运行了单节点hadoop,并尝试执行g++test1.cpp。请帮助完成需要采取的步骤。这是一个旧版本,但实施技术不应改变,我试着跟随你的链接。获取链接错误:/almdev/hadoop/wordcount.cpp:57:未定义对“HadoopPipes::runTask(HadoopPipes::Factory const&)”的引用,我的生成文件如下所示:CC=g++hadoop\u INSTALL=/almdev/hadoop/hadoop PLATFORM=Linux-i386-32 CPPFLAGS=-m32-I$(hadoop\u INSTALL)/c++/$(PLATFORM)/include-wordcount:wordcount.cpp$(CC)$(CPPFLAGS)$<-Wall-L$(HADOOP_安装)/c++/$(平台)/lib \-L$lib/native/hadooppipes.a-L$lib/native/hadooputils.a-lpthread-g-O2-o$@…@Rafaelappending-lcrypto解决了上述问题,创建了二进制可执行文件。@Rafael…根据您上面的链接,不再支持使用hadoop管道的执行命令。建议的带有mapred的新命令也不再使用。是否还有其他命令替代解决方案?@RafaelIn本地模式不受支持,因为Hadoop管道只能在分布式或伪分布式模式下运行。