web3labs / crux

Data Privacy for Quorum Blockchains
https://www.web3labs.com
Apache License 2.0
53 stars 28 forks source link

Berkeley DB error when trying to build crux #16

Open yghazi opened 6 years ago

yghazi commented 6 years ago

I'm trying to build crux on ubuntu 16.04. The make command fails with this log:

# github.com/blk-io/crux/vendor/github.com/jsimonetti/berkeleydb
bdb.c: In function ‘go_db_cursor’:
bdb.c:78:38: warning: passing argument 3 of ‘dbp->cursor’ from incompatible pointer type [-Wincompatible-pointer-types]
         ret = dbp->cursor(dbp, NULL, dbcp, 0);
                                      ^
bdb.c:78:38: note: expected ‘DBC ** {aka struct __dbc **}’ but argument is of type ‘DBC * {aka struct __dbc *}’

The repo (github.com/jsimonetti/berkeleydb) has been archived and is no longer being maintained. I've managed to solve the issue locally but I think it would be a good idea to fork it and fix dependencies.

conor10 commented 6 years ago

Is the build failing or are you just getting a warning? The challenge is that we want to retain BerkeleyDB support in Crux for the time being.

yghazi commented 6 years ago

The build was failing. I think you'd be better off forking the lib github.com/jsimonetti/berkeleydb and updating the code. I could do it, if you want, since I have already resolved this.

conor10 commented 6 years ago

Great - please do submit a PR.

0zAND1z commented 6 years ago

Hi @yghazi , changing the import spec to github.com/block360/berkeleydb is not yet solving the problem. Still getting 9 errors. Is this still WIP? Pls help, thx.

Puneetha17 commented 6 years ago

Hi @kggp1995 Can you please specify the error log? Is it wrt to berkeleydb?

0zAND1z commented 6 years ago

@Puneetha17 , yes.

Here's a copy from my console:

$ go get github.com/block360/berkeleydb
# github.com/block360/berkeleydb
../../../go/src/github.com/block360/berkeleydb/bdb.go:44:7: could not determine kind of name for C.DBC
../../../go/src/github.com/block360/berkeleydb/bdb.go:19:15: could not determine kind of name for C.DB_CREATE
../../../go/src/github.com/block360/berkeleydb/bdb.go:20:15: could not determine kind of name for C.DB_EXCL
../../../go/src/github.com/block360/berkeleydb/bdb.go:25:16: could not determine kind of name for C.DB_INIT_MPOOL
../../../go/src/github.com/block360/berkeleydb/bdb.go:33:14: could not determine kind of name for C.DB_QUEUE
../../../go/src/github.com/block360/berkeleydb/bdb.go:21:15: could not determine kind of name for C.DB_RDONLY
../../../go/src/github.com/block360/berkeleydb/bdb.go:22:15: could not determine kind of name for C.DB_TRUNCATE
../../../go/src/github.com/block360/berkeleydb/bdb.go:34:14: could not determine kind of name for C.DB_UNKNOWN
../../../go/src/github.com/block360/berkeleydb/bdb.go:53:9: could not determine kind of name for C.db_create
../../../go/src/github.com/block360/berkeleydb/bdb.go:229:27: could not determine kind of name for C.db_full_version
../../../go/src/github.com/block360/berkeleydb/bdb.go:245:9: could not determine kind of name for C.db_strerror
../../../go/src/github.com/block360/berkeleydb/bdb.go:210:9: could not determine kind of name for C.go_cursor_get_first
../../../go/src/github.com/block360/berkeleydb/bdb.go:221:9: could not determine kind of name for C.go_cursor_get_last
../../../go/src/github.com/block360/berkeleydb/bdb.go:188:9: could not determine kind of name for C.go_cursor_get_next
../../../go/src/github.com/block360/berkeleydb/bdb.go:199:9: could not determine kind of name for C.go_cursor_get_prev
../../../go/src/github.com/block360/berkeleydb/bdb.go:172:9: could not determine kind of name for C.go_db_cursor

