I am running on Linux Ubuntu and my IDE is VS code.
At examplePlugin.Build.cs file, i think i have already added ‘include’ folder and the static library file needed.
PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "../libpqxx/include"));
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "../libpqxx/lib/libpqxx.a"));
Then I coded it at .cpp file and compiled. It got passed.
#include "pqxx/pqxx"
But once I try to call the API of that library
pqxx::connection C("dbname = postgres user = postgres password = postgres hostaddr = 127.0.0.1 port = 5432");
and do ‘make’ command under the ProjectDirector, i got these error messages.
[1/1] Link (lld) libUnrealEditor-LauPlugin.so
ld.lld: error: undefined symbol: pqxx::connection_base::close()
>>> referenced by basic_connection.hxx:70 (/home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Source/libpqxx/include/pqxx/basic_connection.hxx:70)
>>> /home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/LauPlugin/LauPlugin.cpp.o:(FLauPluginModule::StartupModule())
>>> referenced by basic_connection.hxx:70 (/home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Source/libpqxx/include/pqxx/basic_connection.hxx:70)
>>> /home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/LauPlugin/LauPlugin.cpp.o:(pqxx::basic_connection_base<pqxx::connect_direct>::~basic_connection_base())
ld.lld: error: undefined symbol: pqxx::connectionpolicy::~connectionpolicy()
>>> referenced by basic_connection.hxx:70 (/home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Source/libpqxx/include/pqxx/basic_connection.hxx:70)
>>> /home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/LauPlugin/LauPlugin.cpp.o:(FLauPluginModule::StartupModule())
>>> referenced by basic_connection.hxx:70 (/home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Source/libpqxx/include/pqxx/basic_connection.hxx:70)
>>> /home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/LauPlugin/LauPlugin.cpp.o:(pqxx::basic_connection_base<pqxx::connect_direct>::~basic_connection_base())
>>> referenced by basic_connection.hxx:61 (/home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Source/libpqxx/include/pqxx/basic_connection.hxx:61)
>>> /home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/LauPlugin/LauPlugin.cpp.o:(pqxx::basic_connection_base<pqxx::connect_direct>::basic_connection_base(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&))
ld.lld: error: undefined symbol: pqxx::connection_base::clearcaps()
>>> referenced by connection_base.hxx:765 (/home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Source/libpqxx/include/pqxx/connection_base.hxx:765)
>>> /home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/LauPlugin/LauPlugin.cpp.o:(pqxx::basic_connection_base<pqxx::connect_direct>::basic_connection_base(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&))
ld.lld: error: undefined symbol: pqxx::connectionpolicy::connectionpolicy(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
>>> referenced by connection.hxx:92 (/home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Source/libpqxx/include/pqxx/connection.hxx:92)
>>> /home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/LauPlugin/LauPlugin.cpp.o:(pqxx::basic_connection_base<pqxx::connect_direct>::basic_connection_base(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&))
ld.lld: error: undefined symbol: vtable for pqxx::connect_direct
>>> referenced by connection.hxx:92 (/home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Source/libpqxx/include/pqxx/connection.hxx:92)
>>> /home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/LauPlugin/LauPlugin.cpp.o:(pqxx::basic_connection_base<pqxx::connect_direct>::basic_connection_base(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&))
>>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)
ld.lld: error: undefined symbol: pqxx::connection_base::init()
>>> referenced by basic_connection.hxx:61 (/home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Source/libpqxx/include/pqxx/basic_connection.hxx:61)
>>> /home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/LauPlugin/LauPlugin.cpp.o:(pqxx::basic_connection_base<pqxx::connect_direct>::basic_connection_base(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&))
ld.lld: error: undefined symbol: int pqxx::internal::check_library_version<6, 4>()
>>> referenced by connection_base.hxx:762 (/home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Source/libpqxx/include/pqxx/connection_base.hxx:762)
>>> /home/laurence/Documents/Unreal Projects/MyProject2/Plugins/LauPlugin/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/LauPlugin/LauPlugin.cpp.o:(pqxx::basic_connection_base<pqxx::connect_direct>::basic_connection_base(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&))
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
It seems the include/lib didn’t work well. I don’t have ideas what to do. Please help by any chances.