jzmq icon indicating copy to clipboard operation
jzmq copied to clipboard

Build error on ubuntu 14.04 with libzmq3

Open buksy opened this issue 9 years ago • 9 comments

When try to build from the latest master getting the following error

Curve.cpp:34:55: error: 'zmq_curve_keypair' was not declared in this scope
     int rc = zmq_curve_keypair (public_key, secret_key);
                                                       ^
Curve.cpp: In function '_jbyteArray* Java_org_zeromq_ZMQ_00024Curve_z85Decode(JNIEnv*, jclass, jstring)':
Curve.cpp:70:48: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
     if (NULL == zmq_z85_decode (out_key, in_key)) {
                                                ^
In file included from Curve.cpp:20:0:
/usr/include/zmq.h:400:21: error:   initializing argument 2 of 'uint8_t* zmq_z85_decode(uint8_t*, char*)' [-fpermissive]
 ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, char *string);

The latest version of libzmq in ubuntu is libzmq3

ii  libzmq3:amd64                         4.0.4+dfsg-2                          amd64        lightweight messaging kernel (shared library)
ii  libzmq3-dev:amd64                     4.0.4+dfsg-2                          amd64        lightweight messaging kernel (development files)

/usr/include/zmq.h:#define ZMQ_VERSION_MAJOR 4
/usr/include/zmq.h:#define ZMQ_VERSION_MINOR 0
/usr/include/zmq.h:#define ZMQ_VERSION_PATCH 4

The issue here is the following code segment

f18cd0fe (David Jelenc 2015-09-20 02:15:30 +0200  61) JNIEXPORT jbyteArray JNICALL
f18cd0fe (David Jelenc 2015-09-20 02:15:30 +0200  62) Java_org_zeromq_ZMQ_00024Curve_z85Decode(JNIEnv *env, jclass cls, jstring key)
f18cd0fe (David Jelenc 2015-09-20 02:15:30 +0200  63) {
f18cd0fe (David Jelenc 2015-09-20 02:15:30 +0200  64) #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4,0,0)
f18cd0fe (David Jelenc 2015-09-20 02:15:30 +0200  65)     const char *in_key = env->GetStringUTFChars (key, NULL);
f18cd0fe (David Jelenc 2015-09-20 02:15:30 +0200  66)     assert (in_key);
f18cd0fe (David Jelenc 2015-09-20 02:15:30 +0200  67) 
f18cd0fe (David Jelenc 2015-09-20 02:15:30 +0200  68)     uint8_t out_key [32];
f18cd0fe (David Jelenc 2015-09-20 02:15:30 +0200  69) 
f18cd0fe (David Jelenc 2015-09-20 02:15:30 +0200  70)     if (NULL == zmq_z85_decode (out_key, in_key)) {

Which checks for the version more than 4.0.0 which is correct, but the /usr/include/zmq.h is looking for a signature with char * not a const char *

/*  Encode a binary key from printable text per ZMQ RFC 32  */
ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, char *string);

buksy avatar Oct 01 '15 16:10 buksy

Similar problems with fedora 22, using zeromq 4.0.5

Hacked to compile, below. Note, that zmq changed the signature (so should #ifdef or something) in 4.0: uint8_t *zmq_z85_decode (uint8_t *dest, char *string); in 4.1: uint8_t *zmq_z85_decode (uint8_t *dest, const char *string);

diff --git a/src/main/c++/Curve.cpp b/src/main/c++/Curve.cpp
index 78884e0..66b1b5a 100644
--- a/src/main/c++/Curve.cpp
+++ b/src/main/c++/Curve.cpp
@@ -18,6 +18,7 @@
 */

 #include <zmq.h>
+#include <zmq_utils.h>
 #include <assert.h>
 #include "jzmq.hpp"
 #include "util.hpp"
@@ -67,7 +68,7 @@ Java_org_zeromq_ZMQ_00024Curve_z85Decode(JNIEnv *env, jclass cls, jstring key)

     uint8_t out_key [32];

-    if (NULL == zmq_z85_decode (out_key, in_key)) {
+    if (NULL == zmq_z85_decode (out_key, (char *)in_key)) {
         env->ReleaseStringUTFChars (key, in_key);
         return NULL;
     }

brandon733 avatar Oct 17 '15 06:10 brandon733

If you can send a pull request, it would be much appreciated

trevorbernard avatar Oct 17 '15 15:10 trevorbernard

Still broken for Debian make, without this patch.

jack9 avatar Feb 02 '16 20:02 jack9

Java tests fail for me after patch is applied :panda_face: @jack9 were you running with tests enabled? (ie not using -DskipTests=true)

davidsiefert avatar Feb 12 '16 19:02 davidsiefert

testCurveBinaryKeys(org.zeromq.ZMQTest)  Time elapsed: 0.007 sec  <<< ERROR!
org.zeromq.ZMQException: Invalid argument
        at org.zeromq.ZMQ$Socket.setLongSockopt(Native Method)
        at org.zeromq.ZMQ$Socket.setCurveServer(ZMQ.java:1377)
        at org.zeromq.ZMQTest.testCurveBinaryKeys(ZMQTest.java:933)

testKeyEncodeDecode(org.zeromq.ZMQTest)  Time elapsed: 0.001 sec  <<< ERROR!
org.zeromq.ZMQException: Operation not supported
        at org.zeromq.ZMQ$Curve.generateKeyPair(Native Method)
        at org.zeromq.ZMQTest.testKeyEncodeDecode(ZMQTest.java:972)

testCurveZ85Keys(org.zeromq.ZMQTest)  Time elapsed: 0.001 sec  <<< ERROR!
org.zeromq.ZMQException: Operation not supported
        at org.zeromq.ZMQ$Curve.generateKeyPair(Native Method)
        at org.zeromq.ZMQTest.testCurveZ85Keys(ZMQTest.java:882)

davidsiefert avatar Feb 12 '16 19:02 davidsiefert

I had to apply 2 changes (one in autogen.sh one in Curve.cpp). My fork https://github.com/jack9/jzmq build successfully on debian and I'm using it.

jack9 avatar Feb 12 '16 20:02 jack9

I get those 3 test failures on master

jasongoodwin avatar Feb 17 '16 00:02 jasongoodwin

@jack9 Would you send a pull request?

msteinhoff avatar Feb 17 '16 23:02 msteinhoff

Same problem here (Ubuntu 14.4 & libzmq 4.1.4). Same failing tests (testCurveBinaryKeys, testKeyEncodeDecode and testCurveZ85Keys).

Any news update about a fix?

Thank you.

cabrinoob avatar Mar 02 '16 13:03 cabrinoob