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

Having trouble linking on RHEL 8.6 #608

Closed
argo1221 opened this issue Oct 27, 2022 · 5 comments
Closed

Having trouble linking on RHEL 8.6 #608

argo1221 opened this issue Oct 27, 2022 · 5 comments

Comments

@argo1221
Copy link

I am trying to compile and link this older version, because our customer is using a version of RHEL that uses an older gcc.
Here are my includes:
#include <libpq-fe.h>
#include <pqxx/pqxx>

Here is the code. This was put in as a placeholder just to get thing up and running:
pqxx::connection c("dbname=onc user=postgres hostaddr=10.17.12.69 port=5432");
//pqxx::work w(c);
I am eventually going to connect to a different IP address and modify an existing table.
This is what happens when I try to build it.

oceus/OCEUS_OSUtils.o: In function pqxx::basic_connection_base<pqxx::connect_direct>::~basic_connection_base()': OCEUS_OSUtils.cpp:(.text._ZN4pqxx21basic_connection_baseINS_14connect_directEED2Ev[_ZN4pqxx21basic_connection_baseINS_14connect_directEED2Ev]+0x15): undefined reference to pqxx::connection_base::close()'
oceus/OCEUS_OSUtils.o: In function pqxx::basic_connection_base<pqxx::connect_direct>::basic_connection_base(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': OCEUS_OSUtils.cpp:(.text._ZN4pqxx21basic_connection_baseINS_14connect_directEEC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN4pqxx21basic_connection_baseINS_14connect_directEEC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x6c): undefined reference to pqxx::connection_base::init()'
oceus/OCEUS_OSUtils.o: In function pqxx::connection_base::connection_base(pqxx::connectionpolicy&)': OCEUS_OSUtils.cpp:(.text._ZN4pqxx15connection_baseC2ERNS_16connectionpolicyE[_ZN4pqxx15connection_baseC2ERNS_16connectionpolicyE]+0xf5): undefined reference to int pqxx::internal::check_library_version<6, 4>()'
OCEUS_OSUtils.cpp:(.text._ZN4pqxx15connection_baseC2ERNS_16connectionpolicyE[_ZN4pqxx15connection_baseC2ERNS_16connectionpolicyE]+0x128): undefined reference to pqxx::connection_base::clearcaps()' oceus/OCEUS_OSUtils.o: In function pqxx::connect_direct::connect_direct(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)':
OCEUS_OSUtils.cpp:(.text._ZN4pqxx14connect_directC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN4pqxx14connect_directC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x1d): undefined reference to pqxx::connectionpolicy::connectionpolicy(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' OCEUS_OSUtils.cpp:(.text._ZN4pqxx14connect_directC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN4pqxx14connect_directC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x28): undefined reference to vtable for pqxx::connect_direct'
oceus/OCEUS_OSUtils.o: In function pqxx::connect_direct::~connect_direct()': OCEUS_OSUtils.cpp:(.text._ZN4pqxx14connect_directD2Ev[_ZN4pqxx14connect_directD2Ev]+0x11): undefined reference to pqxx::connectionpolicy::~connectionpolicy()'
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [make-linux.mk:350: one] Error 1
make[1]: Leaving directory '/Projects/oncast_sandbox/zerotierone'
make: *** [make-linux.mk:392: central-controller] Error 2
make: Leaving directory '/Projects/oncast_sandbox/zerotierone'

Here is the relevant section of the makefile:
central-controller: FORCE
make -j4 LDLIBS="-L/usr/local/pgsql/lib/ -lpq -L/usr/local/lib/ -Lext/librabbitmq/centos_x64/lib/ -lrabbitmq" CXXFLAGS="-I/usr/local/pgsql/include -I./ext/librabbitmq/centos_x64/include -fPIC" DEFS="-DZT_CONTROLLER_USE_LIBPQ -DZT_CONTROLLER" ZT_OFFICIAL=1 ZT_USE_X64_ASM_ED25519=1 one

I have built postgresql 10.22 from source, as well as libpqxx.

The libpxx libraries are installed at /usr/local/lib.
If you have any clues as to what is going on I would appreciate it.
Thanks!!

@tt4g
Copy link
Contributor

tt4g commented Oct 27, 2022

It looks like pqxx is not linked by LDLIBS.

@jtv
Copy link
Owner

jtv commented Oct 28, 2022

That is an old libpqxx version indeed. Off the top of my head, I'd guess it was 6.x at the latest, compiling with C++11 or older. Just as a suggestion, there may be a backported version of gcc — although of course your customer may have rules that prohibit backports.

As @tt4g said, you don't seem to be linking in libpqxx at all! Link -lpqxx first, then -lpq. It looks as if that would fix the problems we're seeing here.

On a side note... Don't include <libpq-fe.h>. The libpqxx source code will do that as needed, and the libpqxx headers don't even need it at all. Once you have libpqxx compiled, you could theoretically build your application without the postgres headers installed anywhere. (Unless the application itself makes use of the C-level libpq API separately from its use of libpqxx, of course.)

@jtv
Copy link
Owner

jtv commented Nov 2, 2022

@argo1221 does this solve your problem?

@github-actions
Copy link

github-actions bot commented Jan 2, 2023

There has been no activity on this ticket. Consider closing it.

@jtv
Copy link
Owner

jtv commented Jan 2, 2023

OK, OK, we'll close it then.

@jtv jtv closed this as completed Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants