0

I added libpqxx (pqxx) via vcpkg to CMake project, however it's failed while building. Here is CMake code:

find_package(libpqxx CONFIG REQUIRED) target_link_libraries(PqDataBase PRIVATE libpqxx::pqxx) 

And included header:

#include <pqxx/pqxx> 

I tried a lot of alternatives of adding CMake, but no one works. It might need dynamic linkage, but I have no idea how it does.

Here is error message:

D:\PqDataBase>cmake --build .\build [2/2] Linking CXX executable PqDataBase.exe FAILED: PqDataBase.exe C:\windows\system32\cmd.exe /C "cd . && C:\msys64\ucrt64\bin\c++.exe CMakeFiles/PqDataBase.dir/PqDataBase.cpp.obj -o PqDataBase.exe -Wl,--out-implib,libPqDataBase.dll.a -Wl,--major-image-version,0,--minor-image-version,0 C:/vcpkg/installed/x64-windows/debug/lib/pqxx.lib -lwsock32 -lws2_32 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && C:\windows\system32\cmd.exe /C "cd /D D:\PqDataBase\build && C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -executionpolicy Bypass -file C:/vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary D:/PqDataBase/build/PqDataBase.exe -installedDir C:/vcpkg/installed/x64-windows/bin -OutVariable out"" C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/PqDataBase.dir/PqDataBase.cpp.obj:PqDataBase.cpp:(.text+0x1bd): undefined reference to `__imp__ZN4pqxx14argument_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE' C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/PqDataBase.dir/PqDataBase.cpp.obj:PqDataBase.cpp:(.text+0x311): undefined reference to `__imp__ZN4pqxx8internal18demangle_type_nameB5cxx11EPKc' C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/PqDataBase.dir/PqDataBase.cpp.obj:PqDataBase.cpp:(.text+0x345): undefined reference to `__imp__ZN4pqxx8internal18demangle_type_nameB5cxx11EPKc' C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/PqDataBase.dir/PqDataBase.cpp.obj:PqDataBase.cpp:(.text+0x379): undefined reference to `__imp__ZN4pqxx8internal18demangle_type_nameB5cxx11EPKc' C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/PqDataBase.dir/PqDataBase.cpp.obj:PqDataBase.cpp:(.text+0x3ad): undefined reference to `__imp__ZN4pqxx8internal18demangle_type_nameB5cxx11EPKc' C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/PqDataBase.dir/PqDataBase.cpp.obj:PqDataBase.cpp:(.text$_ZN4pqxx14argument_errorD1Ev[_ZN4pqxx14argument_errorD1Ev]+0xf): undefined reference to `__imp__ZTVN4pqxx14argument_errorE' collect2.exe: error: ld returned 1 exit status ninja: build stopped: subcommand failed. 
5
  • Stack Overflow discourages using images which represent textual information. Instead, copy paste error message directly to the question post, as text. See How to Ask and that question on meta. Commented May 22, 2024 at 21:37
  • You used vckg to generate msvc binaries and are now attempting to link that with MinGW. For c based code that has a chance of working for c++ its unlikely to work. Commented May 22, 2024 at 22:42
  • I used the different packages that installed via vcpkg, they work smoothly with the same environment. Commented May 23, 2024 at 17:16
  • You need to use one of the MinGW triplets and not the msvc ones: https://stackoverflow.com/questions/63031513/vcpkg-with-mingw Commented May 24, 2024 at 12:30
  • I tried it, at the moment there is issue of installing of x64-mingw-dynamic packages. Now issue is opened on github, I will try it. Thank you. Commented May 24, 2024 at 17:56

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.