-1
I am developing an altcoin using a new PoW algorithm which is written in C to test the algorithm. I get compilation errors related to compiling the C code when trying to compile. How can I properly add the C code to the Makefile?
My fork is based of Bitcoin Core 0.12.1 I am compiling on Ubuntu 16.04
Here is the compilation error:
CXXLD bitcoind
/usr/bin/ld: crypto/libbitcoin_crypto.a(crypto_libbitcoin_crypto_a-
rainforest.o): relocation R_X86_64_32S against `rf_crc32_table' can not be
used when making a shared object; recompile with -fPIC
crypto/libbitcoin_crypto.a: error adding symbols: Bad value
Here is how I added the files to src/Makefile.am:
# crypto primitives library
crypto_libbitcoin_crypto_a_CPPFLAGS = $(AM_CPPFLAGS)
$(BITCOIN_CONFIG_INCLUDES)
crypto_libbitcoin_crypto_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
crypto_libbitcoin_crypto_a_SOURCES = \
crypto/common.h \
crypto/hmac_sha256.cpp \
crypto/hmac_sha256.h \
crypto/hmac_sha512.cpp \
crypto/hmac_sha512.h \
crypto/ripemd160.cpp \
crypto/ripemd160.h \
crypto/sha1.cpp \
crypto/sha1.h \
crypto/sha256.cpp \
crypto/sha256.h \
crypto/sha512.cpp \
crypto/sha512.h \
crypto/rainforest/rainforest.c \
crypto/rainforest/rainforest.h
The files are rainforest.c and rainforest.h
Sorry for this question, I am a newbie in C and C++ developing, I come from Java and Python
EDIT: I didn't mention before that I linked rainforest.h by doing this:
extern "C"{
#include "crypto/rainforest/rainforest.h"
}
What/of which type is rf_crc32_tabl? – MCCCS – 2019-01-07T09:55:26.317
@MCCCS It is declared as
const uint32_t rf_crc32_table[256]– EndlessLoop – 2019-01-07T15:01:31.497If you include the functions with extern "C", then you should also declare them with extern "C" in the source file. Although your file is a c file, keep in mind that it'll be compiled by the cpp compiler. – MCCCS – 2019-01-07T15:09:04.537
@MCCCS Tried that, got the same error, not sure what to do but I think there may be a way to change the makefile so the compiler properly compiles – EndlessLoop – 2019-01-07T20:05:57.600