Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link error : pthread #19

Open
Hakkadaikon opened this issue Dec 1, 2023 · 0 comments
Open

Link error : pthread #19

Hakkadaikon opened this issue Dec 1, 2023 · 0 comments

Comments

@Hakkadaikon
Copy link
Contributor

Hi,
When I built nostrdb, the following link error occurred.

$ make clean; make
rm -rf test bench bench-ingest bench-ingest-many
cc -Wall -Wno-misleading-indentation -Wno-unused-function -Werror -O2 -g -Ideps/secp256k1/include -Ideps/lmdb -Ideps/flatcc/include bench.c nostrdb.c sha256.c bech32.c deps/flatcc/src/runtime/json_parser.c deps/flatcc/src/runtime/verifier.c deps/flatcc/src/runtime/builder.c deps/flatcc/src/runtime/emitter.c deps/flatcc/src/runtime/refmap.c deps/lmdb/liblmdb.a deps/secp256k1/.libs/libsecp256k1.a  -o bench
/usr/bin/ld: deps/lmdb/liblmdb.a(mdb.o): in function `mdb_txn_renew0':
/home/hakkadaikon/repos/hakkadaikon/nostrdb/deps/lmdb/mdb.c:2719: undefined reference to `pthread_getspecific'
/usr/bin/ld: /home/hakkadaikon/repos/hakkadaikon/nostrdb/deps/lmdb/mdb.c:2762: undefined reference to `pthread_setspecific'
/usr/bin/ld: deps/lmdb/liblmdb.a(mdb.o): in function `mdb_env_copythr':
/home/hakkadaikon/repos/hakkadaikon/nostrdb/deps/lmdb/mdb.c:9126: undefined reference to `pthread_sigmask'

collect2: error: ld returned 1 exit status
make: *** [Makefile:137: bench] Error 1

The problem was resolved by changing nostrdb/Makefile as follows.

--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ CFLAGS = -Wall -Wno-misleading-indentation -Wno-unused-function -Werror -O2 -g -
 HEADERS = sha256.h nostrdb.h cursor.h hex.h jsmn.h config.h sha256.h random.h memchr.h $(C_BINDINGS)
 FLATCC_SRCS=deps/flatcc/src/runtime/json_parser.c deps/flatcc/src/runtime/verifier.c deps/flatcc/src/runtime/builder.c deps/flatcc/src/runtime/emitter.c deps/flatcc/src/runtime/refmap.c
 SRCS = nostrdb.c sha256.c bech32.c $(FLATCC_SRCS)
-LDS = $(SRCS) $(ARS) 
+LDS = $(SRCS) $(ARS) -lpthread
 DEPS = $(SRCS) $(HEADERS) $(ARS)
 ARS = deps/lmdb/liblmdb.a deps/secp256k1/.libs/libsecp256k1.a 
 LMDB_VER=0.9.31

I'm using Ubuntu 20.04.

cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant