ikalchev / kpabe-yct14-cpp

A lightweight Key-Policy Attribute-Based Encryption scheme in C++
Apache License 2.0
19 stars 4 forks source link

Build error using SContruct.py #1

Closed p-dealwis closed 6 years ago

p-dealwis commented 6 years ago

I got the following error when trying to compile.

g++ -o kpabe_test kpabe_test.o -L. -L/usr/local/lib -lpbc -lgmp -lmbedcrypto -lm -lkpabe -lboost_unit_test_framework
./libkpabe.a(kpabe.o): In function `element_pow_zn':
kpabe.cpp:(.text+0x52): undefined reference to `__gmpz_init'
kpabe.cpp:(.text+0x7c): undefined reference to `__gmpz_clear'
./libkpabe.a(kpabe.o): In function `getPairing()':
kpabe.cpp:(.text+0x1f2): undefined reference to `pairing_init_set_str'
./libkpabe.a(kpabe.o): In function `hashElement(element_s*, unsigned char*)':
kpabe.cpp:(.text+0x250): undefined reference to `mbedtls_md_info_from_type'
kpabe.cpp:(.text+0x261): undefined reference to `mbedtls_md'
./libkpabe.a(kpabe.o): In function `mbedtlsSymCrypt(unsigned char const*, unsigned long, unsigned char*, unsigned char*, unsigned long*, mbedtls_operation_t)':
kpabe.cpp:(.text+0x2ac): undefined reference to `mbedtls_cipher_info_from_type'
kpabe.cpp:(.text+0x2bc): undefined reference to `mbedtls_cipher_setup'
kpabe.cpp:(.text+0x2d4): undefined reference to `mbedtls_cipher_setkey'
kpabe.cpp:(.text+0x303): undefined reference to `mbedtls_cipher_crypt'
collect2: error: ld returned 1 exit status
scons: *** [kpabe_test] Error 1
scons: building terminated because of errors.

I have the mbedtls headers in /usr/include/mbedtls/ and /usr/local/include/mbedtls/

p-dealwis commented 6 years ago

Found the fix for the problem. The command: g++ -o kpabe_test kpabe_test.o -L. -L/usr/local/lib -lpbc -lgmp -lmbedcrypto -lm -lkpabe -lboost_unit_test_framework does not work, but instead running this: g++ -o kpabe_test kpabe_test.o -L. -L/usr/local/lib -lm -lkpabe -lboost_unit_test_framework -lpbc -lgmp -lmbedcrypto works.

The GMP, PBC and lmbedcrypto (-lpbc -lgmp -lmbedcrypto) libraries need to be added at the end of the command. The scons file should be fixed accordingly.

ikalchev commented 6 years ago

Hi and thanks for reporting this. I will look into it and address this in the following days.

ikalchev commented 6 years ago

@p-dealwis The original compiles fine on macOS with clang, as it appears lib order is irrelevant for Apple's ld. Could you confirm you hit this issue with GCC?

p-dealwis commented 6 years ago

Hi @ikalchev , I am using Ubuntu and yes GCC. I modified the python file to make it work successfully, easy fix.

ikalchev commented 6 years ago

Ok, thanks for that. Pushing soon.