Lots of proplem when I use Native Client with HElib library(including NTL library and GMP library)

72 views
Skip to first unread message

Lichang Wang

unread,
Nov 23, 2015, 8:38:16 PM11/23/15
to Native-Client-Discuss
Hello,

I was new to Native-Client, when I try Native-Client wihout HElib library(https://github.com/shaih/HElib), it works fine. But, when I introduced HElib library to my Native-Client application, the  pnacl-clang++ compiler always reports error.
It takes me a lot of time, but still can't be solved. The HElib also worked fine without Native_Client. I think it the problem of C++ library or NTL library path,,,but I can't figure out it.

Thank you in advance for any help !!

Here is the Makefile:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

      FILE := temple
 17
 18 THIS_MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
 19 NACL_SDK_ROOT ?= $(abspath $(dir $(THIS_MAKEFILE))../)
 20
 21 #all:
 22 #       @echo  $(MAKEFILE_LIST)
 23 #       @echo  $(THIS_MAKEFILE)
 24 #       @echo  $(NACL_SDK_ROOT)
 25
 26 # Project Build flags
 27 WARNINGS := -Wno-long-long -Wall -Wswitch-enum -pedantic -Werror
 28 CLANGFLAGS := --pnacl-allow-native -std=gnu++11 -stdlib=libc++  -arch x86_64 #-DBOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK=1 -DB    OOST_HAS_GETTIMEOFDAY=1  -pthread -std=gnu++11  $(WARNINGS)
 29
 30 #
 31 # Compute tool paths
 32 #
 33 GETOS := python $(NACL_SDK_ROOT)/tools/getos.py
 34 OSHELPERS = python $(NACL_SDK_ROOT)/tools/oshelpers.py
 35 OSNAME := $(shell $(GETOS))
 36 RM := $(OSHELPERS) rm
 37
 38 PNACL_TC_PATH := $(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_pnacl)
 39 PNACL_CXX := $(PNACL_TC_PATH)/bin/pnacl-clang++
 40 PNACL_FINALIZE := $(PNACL_TC_PATH)/bin/pnacl-finalize

      HOMOMOR_ST_LIB := $(NACL_SDK_ROOT)/wlc_Homomorphic/HomomoLib/HElib-master/src/fhe.a
 43 HOMOMOR_FLAGS := -I/usr/local/include -I$(NACL_SDK_ROOT)/wlc_Homomorphic/HomomoLib/HElib-master/src
 44 HOMOMOR_LDFLAGS := -L/usr/local/lib  -lntl -lgmp -lm
 45
 46 CXXFLAGS := -I$(NACL_SDK_ROOT)/include
 47 LDFLAGS := -L$(NACL_SDK_ROOT)/lib/pnacl/Release -lppapi_cpp -lppapi
 48
 49 # Disable DOS PATH warning when using Cygwin based tools Windows
 50 #
 51 CYGWIN ?= nodosfilewarning
 52 export CYGWIN
 53
 54
 55 # Declare the ALL target first, to make the 'all' target the default build
 56 all: $(FILE).pexe
 57
 58 clean:
 59         $(RM) $(FILE).pexe $(FILE).bc
 60
 61 $(FILE).bc: $(FILE).cc
 62         $(PNACL_CXX) $(CLANGFLAGS)   -o $@ $< -O2 $(HOMOMOR_ST_LIB) $(HOMOMOR_FLAGS)  $(HOMOMOR_LDFLAGS)  $(CXXFLAGS) $(LDFLAG    S)
 63 $(FILE).pexe: $(FILE).bc
 64         $(PNACL_FINALIZE) -o $@ $<  
////////////////////////////////////////////////////////////////////////////////////////////////////////////

Below is trouble shot:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////

/home/lichang/NativeClient/nacl_sdk/pepper_46/toolchain/linux_pnacl/bin/pnacl-clang++ --pnacl-allow-native -std=gnu++11 -stdlib=libc++  -arch x86_64    -o homomoEncryption.bc homomoEncryption.cc -O2 /home/lichang/NativeClient/nacl_sdk/pepper_46/wlc_Homomorphic/HomomoLib/HElib-master/src/fhe.a -I/usr/local/include -I/home/lichang/NativeClient/nacl_sdk/pepper_46/wlc_Homomorphic/HomomoLib/HElib-master/src  -L/usr/local/lib  -lntl -lgmp -lm    -I/home/lichang/NativeClient/nacl_sdk/pepper_46/include   -L/home/lichang/NativeClient/nacl_sdk/pepper_46/lib/pnacl/Release -lppapi_cpp -lppapi


In file included from homomoEncryption.cc:11:
In file included from /usr/local/include/NTL/ZZ.h:19:
/usr/local/include/NTL/tools.h:234:32: warning: shift count >= width of type
      [-Wshift-count-overflow]
   { unsigned long y = a;  x = NTL_ULONG_TO_LONG(y); }
                               ^~~~~~~~~~~~~~~~~~~~
/usr/local/include/NTL/ctools.h:273:26: note: expanded from macro 'NTL_ULONG_TO_LONG'
   ((((unsigned long) a) >> (NTL_BITS_PER_LONG-1)) ? \
                         ^  ~~~~~~~~~~~~~~~~~~~~~
In file included from homomoEncryption.cc:11:
In file included from /usr/local/include/NTL/ZZ.h:19:
/usr/local/include/NTL/tools.h:237:10: warning: shift count >= width of type
      [-Wshift-count-overflow]
   { x = NTL_ULONG_TO_LONG(a); }
         ^~~~~~~~~~~~~~~~~~~~
/usr/local/include/NTL/ctools.h:273:26: note: expanded from macro 'NTL_ULONG_TO_LONG'
   ((((unsigned long) a) >> (NTL_BITS_PER_LONG-1)) ? \
                         ^  ~~~~~~~~~~~~~~~~~~~~~
In file included from homomoEncryption.cc:11:
In file included from /usr/local/include/NTL/ZZ.h:19:
/usr/local/include/NTL/tools.h:245:35: warning: shift count >= width of type
      [-Wshift-count-overflow]
   { unsigned long y = a;  return NTL_ULONG_TO_LONG(y); }
                                  ^~~~~~~~~~~~~~~~~~~~

/usr/local/include/NTL/sp_arith.h:748:41: warning: shift count >= width of type
      [-Wshift-count-overflow]
   unsigned long rr = (cast_unsigned(b) << NTL_SP_NBITS) - cast_unsigned(q)*cas...
                                        ^  ~~~~~~~~~~~~                            ^
In file included from homomoEncryption.cc:11:
In file included from /usr/local/include/NTL/ZZ.h:20:
/usr/local/include/NTL/vector.h:414:20: warning: overflow in expression; result is
      2147483632 with type 'long' [-Winteger-overflow]
/usr/local/include/NTL/ctools.h:251:5: note: expanded from macro 'NTL_SNS_REALLOC'
   (NTL_OVERFLOW1(n, a, b) ? ((void *) 0) : \
    ^
/usr/local/include/NTL/ctools.h:165:34: note: expanded from macro 'NTL_OVERFLOW1'
    (((long) (n)) >= (NTL_OVFBND1-((long)(b))+((long)(a))-1)/((long)(a))))))
                                 ^
26 warnings generated.
/usr/local/lib/libntl.a(thread.o): error: undefined reference to 'std::string::assign(char const*, unsigned long)'
/usr/local/lib/libntl.a(fileio.o): error: undefined reference to 'std::string::append(std::string const&)'
/usr/local/lib/libntl.a(fileio.o): error: undefined reference to 'std::basic_iostream<char, std::char_traits<char> >::~basic_iostream()'
/usr/local/lib/libntl.a(fileio.o): error: undefined reference to 'std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_stringstream()'
/usr/local/lib/libntl.a(fileio.o): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'

/usr/local/lib/libntl.a(GF2EXFactoring.o): error: undefined reference to 'std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()'
/usr/local/lib/libntl.a(GF2EXFactoring.o): error: undefined reference to 'std::basic_filebuf<char, std::char_traits<char> >::~basic_filebuf()'

/usr/local/lib/libntl.a(GF2EXFactoring.o): error: undefined reference to 'std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*)'
/usr/local/lib/libntl.a(GF2EXFactoring.o): error: undefined reference to 'vtable for std::basic_ios<char, std::char_traits<char> >'

/home/lichang/NativeClient/nacl_sdk/pepper_46/wlc_Homomorphic/HomomoLib/HElib-master/src/fhe.a(NumbTh.o): error: undefined reference to 'std::cerr'
/home/lichang/NativeClient/nacl_sdk/pepper_46/wlc_Homomorphic/HomomoLib/HElib-master/src/fhe.a(NumbTh.o): error: undefined reference to 'std::istream::get()'
/home/lichang/NativeClient/nacl_sdk/pepper_46/wlc_Homomorphic/HomomoLib/HElib-master/src/fhe.a(NumbTh.o): error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/home/lichang/NativeClient/nacl_sdk/pepper_46/wlc_Homomorphic/HomomoLib/HElib-master/src/fhe.a(NumbTh.o): error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
/home/lichang/NativeClient/nacl_sdk/pepper_46/wlc_Homomorphic/HomomoLib/HElib-master/src/fhe.a(NumbTh.o): error: undefined reference to 'std::string::assign(std::string const&)'
/home/lichang/NativeClient/nacl_sdk/pepper_46/wlc_Homomorphic/HomomoLib/HElib-master/src/fhe.a(NumbTh.o): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/home/lichang/NativeClient/nacl_sdk/pepper_46/wlc_Homomorphic/HomomoLib/HElib-master/src/fhe.a(NumbTh.o): error: undefined reference to 'std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/home/lichang/NativeClient/nacl_sdk/pepper_46/wlc_Homomorphic/HomomoLib/HElib-master/src/fhe.a(NumbTh.o): error: undefined reference to 'std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)'
.............
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Any suggestions is appreciate!

Thank you so much!

Best,

Lichang





Derek Schuff

unread,
Dec 1, 2015, 1:48:48 PM12/1/15
to Native-Client-Discuss
Why are you using the --pnacl-allow-native and -arch x86_64 flags?

If you want native (non-pnacl) object files, it would be easier and probably faster to use nacl-clang (the executable name is i686-nacl-clang, arm-nacl-clang, and x86_64-nacl-clang in the same directory as pnacl-clang). If you are using the SDK makefiles, that's the clang-newlib toolchain.

I didn't look in detail at your linker issue, but the -arch flag changes the default linker paths for pnacl-clang, so I would suggest first deciding on pure PNaCl to build a pexe file (with optional use of pnacl-translate to get nexe files at the end), or nacl-clang to build nexe files, and then going from there.

--
You received this message because you are subscribed to the Google Groups "Native-Client-Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to native-client-di...@googlegroups.com.
To post to this group, send email to native-cli...@googlegroups.com.
Visit this group at http://groups.google.com/group/native-client-discuss.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages