I have seen a lot of similar posts, but tried every trick in the book and am still struggling. Everything was working fine, but after installing/removing wireshark with some
I have found the solution; setting the -Wl,--no-as-needed before -ldl The new compile command is
gcc main.cpp -lsqlapi -lstdc++ -Wl,--no-as-needed -ldl
Apparently it has something to do with recent versions of gcc/ld default to linking with --as-needed.