Closed mxaddict closed 3 years ago
Issue I'm having is that when I think against the generated libmcl.a
from the cmake build, It does not have the mclBnG1_clear
function
But I see that mcl/build/lib/libmclbn256.so
contains it
I was able to build static libs by editing the CMakeList.txt and chaging the following:
diff --git a/src/mcl/CMakeLists.txt b/src/mcl/CMakeLists.txt
index c4eb3e89..9526f236 100644
--- a/src/mcl/CMakeLists.txt
+++ b/src/mcl/CMakeLists.txt
@@ -320,7 +320,7 @@ endif()
# mclbnXXX
foreach(bit IN ITEMS 256 384 384_256)
- add_library(mclbn${bit} SHARED src/bn_c${bit}.cpp)
+ add_library(mclbn${bit} STATIC src/bn_c${bit}.cpp)
add_library(mcl::mclbn${bit} ALIAS mclbn${bit})
set_target_properties(mclbn${bit} PROPERTIES
CXX_STANDARD 11
Maybe adding those as static to the repo for cmake builds would be a nice addition, I can create a PR that allows for it if you like.
Thank you for the advice. How about https://github.com/herumi/mcl/commit/10183458d3d4ff81d52c4f96bf3ef0ae6da1de87 ?
That looks good, but I think you will also have to add -fPIC
when building static bn_
libs
I don't think that -fPIC
is necessary for a static library. src/fp.cpp is compiled with -fPIC
for a shard-library. What do you have some problem when -fPIC
is not be added?
I don't think that
-fPIC
is necessary for a static library. src/fp.cpp is compiled with-fPIC
for a shard-library. What do you have some problem when-fPIC
is not be added?
Yeah, I think I ran into an issue with linking when -fPIC was not added.
I'll test it out and get some more details to post here
Issue I'm having is that when I think against the generated libmcl.a from the cmake build, It does >not have the mclBnG1_clear function
But I see that mcl/build/lib/libmclbn256.so contains it
Could you please link both -lmcl and -lmclbn256? Or https://github.com/herumi/bls-eth-go-binary/tree/master/bls/lib/linux/amd64 contains all functions in both mcl and mclbn384_256.
Actually, you can check how we are compiling and linking the lib here: https://github.com/navcoin/navcoin-core/pull/775
Files of note are in the configure.ac
and the changes to src/mcl/CMakeList.txt
I've appended -fPIC
to CMakeLists.txt.
I'm trying to build mcl lib with static libs when using the cmake to build, I don't get all the bn*.a files
But when building with just the Makefile setup, I see these:
On cmake build, I only get: