JHUISI / charm

Charm: A Framework for Rapidly Prototyping Cryptosystems
http://charm-crypto.io
GNU Lesser General Public License v3.0
564 stars 166 forks source link

"multiple definition" error #255

Open tommasobilli opened 4 years ago

tommasobilli commented 4 years ago

Hi, I'm trying to install charm on Debian, but build is failing with a multiple definition error. Here is the ouput I'm getting:

  1. Run ./configure.sh

    Install prefix    /usr/local
    data directory    /usr/local/share/charm
    binary directory  /usr/local/bin
    library directory /usr/local/lib
    config directory  /usr/local/etc
    Source path       /home/tom/charm
    CFLAGS            -O2 -g 
    CHARM_CFLAGS       -m64 -Wall -Wundef -Wwrite-strings -Wmissing-prototypes  -fstack-protector-all -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits
    LDFLAGS           -m64 
    make              make
    python            /usr/bin/python3
    python-config     /usr/bin/python3-config
    build_ext options build_ext 
    install           install
    host CPU          x86_64
    wget              /usr/bin/wget
    gprof enabled     no
    profiler          no
    static build      no
    -Werror enabled   no
    integer module    yes
    ecc module        yes
    pairing module    yes
    disable benchmark no
    libm found        yes
    libgmp found      yes
    libpbc found      yes
    libcrypto found   yes
    Documentation     no
  2. Run make install

    /usr/bin/python3 setup.py install
    Platform: Linux
    Config file: /home/tom/charm/config.mk
    running install
    running bdist_egg
    running egg_info
    creating Charm_Crypto.egg-info
    writing Charm_Crypto.egg-info/PKG-INFO
    writing dependency_links to Charm_Crypto.egg-info/dependency_links.txt
    writing requirements to Charm_Crypto.egg-info/requires.txt
    writing top-level names to Charm_Crypto.egg-info/top_level.txt
    writing manifest file 'Charm_Crypto.egg-info/SOURCES.txt'
    package init file 'charm/schemes/prenc/__init__.py' not found (or not a regular file)
    reading manifest file 'Charm_Crypto.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching 'README'
    writing manifest file 'Charm_Crypto.egg-info/SOURCES.txt'
    installing library code to build/bdist.linux-x86_64/egg
    running install_lib
    running build_py
    copying charm/config.py -> build/lib.linux-x86_64-3.8/charm
    running build_ext
    building 'charm.core.math.pairing' extension
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DBENCHMARK_ENABLED=1 -Icharm/core/utilities/ -Icharm/core/benchmark/ -I/usr/include/python3.8 -c charm/core/math/pairing/pairingmodule.c -o build/temp.linux-x86_64-3.8/charm/core/math/pairing/pairingmodule.o
    charm/core/math/pairing/pairingmodule.c: In function ‘hash2_element_to_bytes’:
    charm/core/math/pairing/pairingmodule.c:473:15: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
    473 |  for(i = 0; i < last_buflen; i++)
      |               ^
    charm/core/math/pairing/pairingmodule.c:477:25: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
    477 |  for(i = last_buflen; i < (last_buflen + buf_len); i++)
      |                         ^
    In file included from charm/core/math/pairing/pairingmodule.c:1789:
    charm/core/benchmark/benchmark_util.c: In function ‘InitBenchmark’:
    charm/core/benchmark/benchmark_util.c:172:3: warning: ‘RAND_pseudo_bytes’ is deprecated [-Wdeprecated-declarations]
    172 |   RAND_pseudo_bytes(group->bench_id, ID_LEN);
      |   ^~~~~~~~~~~~~~~~~
    In file included from /usr/include/openssl/e_os2.h:13,
                 from /usr/include/openssl/bio.h:13,
                 from /usr/include/openssl/objects.h:14,
                 from charm/core/math/pairing/pairingmodule.h:44,
                 from charm/core/math/pairing/pairingmodule.c:30:
    /usr/include/openssl/rand.h:44:1: note: declared here
    44 | DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num))
      | ^~~~~~~~~~~~~~~~~~
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DBENCHMARK_ENABLED=1 -Icharm/core/utilities/ -Icharm/core/benchmark/ -I/usr/include/python3.8 -c charm/core/utilities/base64.c -o build/temp.linux-x86_64-3.8/charm/core/utilities/base64.o
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DBENCHMARK_ENABLED=1 -Icharm/core/utilities/ -Icharm/core/benchmark/ -I/usr/include/python3.8 -c charm/core/benchmark/benchmarkmodule.c -o build/temp.linux-x86_64-3.8/charm/core/benchmark/benchmarkmodule.o
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fwrapv -O2 -Wl,-z,relro -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.8/charm/core/math/pairing/pairingmodule.o build/temp.linux-x86_64-3.8/charm/core/utilities/base64.o build/temp.linux-x86_64-3.8/charm/core/benchmark/benchmarkmodule.o -lpbc -lgmp -lcrypto -o build/lib.linux-x86_64-3.8/charm/core/math/pairing.cpython-38-x86_64-linux-gnu.so
    /usr/bin/ld: build/temp.linux-x86_64-3.8/charm/core/benchmark/benchmarkmodule.o:/home/tom/charm/charm/core/benchmark/benchmarkmodule.h:60: multiple definition of `BenchmarkError'; build/temp.linux-x86_64-3.8/charm/core/math/pairing/pairingmodule.o:/home/tom/charm/charm/core/benchmark/benchmarkmodule.h:60: first defined here
    /usr/bin/ld: build/temp.linux-x86_64-3.8/charm/core/benchmark/benchmarkmodule.o:/home/tom/charm/charm/core/benchmark/benchmarkmodule.h:58: multiple definition of `BenchmarkType'; build/temp.linux-x86_64-3.8/charm/core/math/pairing/pairingmodule.o:/home/tom/charm/charm/core/benchmark/benchmarkmodule.h:58: first defined here
    collect2: error: ld returned 1 exit status
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    make: *** [Makefile:43: install] Error 1
kamwill commented 4 years ago

