我目前正在尝试创建Java Freeling API,以便在Stanbol上使用它。
这样,我没有遵循Freeling文档(此处为https://github.com/insideout10/stanbol-freeling)给出的所有说明。我的JDK似乎有问题,但我真的不知道如何解决。
这就是我所做的:

步骤A,用C ++编译Freeling(这里没有问题):

A.1)安装以下软件包(使用“ sudo apt-get install”):
 -必要的
 -zlib1g-dev
 -libboost1.48-all-dev
 -自动制作
 -自动配置
 -libtool
 -libboost-regex-dev
 -libicu-dev
 -libboost-filesystem-dev
 -libboost-program-options-dev
 -痛饮

A.2)下载最新版本的冻结:
svn checkout http://devel.cpl.upc.edu/freeling/svn/trunk冻结

A.3)准备我的Freeling存储库:
本地libtoolize; autoconf;自动制作-a

4)构建并安装Freeling:
。/配置
使
须藤使安装

步骤B,编译Java API(我的问题是在此步骤中):

1)将freeling.i替换为freeling.i,位于以下位置:[url] https://raw.github.com/ziodave/freeling-brew-formula/master/APIs /common/freeling.i[/url]

2)将Makefile的参数设置为freeling / APIs / java / MakeFile

我的Makefile如下:

# Change these paths to match your installation
# Alternatively, you can call 'make' overriding variable values, E.g.:
#     make FREELINGDIR=/my/freeling/dir SWIGDIR=/my/swig/dir JAVADIR=/my/java/dir

FREELINGDIR = /home/saturn/freeling
SWIGDIR = /usr/share/swig2.0
JAVADIR = /usr/lib/jvm/jdk1.7.0_25

# you may change the package name if you want
PACKAGE = edu/upc/freeling
JPACKAGE = edu.upc.freeling

# Change your compiler, if necessary.
GCC=g++

all: freeling_javaAPI.cxx libfreeling_javaAPI.so

.PHONY: all

