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

Undefined reference when building PQXX (pqxx::internal::clear_result(pg_result const*) #22

Closed
Luis-Abreu opened this issue Jul 20, 2017 · 6 comments

Comments

@Luis-Abreu
Copy link

Luis-Abreu commented Jul 20, 2017

Hi everyone,
I'm having problems testing the library, I'm getting the following error:

test_escape.o: In function `pqxx::internal::PQAlloc<pg_result const, &pqxx::internal::clear_result>::loseref()':
/libpqxx-master/test/unit/../../include/pqxx/util.hxx:609: undefined reference to `pqxx::internal::clear_result(pg_result const*)'

What I did to build the library was:
./configure --prefix=/usr/local --enable-shared
make -j8
sudo make install

@jtv
Copy link
Owner

jtv commented Jul 26, 2017

Looks like there could be a version mismatch... as of a few days ago, PQAlloc no longer exists. Is it possible that you've got an older version of the headers installed, so that the build is picking up those instead of the new ones from the version that you're trying to build?

@jtv jtv closed this as completed Sep 9, 2017
@scottfurry
Copy link

Apologies for resurrecting this thread, but it seems rather pertinent to my current situation.
I'm updating code that uses libpqxx but linking fails.
libpq ver 9.6.5 build date 2017Sep06
libpqxx ver 5.1.0 build date 2017Aug03

I don't see the "PQAlloc" notice, but I receive numerous linking errors stating "undefined reference to `pqxx::internal::clear_result(pg_result const*)'". Can you clarify, please.

@jtv
Copy link
Owner

jtv commented Oct 19, 2017

Ah, this may be that problem where I forgot to export clear_result! It's fixed in 6.0, but obviously that won't help 5.1.

In include/pqxx/result.hxx, try prefixing the clear_result declaration with PQXX_LIBEXPORT. So it becomes:
PQXX_LIBEXPORT void clear_result(const pq::PGresult *);

I believe this problem shows up only when linking dynamically against libpqxx. It may be safer to link statically — it's just so easy to sneak in a binary-incompatible change in C++!

@scottfurry
Copy link

I had already tried changing the line in include/pqxx/result.hxx without success.
This lead to creating issue #33.

@jtv
Copy link
Owner

jtv commented Oct 22, 2017

Hopefully the newly pushed 5.1 branch and updated 5.1.1 tag will solve this...

@scottfurry
Copy link

Yes - version bump solved the problem is it caught the change.

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

3 participants