Same issues. Does anyone knows a resolve?

digital-idiot commented 4 years ago

Having the same issue, can not build successfully

lightclient commented 4 years ago

Also have this issue.

kara07 commented 3 years ago

Having the same issue, can not build successfully

dfaranha commented 3 years ago

I replaced the affected lines in benchmark_module.h with

#ifndef BENCHMARK_MODULE
// define new benchmark type for benchmark module
extern PyTypeObject BenchmarkType;
// define new benchmark error type (will be used for notifying errors)
extern PyObject *BenchmarkError;
#else
// define new benchmark type for benchmark module
PyTypeObject BenchmarkType;
// define new benchmark error type (will be used for notifying errors)
PyObject *BenchmarkError;
#endif

to conditionally compile the types only for the right source file, and this particular problem went away. However, I hit #239 and could not go further.

ajisaisena commented 2 years ago

Edited: delete 'extern' in modifition of 'benchmark_module.c'. Hey guys, I have just found the solution. Just as @dfaranha said, replace the affected lines(about 56 to 60) in benchmark_module.h with:

#ifndef BENCHMARK_MODULE
// define new benchmark type for benchmark module
extern PyTypeObject BenchmarkType;
// define new benchmark error type (will be used for notifying errors)
extern PyObject *BenchmarkError;
#else
// define new benchmark type for benchmark module
PyTypeObject BenchmarkType;
// define new benchmark error type (will be used for notifying errors)
PyObject *BenchmarkError;
#endif

But you should also modify the benchmark_module.c after include the head file:

#add after include
#ifndef BENCHMARK_MODULE
// define new benchmark type for benchmark module
PyTypeObject BenchmarkType;
// define new benchmark error type (will be used for notifying errors)
PyObject *BenchmarkError;
#endif

And you'll solve this.

jakinyele commented 2 years ago

@fremakvi can you pls submit a PR?

ajisaisena commented 2 years ago

I hit #239 when I was trying to install charm in conda base environment in this way. But when I create a new environment for charm, I installed it successfully. I'm still confused about this error.