# Compile the C++ API
libfreeling_javaAPI.so: freeling_javaAPI.cxx
    $(GCC) -shared -o libfreeling_javaAPI.so freeling_javaAPI.cxx -lfreeling -L$(FREELINGDIR)/lib -I$(FREELINGDIR)/include -I$(JAVADIR)/include -I$(JAVADIR)/include/linux -fPIC
    $(JAVADIR)/bin/javac $(PACKAGE)/*.java
    $(JAVADIR)/bin/jar -cf freeling.jar $(PACKAGE)

# Build the Java JNI wrapper classes.
freeling_javaAPI.cxx: freeling_javaAPI.i ../common/freeling.i
    rm -rf $(PACKAGE)
    mkdir -p $(PACKAGE)
    swig -java -c++ -package $(JPACKAGE) -outdir $(PACKAGE) -o freeling_javaAPI.cxx -I$(SWIGDIR)/java -I$(SWIGDIR)/std -I$(SWIGDIR) freeling_javaAPI.i

clean:
    rm -rf *.jar *.so *.cxx *.class edu
    java -> $(JAVADIR)/bin/java
    jar -> $(JAVADIR)/bin/jar


3)运行make

我得到以下结果:

g++ -shared -o libfreeling_javaAPI.so freeling_javaAPI.cxx -lfreeling -L/usr/local/share/freeling/lib -I/usr/local/share/freeling/include -I/usr/lib/jvm/jdk1.7.0_25/include -I/usr/lib/jvm/jdk1.7.0_25/include/linux -fPIC


freeling_javaAPI.cxx: In function ‘jlong Java_edu_upc_freeling_freelingJNI_new_1TreeIteratorNode_1_1SWIG_10(JNIEnv*, jclass)’:
freeling_javaAPI.cxx:2995:3: error: ‘tree_iterator’ was not declared in this scope
freeling_javaAPI.cxx:2995:3: note: suggested alternative:
/usr/local/include/freeling/tree.h:47:7: note:   ‘freeling::tree_iterator’
freeling_javaAPI.cxx:2995:18: error: ‘node’ was not declared in this scope
freeling_javaAPI.cxx:2995:18: note: suggested alternative:
/usr/local/include/freeling/morfo/language.h:372:14: note:   ‘freeling::node’
freeling_javaAPI.cxx:2995:23: error: ‘tree’ was not declared in this scope
freeling_javaAPI.cxx:2995:23: note: suggested alternative:
/usr/local/include/freeling/tree.h:35:26: note:   ‘freeling::tree’
freeling_javaAPI.cxx:2995:36: error: expected primary-expression before ‘>’ token
freeling_javaAPI.cxx:2995:39: error: ‘result’ was not declared in this scope
freeling_javaAPI.cxx:2999:46: error: expected primary-expression before ‘>’ token
freeling_javaAPI.cxx:2999:49: error: expected primary-expression before ‘)’ token
freeling_javaAPI.cxx:2999:50: error: expected ‘;’ before ‘new’
freeling_javaAPI.cxx:3000:38: error: expected primary-expression before ‘>’ token
freeling_javaAPI.cxx:3000:42: error: expected primary-expression before ‘)’ token
freeling_javaAPI.cxx: In function ‘jlong Java_edu_upc_freeling_freelingJNI_new_1TreeIteratorNode_1_1SWIG_11(JNIEnv*, jclass, jlong, jobject)’:
freeling_javaAPI.cxx:3007:3: error: ‘tree’ was not declared in this scope
freeling_javaAPI.cxx:3007:3: note: suggested alternative:
/usr/local/include/freeling/tree.h:35:26: note:   ‘freeling::tree’
freeling_javaAPI.cxx:3007:9: error: ‘node’ was not declared in this scope
freeling_javaAPI.cxx:3007:9: note: suggested alternative:
/usr/local/include/freeling/morfo/language.h:372:14: note:   ‘freeling::node’
freeling_javaAPI.cxx:3007:17: error: ‘arg1’ was not declared in this scope
freeling_javaAPI.cxx:3007:39: error: expected primary-expression before ‘)’ token
freeling_javaAPI.cxx:3007:41: error: expected ‘;’ before numeric constant
freeling_javaAPI.cxx:3008:3: error: ‘tree_iterator’ was not declared in this scope
freeling_javaAPI.cxx:3008:3: note: suggested alternative:
[...]
Java_edu_upc_freeling_freelingJNI_ParseTree_1SWIGUpcast(JNIEnv*, jclass, jlong)’:
freeling_javaAPI.cxx:12567:7: error: ‘tree’ was not declared in this scope
freeling_javaAPI.cxx:12567:7: note: suggested alternative:
/usr/local/include/freeling/tree.h:35:26: note:   ‘freeling::tree’
freeling_javaAPI.cxx:12567:13: error: ‘node’ was not declared in this scope
freeling_javaAPI.cxx:12567:13: note: suggested alternative:
/usr/local/include/freeling/morfo/language.h:372:14: note:   ‘freeling::node’
freeling_javaAPI.cxx:12567:22: error: expected primary-expression before ‘)’ token
freeling_javaAPI.cxx:12567:36: error: ‘parse_tree’ was not declared in this scope
freeling_javaAPI.cxx:12567:36: note: suggested alternative:
/usr/local/include/freeling/morfo/language.h:423:14: note:   ‘freeling::parse_tree’
freeling_javaAPI.cxx:12567:49: error: expected primary-expression before ‘)’ token
freeling_javaAPI.cxx: In function ‘jlong Java_edu_upc_freeling_freelingJNI_Depnode_1SWIGUpcast(JNIEnv*, jclass, jlong)’:
freeling_javaAPI.cxx:12575:7: error: ‘node’ was not declared in this scope
freeling_javaAPI.cxx:12575:7: note: suggested alternative:
/usr/local/include/freeling/morfo/language.h:372:14: note:   ‘freeling::node’
freeling_javaAPI.cxx:12575:14: error: expected primary-expression before ‘)’ token
freeling_javaAPI.cxx:12575:28: error: ‘depnode’ was not declared in this scope
freeling_javaAPI.cxx:12575:28: note: suggested alternative:
/usr/local/include/freeling/morfo/language.h:452:14: note:   ‘freeling::depnode’
freeling_javaAPI.cxx:12575:38: error: expected primary-expression before ‘)’ token
freeling_javaAPI.cxx: In function ‘jlong Java_edu_upc_freeling_freelingJNI_DepTree_1SWIGUpcast(JNIEnv*, jclass, jlong)’:
freeling_javaAPI.cxx:12583:7: error: ‘tree’ was not declared in this scope
freeling_javaAPI.cxx:12583:7: note: suggested alternative:
/usr/local/include/freeling/tree.h:35:26: note:   ‘freeling::tree’
freeling_javaAPI.cxx:12583:13: error: ‘depnode’ was not declared in this scope
freeling_javaAPI.cxx:12583:13: note: suggested alternative:
/usr/local/include/freeling/morfo/language.h:452:14: note:   ‘freeling::depnode’
freeling_javaAPI.cxx:12583:25: error: expected primary-expression before ‘)’ token
freeling_javaAPI.cxx:12583:39: error: ‘dep_tree’ was not declared in this scope
freeling_javaAPI.cxx:12583:39: note: suggested alternative:
/usr/local/include/freeling/morfo/language.h:478:14: note:   ‘freeling::dep_tree’
freeling_javaAPI.cxx:12583:50: error: expected primary-expression before ‘)’ token
make: *** [libfreeling_javaAPI.so] Error 1


据我了解,Makefile只是调用JDK并遇到错误。

我尝试将JDK更改为旧版本(尝试使用JDK7,JDK6和SDK6),但结果是相同的。

有关信息,我在使用Ubuntu12.04 x64的虚拟机中工作,我还尝试使用Ubuntu12.04 x32编译Freeling,但结果是相同的。

我在.bashrc上添加了以下几行:

JAVA_HOME=/usr/lib/jvm/jdk1.7.0_25
MAVEN_OPTS="-Xmx2048m -XX:MaxPermSize=2048m"
JAVA_OPTS="-Xmx2048m -XX:MaxPermSize=2048m"
ANT_OPTS="-Xmx2048m -XX:MaxPermSize=2048m"
JVM_ARGS="-Xmx2048m -XX:MaxPermSize=2048m"
export MAVEN_OPTS
export JAVA_OPTS
export ANT_OPTS
export JVM_ARGS
export JAVA_HOME


我认为我做错了事,但我真的不知道该怎么办,我花了3天的时间才找到解决方案,但没有成功。有人可以帮我吗?

先感谢您 !

最佳答案

因此,看来您比我优越得多,但是我注意到您设置了环境变量的路径,您是否还检查以确保系统将哪个版本的Java用作默认总体?

尝试使用

sudo update-alternatives --config java


并确保使用正确的JDK。

如果您已经解决了此问题,则很想听听您的解决方案(因为您之前发布了此信息)。

关于c++ - 卡住:无法在Ubuntu上编译Java API,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17749056/

10-09 04:31