Rich
Rich

Reputation: 1779

JPype compile problems

I'm having a right old nightmare with JPype. I have got my dev env on Windows and so tried installing it there with no luck. I then tried on Ubunto also with no luck. I'm getting a bit desperate now. I am using Mingw32 since I tried installing VS2008 but it told me I had to install XP SP2 but I am on Vista. I tried VS2010 but no luck, I got the 'error: Unable to find vcvarsall.bat' error. Anyway, I am now on Mingw32

Ultimately I am trying to use Neo4j and Python hence my need to use JPype. I have found so many references to the problem on the net for MySQL etc but they don't help me with JPype.

If I could fix unix or windows I could get going so help on either will be really appreciated.

Here's the versions..

Windows: Vista 64 Python: 2.6 Compiler Mingw32: latest version Jpype: 0.5.4.1 Java info: java version "1.6.0_13" Java(TM) SE Runtime Environment (build 1.6.0_13-b03) Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)

I run:

python setup.py install --compiler=wingw32

and get the following output.

Choosing the Windows profile running install running build running build_py running build_ext building '_jpype' extension C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -DWIN32=1 "-IC:\Program Files (x86)\Java\jdk1.6.0_21/include" "-IC:\Program Files (x86)\Java\jdk1.6.0_21/include/win32" -Isrc/native/common/include -Isrc/native/python/include -Ic:\Python26\include -Ic:\Python26\PC -c src/native/common/jp_array.cpp -o build\temp.win32-2.6\Release\src\native\common\jp_array.o /EHsc src/native/common/jp_array.cpp: In member function 'void JPArray::setRange(int, int, std::vector&)': src/native/common/jp_array.cpp:56:13: warning: comparison between signed and unsigned integer expressions src/native/common/jp_array.cpp:68:4: warning: deprecated conversion from string constant to 'char*' src/native/common/jp_array.cpp: In member function 'void JPArray::setItem(int, HostRef*)': src/native/common/jp_array.cpp:80:3: warning: deprecated conversion from string constant to 'char*' gcc: /EHsc: No such file or directory error: command 'gcc' failed with exit status 1

So on unix Ubunto the problem is as follows:

Java version: 1.6.0_18 JPype: 0.5.4.1 Python: 2.6

Java is in the path and I did apt-get install build-essentials just now so have latest GCC etc.

I won't paste all the output as it's massive. So many errors it's like I have missed the install of Java or similar but I haven't. typing java takes me into version above. This is the beginning:

running install running build running build_py running build_ext building '_jpype' extension gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include -I/usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include/linux -Isrc/native/common/include -Isrc/native/python/include -I/usr/include/python2.6 -c src/native/common/jp_javaenv_autogen.cpp -o build/temp.linux-i686-2.6/src/native/common/jp_javaenv_autogen.o cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ In file included from src/native/common/jp_javaenv_autogen.cpp:21: src/native/common/include/jpype.h:45:17: error: jni.h: No such file or directory In file included from src/native/common/jp_javaenv_autogen.cpp:21: src/native/common/include/jpype.h:77: error: ISO C++ forbids declaration of ‘jchar’ with no type src/native/common/include/jpype.h:77: error: expected ‘,’ or ‘...’ before ‘’ token src/native/common/include/jpype.h:82: error: ISO C++ forbids declaration of ‘jchar’ with no type src/native/common/include/jpype.h:82: error: expected ‘;’ before ‘’ token src/native/common/include/jpype.h:86: error: ISO C++ forbids declaration of ‘jchar’ with no type src/native/common/include/jpype.h:86: error: expected ‘;’ before ‘&’ token src/native/common/include/jpype.h:88: error: expected ‘;’ before ‘private’ src/native/common/include/jpype.h:89: error: ISO C++ forbids declaration of ‘jchar’ with no type src/native/common/include/jpype.h:89: error: expected ‘;’ before ‘*’ token In file included from src/native/common/include/jpype.h:96, from src/native/common/jp_javaenv_autogen.cpp:21:

And this is the end:

src/native/common/include/jp_monitor.h:27: error: ‘jobject’ does not name a type src/native/common/jp_javaenv_autogen.cpp:30: error: ‘jbyte’ does not name a type src/native/common/jp_javaenv_autogen.cpp:38: error: ‘jbyte’ does not name a type src/native/common/jp_javaenv_autogen.cpp:45: error: variable or field ‘SetStaticByteField’ declared void src/native/common/jp_javaenv_autogen.cpp:45: error: ‘jclass’ was not declared in this scope src/native/common/jp_javaenv_autogen.cpp:45: error: ‘jfieldID’ was not declared in this scope src/native/common/jp_javaenv_autogen.cpp:45: error: ‘jbyte’ was not declared in this scope error: command 'gcc' failed with exit status 1

Upvotes: 3

Views: 3890

Answers (3)

mvillegas
mvillegas

Reputation: 123

I had the same error on Linux. It worked for me just executing

export JAVA_HOME=/usr/lib/[*your_java_folder*]

Look at setup.py line 45:

def setupLinux(self):        
self.javaHome = os.getenv("JAVA_HOME")
if self.javaHome is None :
    self.javaHome = '/usr/lib/jvm/java-1.5.0-sun-1.5.0.08' # Ubuntu linux

Upvotes: 3

user408847
user408847

Reputation:

Edit the Setup.py and remove the /EHsc option.

Upvotes: 1

Jim Brissom
Jim Brissom

Reputation: 32919

gcc: /EHsc: No such file or directory error: command 'gcc' failed with exit status 1

EHsc is a compiler switch specific to the Microsoft toolchain. which is why you are getting this error. You are mixing toolchains somewhere, somehow - maybe some leftover files from a previous attempt? I would have to download JPype myself to verify building with mingw32.

You do know that you can download a JPype binary distribution for Python 2.6 and Pytho 2.5, though?

As for your *NIX build, you are missing the Java/JNI development headers, so the Java types for C are unavailable and the compiler is unable to recognize them. Install the dev package and make sure your toolchain is able to find them.

Upvotes: 1

Related Questions