[Libpqxx-general] Problem with the tests using Visual Studio 2008 and libpqxx version 3.0

Andrew Maclean andrew.amaclean at gmail.com
Mon Jan 5 21:36:04 UTC 2009


Firstly I built version 3.0 of libpqxx and postgresql 8.3.5 with no
problems following the instructions using Visual Studio 2008.
However when running the tests the nmake file does not work. I note
that there is a ticket for this problem. Make clean also needs to be
fixed in

this file too.

As an alternative, I created a CMake file and two auxillary files to
find postgresql and libpqxx and used these to generate the test
executable.

The advantage here is that the make files or ide files are created
automatically and it is cross platform, removing the need to maintain
the make
files. A second advantage is that CMake knows about the platform you
are building on so you can automatically set the various conditions
for the
platform/compiler. It can also produce make files or ide files for
cross platform compiling. As as aside, when using Linux, make files or
files for the kdevelop ide are generated.

To use it do the following steps after installing CMake, available
from www.cmake.org:

Firstly, drop the three attached files into the test directory.
Then create a build directory (it can be a subdirectory of test) and
run CMake in it. I called the directory: build. You may need to
specify the
Postgresql include directory and the libpqxx include directory. Note
that the static build for the tests is on by default.

If you look at CMakeLists.txt notice that I have commented out tests
046,067,069,070,072,073,074,075,084,087,088,092 because of the visual
studio dynamic build problem regarding linking as ourtlined below. I
have also set the project name to teas_libpqxx but you can change it
to runner if
you want.

When using Visual Studio, do the following:

In the property pages for the executable, test_libpxxx in this case.
You may need to set the environment in order to run the tests.

So:
right-click on test_libpqxx and select Properties, then Debugging.
Find Environment on the page and enter the following lines into it. If
you click on the far right of the line a dialog will come up letting
you enter the folowing lines.


PGDATABASE=
<the name of the database>
PGPASSWORD=<the password>


The press F7 to build the project.

You will also need to do this for the Release build.

If you change from static to dynamic, then you should delete the bin
subdirectory directory in the build directory ans recompile.


Problems:
The debug, static version of all the tests will build Ok.
The release, static version will build but not run.
If you select debug or release, dynamic build then the following
linker errors arise for tests
046,067,069,070,072,073,074,075,084,087,088,092:

error LNK2019: unresolved external symbol "void __cdecl
pqxx::internal::throw_null_conversion(class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > const &)"
(?throw_null_conversion at internal@pqxx@@YAXABV?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@@Z)
referenced in function "public: static bool __cdecl
pqxx::string_traits<bool>::null(void)" (?
null@?$string_traits at _N@pqxx@@SA_NXZ)

Note that once these tests are excluded from the build, then the
release, static version will also run Ok. So there is a definite
problem relating to throw_null_conversion() not appearing in the
libraries.


As an aside. we develop for Linux 32/64-bit, XP, Vista, QNX using many
different compilers. So whilst not enforcing the use of CMake it
became apparent that this was the only efficient way to undertake
cross-platform development. Most of our people use CMake and they
generally undergo a conversion from automake tools when discovering
that their code won't compile easily in Windows! Along with CMake we
use CTest so that when a developer submits code to the subversion
repository CTest detects this and the code is tested on all platforms
within 10 minutes of submission. Thus we detect errors relatively
quickly. CMake is also tested in the same way, look at the dashboard
for it.
The two files FindPostgreSQL.cmake and FindLibpqxx.cmake were written
by myself to make usage of your library simple.


Andrew



-- 
___________________________________________
Andrew J. P. Maclean
Centre for Autonomous Systems
The Rose Street Building J04
The University of Sydney  2006  NSW
AUSTRALIA
Ph: +61 2 9351 3283
Fax: +61 2 9351 7474
URL: http://www.acfr.usyd.edu.au/
___________________________________________


More information about the Libpqxx-general mailing list