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

linking to shared lib fails on github master but succeeds on svn trunk #31

Closed
rocksolidwebdesign opened this issue Oct 8, 2017 · 2 comments

Comments

@rocksolidwebdesign
Copy link
Contributor

rocksolidwebdesign commented Oct 8, 2017

here is the example test case C++ source code I'm using for foo.cpp

#include "pqxx/pqxx"

#include <iostream>

int main()
{
	auto conn_string = "dbname=foo user=foo password=foo";
	auto sql = "SELECT 1";

	pqxx::result rs;
	try {
		pqxx::connection conn(conn_string);
		pqxx::work w(conn);
		rs = w.exec(sql);
		w.commit();
	} catch (const std::exception &e) {
		std::cout << "Exception:\n" << e.what() << std::endl;
	}

	return 0;
}

I'm using the following process, which successfully compiles (and runs) foo.cpp against the shared lib version as of svn trunk 1945 but fails when using the latest github master

git clone https://github.com/jtv/libpqxx
cd libpqxx
CXXFLAGS="-std=c++11 -DPQXX_SHARED -g" ./configure --disable-documentation --enable-shared=yes --enable-static=no --prefix=$HOME/local
make
make install
cd ~/pqxx_foo_test
g++ foo.cpp -v -o foo -std=c++11 -I$HOME/local/include -L$HOME/local/lib -DPQXX_SHARED -lpqxx -lpq && ./foo

the build of libpqxx completes successfully but in the last step, where I compile foo.cpp using g++ compilation succeeds but linking fails with the following error

In function `pqxx::result::make_data_pointer(pg_result const*)': /home/me/local/include/pqxx/result.hxx:203: undefined reference to `pqxx::internal::clear_result(pg_result const*)'

NOTE: it appears that -DPQXX_SHARED is not required on linux because compiling svn trunk and compiling my example foo.cpp against the shared svn trunk works with or without this flag. reading the docs, it is not clear to me whether this directive is required on windows only, or at all, I am including it when building both svn trunk and github master, nothing appears to change if I leave it out

my gcc version information

g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

compiling github master statically and linking foo.cpp to libpqxx statically succeeds

@rocksolidwebdesign rocksolidwebdesign changed the title cannot compile against shared libs linking to shared lib fails on github master but succeeds on svn trunk Oct 8, 2017
jtv added a commit that referenced this issue Oct 12, 2017
@jtv
Copy link
Owner

jtv commented Oct 12, 2017

It could be simply that I neglected to export clear_result. I've fixed that; could you try again? It's possible that we'll hit more of these cases.

@rocksolidwebdesign
Copy link
Contributor Author

fix confirmed on Mac OS X Sierra and Ubuntu 16.04, thanks!

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

2 participants