clang errors for preamble:
In file included from ../../../go/src/github.com/block360/berkeleydb/bdb.go:6:
./bdb.h:5:29: error: expected parameter declarator
extern int go_db_open(DB *, DB_TXN *, char *, char *, DBTYPE, u_int32_t, int);
                            ^
/usr/include/db.h:93:17: note: expanded from macro 'DB_TXN'
#define DB_TXN          0x80000000      /* Do transactions. */
                        ^
In file included from ../../../go/src/github.com/block360/berkeleydb/bdb.go:6:
./bdb.h:5:29: error: expected ')'
/usr/include/db.h:93:17: note: expanded from macro 'DB_TXN'
#define DB_TXN          0x80000000      /* Do transactions. */
                        ^
./bdb.h:5:22: note: to match this '('
extern int go_db_open(DB *, DB_TXN *, char *, char *, DBTYPE, u_int32_t, int);
                     ^
./bdb.h:11:24: error: unknown type name 'DB_ENV'
extern int go_env_open(DB_ENV *, char *, u_int32_t, u_int32_t);
                       ^
./bdb.h:12:25: error: unknown type name 'DB_ENV'
extern int go_env_close(DB_ENV *, u_int32_t);
                        ^
./bdb.h:19:24: error: unknown type name 'DBC'
int go_db_cursor(DB *, DBC **);
                       ^
./bdb.h:20:24: error: unknown type name 'DBC'
int go_cursor_get_next(DBC *, char *, char *);
                       ^
./bdb.h:21:24: error: unknown type name 'DBC'
int go_cursor_get_prev(DBC *, char *, char *);
                       ^
./bdb.h:22:25: error: unknown type name 'DBC'
int go_cursor_get_first(DBC *, char *, char *);
                        ^
./bdb.h:23:24: error: unknown type name 'DBC'
int go_cursor_get_last(DBC *, char *, char *);
                       ^
9 errors generated.
Puneetha17 commented 6 years ago

To build Crux we dont need to do go get github.com/block360/berkeleydb You can install berkeleydb using sudo apt-get update -qq && apt-get install -y -qq libdb-dev libpthread-stubs0-dev and run make setup && make, it will pull down all the dependencies and execute.

0zAND1z commented 6 years ago

@Puneetha17 , thanks for that headsup. Mac users can install berkeleydb using: brew install berkeley-db4 and brew link berkeley-db4 --force

However, I am now encountering a new error this time for make setup && make:

$ make setup && make
go get -u github.com/golang/dep/cmd/dep
go get -u golang.org/x/tools/cmd/goimports
go get -u github.com/wadey/gocovmerge
(cd /Users/<DIR>/crux/.GOPATH/src/github.com/blk-io/crux && ./bin/dep ensure)
# github.com/blk-io/crux/vendor/github.com/block360/berkeleydb
.GOPATH/src/github.com/blk-io/crux/vendor/github.com/block360/berkeleydb/bdb.go:229:27: could not determine kind of name for C.db_full_version
make: *** [build] Error 2
Puneetha17 commented 6 years ago

Can you reset Crux to use github.com/jsimonetti/berkeleydb instead of github.com/block360/berkeleydb?

There should be no build errors using github.com/jsimonetti/berkeleydb

0zAND1z commented 6 years ago

@Puneetha17 , still no luck. I hope I have setup the right dependencies via homebew?

Puneetha17 commented 6 years ago

@kggp1995 I wonder there is something wrong with the berkelydb installation. Can you remove the berkeleydb references from the GOPATH?

schroedingerscode commented 5 years ago

I am seeing the same warn, however I believe it is just a warning.

Looks like berkeleydb is no longer maintained, however, so having it as a build dependency is probably not ideal long term. https://github.com/jsimonetti/berkeleydb/issues/1