Necesito ayuda para agregar archivos a la base del código agregándolos al sistema de compilación de autotools. Otras publicaciones que intentan responder la misma pregunta no me han ayudado. Estoy experimentando con la base de código de Bitcoin y estoy tratando de agregar nuevos archivos a la base de código. Estoy tratando de agregar una biblioteca estática en src/Makefile.am agregando estas líneas:
LIBGLYPH=libglyph.a
libglyph_a_SOURCES = \
glyph/glp.c \
glyph/glp_utils.c \
glyph/glp_rand.c \
glyph/glp_rand_openssl_aes.c \
glyph/FFT/FFT_1024_65537.c \
glyph/converter.c
libglyph_a_CPPFLAGS = $(AM_CPPFLAGS)
libglyph_a_CFLAGS =
libglyph_a_CXXFLAGS = $(AM_CXXFLAGS)
EXTRA_LIBRARIES += \
$(LIBBITCOIN_CRYPTO) \
$(LIBBITCOIN_UTIL) \
$(LIBBITCOIN_COMMON) \
$(LIBGLYPH) \
$(LIBBITCOIN_CONSENSUS) \
$(LIBBITCOIN_SERVER) \
$(LIBBITCOIN_CLI) \
$(LIBBITCOIN_WALLET) \
$(LIBBITCOIN_ZMQ)
bitcoin_tx_LDADD = \
$(LIBUNIVALUE) \
$(LIBBITCOIN_COMMON) \
$(LIBBITCOIN_UTIL) \
$(LIBBITCOIN_CONSENSUS) \
$(LIBBITCOIN_CRYPTO) \
$(LIBGLYPH) \
$(LIBSECP256K1)
bitcoind_LDADD = \
$(LIBBITCOIN_SERVER) \
$(LIBBITCOIN_COMMON) \
$(LIBUNIVALUE) \
$(LIBBITCOIN_UTIL) \
$(LIBBITCOIN_WALLET) \
$(LIBBITCOIN_ZMQ) \
$(LIBBITCOIN_CONSENSUS) \
$(LIBBITCOIN_CRYPTO) \
$(LIBLEVELDB) \
$(LIBLEVELDB_SSE42) \
$(LIBMEMENV) \
$(LIBGLYPH) \
$(LIBSECP256K1)
Probé al menos 30 intentos de compilación diferentes en los que reordené la compilación y/o cambié el nombre de la biblioteca.
Error:
make[3]: Entering directory '/home/joe/glyph/glyphCodebase/BitcoinUnlimited/src/secp256k1'
make[3]: Leaving directory '/home/joe/glyph/glyphCodebase/BitcoinUnlimited/src/secp256k1'
CXXLD bitcoind
libbitcoin_common.a(libbitcoin_common_a-key.o): In function `CKey::MakeNewKey()':
/home/joe/glyph/glyphCodebase/BitcoinUnlimited/src/key.cpp:25: undefined reference to `glp_gen_sk(glp_signing_key_st*)'
libbitcoin_common.a(libbitcoin_common_a-key.o): In function `CKey::GetPubKey() const':
/home/joe/glyph/glyphCodebase/BitcoinUnlimited/src/key.cpp:48: undefined reference to `glp_gen_pk(glp_public_key_st*, glp_signing_key_st)'
collect2: error: ld returned 1 exit status
Makefile:3556: recipe for target 'bitcoind' failed
make[2]: *** [bitcoind] Error 1
make[2]: Leaving directory '/home/joe/glyph/glyphCodebase/BitcoinUnlimited/src'
Makefile:9207: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/joe/glyph/glyphCodebase/BitcoinUnlimited/src'
Makefile:670: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
Este error ocurre a pesar de que se ha creado libglyph.a y contiene las funciones. Intenté agregar el encabezado de la biblioteca y los archivos C a la biblioteca común sin suerte tampoco. He reorganizado la sección EXTRA_LIBRARIES de Makefile.am sin suerte.
Para simplificar el problema, aquí hay un ejemplo realmente simple que escupe el mismo error:
Agregar 1 archivo .h y 1 .cpp a 1 biblioteca ya creada: libbitcoin_common archivos nuevos:src/testFile.cpp src/testFile.h
archivo de prueba.h:
void testFunction();
testFile.cpp
#include "testFile.h"
#include <stdio.h>
void testFunction() {
printf("I am a test function");
}
agregó las siguientes líneas a key.cpp:
#include "testFile.h"
void CKey::MakeNewKey()
{
testFunction();
...
...
...
}
Luego en src/Makefile.am
BITCOIN_CORE_H = \
testFile.h \
...
...
y testFile a la biblioteca común, donde está key.cpp, como lo menciona Pieter Wuille aquí
# common: shared between bitcoind, and bitcoin-qt and non-server tools
libbitcoin_common_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
libbitcoin_common_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_common_a_SOURCES = \
amount.cpp \
base58.cpp \
chainparams.cpp \
coins.cpp \
compressor.cpp \
core_read.cpp \
core_write.cpp \
keystore.cpp \
netaddress.cpp \
netbase.cpp \
protocol.cpp \
scheduler.cpp \
script/sign.cpp \
script/standard.cpp \
key.cpp \
testFile.cpp \
$(BITCOIN_CORE_H)
El error:
libbitcoin_common.a(libbitcoin_common_a-key.o): In function
`CKey::MakeNewKey()':
/home/joe/glyph/glyphCodebase/BitcoinUnlimited/src/key.cpp:23: undefined reference to `testFunction()
Por favor, me ayudas con ésto. Muchas gracias
Agregar un solo archivo de origen y encabezado es más fácil que agregar una nueva biblioteca.
Para un archivo fuente único, el archivo debe estar antes que cualquier archivo que dependa de él. Entonces, en tu ejemplo, deberías tener
...
testFile.cpp \
key.cpp \
...
Pero realmente está tratando de agregar una nueva biblioteca. Para hacer eso, debe agregarlo a bitcoind_LDADD
lo que está más abajo en Makefile.am
. De esa manera el enlazador sabe enlazarlo. Para el enlazador, las dependencias deben colocarse después de las cosas que dependen de él. Entonces, solo puede agregar $(LIBGLYPH)
al final de esa lista debería funcionar.
Hubo 2 problemas con el código:
Para cualquiera que quiera ver mi makefile.am, vaya aquí: https://drive.google.com/file/d/1eB_EnxfSG1erRgDpDNgU_q-PzPQYs0hp/view?usp=sharing
Los sistemas de construcción son notoriamente frustrantes. Si tienes dudas, deja un comentario o pregúntame.
jose n
CKey::MakeNewKey()': /home/joe/glyph/glyphCodebase/BitcoinUnlimited/src/key.cpp:23: undefined reference to
testFunction()'jose n
andres chow
bitcoin_tx_LDADD
también. ¿Puede actualizar su pregunta con el resultado completo del comando make?andres chow
autogen.sh
yconfigure
después de modificar el archivo MAKE?jose n
andres chow
EXTRA_LIBRARIES
, ¿ha intentado poner libglyph antes de libbitcoin_common?jose n
jose n