[users] Bug in libpqxx (related to visibility)

Filipe Brandenburger filbranden at gmail.com
Tue Apr 7 03:58:47 CEST 2009


I am migrating some programs that use libpqxx from CentOS 4 to CentOS
5, and I found an issue with libpqxx-2.6.9 from RPMforge.

I built a Python module that uses the library. However, in Python 5,
when I try to load it, I get this error:

ImportError: libxxx.so: undefined symbol:

I rebuilt the RPM, and I traced the issue to the warnings I get when
building the library:

../include/pqxx/result.hxx:63: warning: lowering visibility of 'void
pqxx::internal::freemem_result_data(pqxx::internal::result_data*)' to
match its type

And more, I saw that the RPM removes the -Werror that the library uses
to build by default (which prevents the library from building cleanly
under CentOS 5).

Googling for the error message, I found that it was a "feature"
introduced in GCC 4.1 that ships with CentOS 5, and that it was
actually retracted in later versions, however the issue is still
present in CentOS 5 (even in 5.3):

I compared the code with the includes in libpqxx-3.0, and I saw that
there they explicitely set the visibility.

So I came up with a patch that actually fixes the issue. I'm pasting it here:

====================> cut patch <====================
diff -Naur libpqxx-2.6.9.orig/include/pqxx/prepared_statement.hxx
--- libpqxx-2.6.9.orig/include/pqxx/prepared_statement.hxx
2007-01-29 14:18:52.000000000 -0500
+++ libpqxx-2.6.9/include/pqxx/prepared_statement.hxx   2009-04-06
21:27:43.000000000 -0400
@@ -141,7 +141,7 @@
 namespace internal
 /// Internal representation of a prepared statement definition
-struct PQXX_PRIVATE prepared_def
+struct PQXX_LIBEXPORT prepared_def
   /// Parameter definition
   struct param
diff -Naur libpqxx-2.6.9.orig/include/pqxx/result.hxx
--- libpqxx-2.6.9.orig/include/pqxx/result.hxx  2007-01-29
14:18:52.000000000 -0500
+++ libpqxx-2.6.9/include/pqxx/result.hxx       2009-04-06
21:27:14.000000000 -0400
@@ -60,7 +60,7 @@

-void freemem_result_data(result_data *) throw ();
+void PQXX_LIBEXPORT freemem_result_data(result_data *) throw ();
 template<> inline
 void PQAlloc<result_data>::freemem() throw () { freemem_result_data(m_Obj); }
 } // namespace internal
====================> cut patch <====================

Another issue with that RPM is that it is not easy to upgrade it,
since if you create a 3.0 RPM of libpqxx with the libpqxx-3.0.so file,
all the programs already linked to libpqxx-2.6.9.so will become
broken. I guess the right thing to do in this case would be creating
an RPM with the version on the name, like libpqxx_2_6_9.rpm or
something like that.

More information about the users mailing list