miracl / MIRACL

MIRACL Cryptographic SDK: Multiprecision Integer and Rational Arithmetic Cryptographic Library is a C software library that is widely regarded by developers as the gold standard open source SDK for elliptic curve cryptography (ECC).
https://miracl.com
655 stars 242 forks source link

Problem compiling c++ program that using MIRACL on ubuntu 14.04 #28

Closed liorko87 closed 8 years ago

liorko87 commented 8 years ago

Hi,

I'm trying to compile a very simple program that using MIRACL but I have a strange problem.

When I'm trying to compile it with cmake, I'm receiving the error: error: ‘mr_large’ does not name a type. cmake file and simple main are attached.

CMakeLists.txt

cmake_minimum_required(VERSION 3.0)
project(OS-PSI)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -maes -O3 -mavx")

include_directories($ENV{HOME}/libscapi/lib/Miracl/include)

find_library(
        LIBMIRACL
        NAMES miracl
        PATHS $ENV{HOME}/libscapi/install/lib/
        NO_DEFAULT_PATH
)

set(SOURCE_FILES main.cpp)
add_executable(OS-PSI ${SOURCE_FILES})

target_link_libraries(OS-PSI ${LIBMIRACL})

main.cpp

#include <iostream>
#include <miracl.h>
#include <mirdef.h>
#include <ecn.h>
#include <big.h>

int main(int argc, char *argv[])
{
    Big big1(12);
    int partyId = atoi(argv[1]);
    return 0;
}
mcarrickscott commented 8 years ago

Hello,

What we need to help here is your mirdef.h file.

Typically it needs to define an mr_dltype (as in the supplied mirdef.h32 file for example).

If for example you define MR_NOASM, then the library requires a dltype.

For example: If the underlying type (utype) is 32 bits, then the double length type (dltype) should be 64-bits. Using assembly language it is possible to dispense with the double-length type.

However if for example you declare a 64-bit utype, and define MR_NOASM, then there is a problem. A 128-bit dltype is required, but none is available. Note that GCC on certain 64-bit platforms DOES support a 128-bit integer type.

Mike

On Sun, Aug 21, 2016 at 6:18 AM, liorbiu notifications@github.com wrote:

Hi,

I'm trying to compile a very simple program that using MIRACL but I have a strange problem.

When I'm trying to compile it with cmake, I'm receiving the error: error: ‘mr_large’ does not name a type. cmake file and simple main are attached.

CMakeLists.txt

cmake_minimum_required(VERSION 3.0) project(OS-PSI)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -maes -O3 -mavx")

include_directories($ENV{HOME}/libscapi/lib/Miracl/include)

find_library( LIBMIRACL NAMES miracl PATHS $ENV{HOME}/libscapi/install/lib/ NO_DEFAULT_PATH )

set(SOURCE_FILES main.cpp) add_executable(OS-PSI ${SOURCE_FILES})

target_link_libraries(OS-PSI ${LIBMIRACL})

main.cpp

include

include

include

include

include

int main(int argc, char *argv[]) { Big big1(12); int partyId = atoi(argv[1]); return 0; }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/miracl/MIRACL/issues/28, or mute the thread https://github.com/notifications/unsubscribe-auth/ACm8jlzm8LFDRX2GpHTDAqmeeWagUE65ks5qh9-KgaJpZM4JpOnQ .

liorko87 commented 8 years ago

Hello,

Thank you for your reply.

mirdef.h is attached:

/* 
 *   MIRACL compiler/hardware definitions - mirdef.h
 *   This version suitable for use with most 32-bit computers
 *   e.g. 80386+ PC, VAX, ARM etc. Assembly language versions of muldiv,
 *   muldvm, muldvd and muldvd2 will be necessary. See mrmuldv.any 
 *
 *   Also suitable for DJGPP GNU C Compiler
 *   ... but change __int64 to long long
 */

#define MIRACL 32
#define MR_LITTLE_ENDIAN    /* This may need to be changed        */
#define mr_utype int
                            /* the underlying type is usually int *
                             * but see mrmuldv.any                */
#define mr_unsign32 unsigned int
                            /* 32 bit unsigned type               */
#define MR_IBITS      32    /* bits in int  */
#define MR_LBITS      32    /* bits in long */
#define MR_FLASH      52      
                            /* delete this definition if integer  *
                             * only version of MIRACL required    */
                            /* Number of bits per double mantissa */

#define mr_dltype __int64   /* ... or long long for Unix/Linux */
#define mr_unsign64 unsigned __int64

#define MAXBASE ((mr_small)1<<(MIRACL-1))
mcarrickscott commented 8 years ago

OK. The relevant code in miracl.h is

ifdef mr_dltype

typedef unsigned mr_dltype mr_large;

endif

which defines the type mr_large.

I would suspect that your compiler does not recognise "__int64"

Try "long long" instead, or int64_t. Check your compiler documentation for the signed 64-bit integer type that it supports.

Mike

On Mon, Aug 22, 2016 at 10:28 AM, liorbiu notifications@github.com wrote:

Hello,

Thank you for your reply.

mirdef.h is attached:

/*

  • MIRACL compiler/hardware definitions - mirdef.h
  • This version suitable for use with most 32-bit computers
  • e.g. 80386+ PC, VAX, ARM etc. Assembly language versions of muldiv,
  • muldvm, muldvd and muldvd2 will be necessary. See mrmuldv.any *
  • Also suitable for DJGPP GNU C Compiler
  • ... but change __int64 to long long */

define MIRACL 32

define MR_LITTLEENDIAN /* This may need to be changed /

define mr_utype int

                        /_ the underlying type is usually int *
                         \* but see mrmuldv.any                _/

define mr_unsign32 unsigned int

                        /_ 32 bit unsigned type               _/

define MRIBITS 32 / bits in int _/

define MRLBITS 32 / bits in long _/

define MR_FLASH 52

                        /_ delete this definition if integer  *
                         \* only version of MIRACL required    _/
                        /_ Number of bits per double mantissa */

define mr_dltype __int64 /* ... or long long for Unix/Linux */

define mr_unsign64 unsigned __int64

define MAXBASE ((mr_small)1<<(MIRACL-1))

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/miracl/MIRACL/issues/28#issuecomment-241359625, or mute the thread https://github.com/notifications/unsubscribe-auth/ACm8jpNNWNzvR3Ib75rNBdhyXgEQ8hqKks5qiWvFgaJpZM4JpOnQ .

liorko87 commented 8 years ago

Thanks a lot, that was the solution!