SOCI / soci

Official repository of the SOCI - The C++ Database Access Library
http://soci.sourceforge.net/
Boost Software License 1.0
1.41k stars 477 forks source link

Cant use sqlstate(). Undefined reference #1143

Closed Nosferatu13666 closed 5 months ago

Nosferatu13666 commented 5 months ago

I'm trying to use sqlstate on ubuntu, making with cmake:

catch (soci::postgresql_soci_error const & e) { std::cout << e.sqlstate() << std::endl; }

There is an error: undefined reference to «soci::postgresql_soci_error::sqlstate[abi:cxx11]() const»

Other functions are work. I tryed make Soci with static build, dynamic build, both - no effect, the same error. How to fix problem?

vadz commented 5 months ago

I can't reproduce this by adding

diff --git a/tests/postgresql/test-postgresql.cpp b/tests/postgresql/test-postgresql.cpp
index 65168586..81ffe432 100644
--- a/tests/postgresql/test-postgresql.cpp
+++ b/tests/postgresql/test-postgresql.cpp
@@ -1435,5 +1435,6 @@ int main(int argc, char** argv)

     test_context tc(backEnd, connectString);

+    postgresql_soci_error e("postgresql_soci_error", "foo"); e.sqlstate();
     return Catch::Session().run(argc, argv);
 }

to the test so I can only suppose you're not linking with the right library (libsoci_postgresql.so).

Nosferatu13666 commented 5 months ago

Its done. I forgot to link "Soci_postgresql_PLUGIN" in cmake Thanks!