),
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 its the problem of C++ library or
NTL library path,,,but I can't figure out it.
////////////////////////////////////////////////////////////////////////////////////////////
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 suggestion is appreciated!
Thank you so much!
Best,
Lichang