WSL2 Berkeley DB g++ undefined reference to Db::open(DbTxn*, char const*, char const*, DBTYPE, unsigned int, int)

So, I’m trying to use Berkeley DB under WSL with g++ [11.1.0], and while trying to bind a test application I’m plagued with:

$ g++ -g -std=c++20 -I /usr/local/BerkeleyDB.18.1/include -L /usr/local/BerkeleyDB.18.1/lib/ -l 
db_cxx test.cpp
/usr/bin/ld: test.o: in function `main':
/home/codefool/work/chessgen/db/test.cpp:10: undefined reference to `Db::open(DbTxn*, char const*, 
char const*, DBTYPE, unsigned int, int)'
/usr/bin/ld: test.o: in function `__static_initialization_and_destruction_0(int, int)':
/home/codefool/work/chessgen/db/test.cpp:3: undefined reference to `Db::Db(DbEnv*, unsigned int)'
/usr/bin/ld: /home/codefool/work/chessgen/db/test.cpp:3: undefined reference to `Db::~Db()'
/usr/bin/ld: test.o:(.data.rel.local.DW.ref._ZTI11DbException[DW.ref._ZTI11DbException]+0x0): 
undefined reference to `typeinfo for DbException'
collect2: error: ld returned 1 exit status

After hours of trawling the interwebs, and finding that it’s not an uncommon problem, the usual solution is that the library is not being included. Here the library is not only being correctly included, but I dumped the symbols in the object and the library to make sure the garbled names matched.  I finally got this to build by moving the .cpp file to the start of the command line:

$ g++ test.cpp -g -std=c++20 -I /usr/local/BerkeleyDB.18.1/include -L /usr/local/BerkeleyDB.18.1/lib/ 
-l db_cxx

And thus the problem was solved.

Posted in Uncategorized | Leave a comment

Site Back Up – Wiki Will Take a Little Longer

Site has been down for a while. My web-host was bought (again) by some Vancouver-based people who raised my hosting fees from $30/year to $30/month, stopped taking PayPal, and then were surprised when I wouldn’t update my payment method. C’est la vie.

After much research I’ve decided to go with dreamhost.com, as they have a package that does what I need (for now,) gives me SSH access, and is $99 for three years, so I’m back to ~$30/year. Take that, Vancouver.

In retribution Vancouver updated my server so that none of my software works, so I’ve had to extract the data manually and reconstitute it in the new wiki. Oy.

It’s slow going – but I’ll get it back up eventually. Stay tuned.

Posted in Uncategorized | Leave a comment