secretflow/yacl

编译tpre_test时报错

Smart-SangGe opened this issue · 5 comments

g++ tpre_test.cc -I/home/sangge/yacl -o tpre_test

In file included from /home/sangge/yacl/yacl/math/mpint/mp_int.h:25,
from /home/sangge/yacl/yacl/crypto/base/ecc/ec_point.h:21,
from /home/sangge/yacl/yacl/crypto/primitives/tpre/capsule.h:23,
from /home/sangge/yacl/yacl/crypto/primitives/tpre/tpre.h:23,
from tpre_test.cc:15:
/home/sangge/yacl/yacl/base/int128.h:110:20: error: redefinition of ‘constexpr int128_t std::abs(int128_t)’
110 | constexpr int128_t abs(int128_t x) { return x >= 0 ? x : -x; }
| ^~~
In file included from /usr/include/c++/12/cstdlib:77,
from /usr/include/c++/12/ext/string_conversions.h:41,
from /usr/include/c++/12/bits/basic_string.h:3960,
from /usr/include/c++/12/string:53,
from /usr/include/c++/12/bits/locale_classes.h:40,
from /usr/include/c++/12/bits/ios_base.h:41,
from /usr/include/c++/12/ios:42,
from /usr/include/c++/12/ostream:38,
from /usr/include/c++/12/iostream:39,
from /home/sangge/yacl/yacl/crypto/primitives/tpre/tpre.h:17:
/usr/include/c++/12/bits/std_abs.h:85:3: note: ‘constexpr __int128 std::abs(__int128)’ previously defined here
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -x; }
| ^~~
In file included from /home/sangge/yacl/yacl/crypto/base/ecc/any_ptr.h:22,
from /home/sangge/yacl/yacl/crypto/base/ecc/ec_point.h:20:
/home/sangge/yacl/yacl/math/mpint/mp_int.h: In member function ‘std::size_t std::hashyacl::math::MPInt::operator()(const yacl::math::MPInt&) const’:
/home/sangge/yacl/yacl/math/mpint/mp_int.h:392:22: error: ‘mp_hash’ was not declared in this scope; did you mean ‘hash’?
392 | MPINT_ENFORCE_OK(mp_hash(&x.n
, &h));
| ^~~~~~~
/home/sangge/yacl/yacl/base/exception.h:353:52: note: in definition of macro ‘YACL_ENFORCE_THAT_IMPL’
353 | ::yacl::enforce_detail::EnforceFailMessage r(condition);
| ^~~~~~~~~
/home/sangge/yacl/yacl/math/mpint/mp_int_enforce.h:26:3: note: in expansion of macro ‘YACL_ENFORCE_EQ’
26 | YACL_ENFORCE_EQ((MP_ERR), MP_OKAY, VA_ARGS)
| ^~~~~~~~~~~~~~~
/home/sangge/yacl/yacl/math/mpint/mp_int.h:392:5: note: in expansion of macro ‘MPINT_ENFORCE_OK’
392 | MPINT_ENFORCE_OK(mp_hash(&x.n
, &h));

第二个错误解决了,我安装的tommath是1.2.0版,而好像只有develop branch 有mp_hash这个函数.

@Smart-SangGe 请用 bazel 来 build targets

@anakinxc 我在bazel-bin里面找到了这个tpre-test. 那么如果我想用这个库来写点别的代码,我应该怎么编译和链接呢

@anakinxc 我在bazel-bin里面找到了这个tpre-test. 那么如果我想用这个库来写点别的代码,我应该怎么编译和链接呢

你可以在 bazel 里添加新的 targets

@anakinxc 明白了, 感谢.