The IDE is VS Code and compiler kit is VS Community 2019 amd64.
I have downloaded the pqxx source from github.
I copied the source tree inside root directory of my console project. I used the instructions provided in BUILDING-cmake.md. I am using option A mentioned in the said file to include pqxx in my project. So, I added following lines to main CMakeLists.txt :
add_subdirectory(libpqxx build-pqxx) #libpqxx is the directory containing pqxx source tree
target_link_libraries(myProject PRIVATE pqxx)
After this step, include directive for pqxx #include <pqxx/pqxx>
does not give error in the IDE (VS Code) or at compile time. The project builds fine and runs as expected.
The problem arises when I use following code in the source of my project :
pqxx::connection dbConn("user=postgres "
"host=192.168.1.10 "
"password=Abc@123 "
"dbname=dbName ");
If above code lines are present in the project source (even if it is not referenced from anywhere) The program builds perfectly fine. I even see this message pqxx.vcxproj -> D:\myProjectDirectory\build\build-pqxx\src\Debug\pqxx.lib
during the build process which indicates(i think) that the pqxx library was built successfully.
But when executing the program, the program just exits without any message or error. Even when I launch debugger a breakpoint on first line of main()
it fails with message The program '[17572] myProject.exe' has exited with code -1073741515 (0xc0000135).
If the source lines referencing pqxx::connection
are commented, the program runs fine after rebuild.
After some research (from which I learned the dependency on pq.lib) I made changes to main CMakeLists.txt to look as follows
add_subdirectory(libpqxx build-pqxx) #libpqxx is the directory containing pqxx source tree
target_link_libraries(myProject PRIVATE pqxx
PRIVATE "C:\\Program Files\\PostgreSQL\\14\\lib\\libpq.lib"
But the problem remains same as before. Program exits without any message when run with or without debugger.
Lack of error messages during build or execution is making it impossible to figure out the problem.
Please help me figure out the issue with this setup or the build process. Any help will be greatly appreciated.
Edit 1
I added the bin
and lib
sub-directories of the Postgres install directory to PATH variable. Now the build command is producing numerous syntax errors and the like, all pointing to the .hxx
files in the 'include' sub-directory of the pqxx source tree.
(posting just a few here)
D:\projectHome\libpqxx\include\pqxx/result.hxx(135,55): error C2238: unexpected token(s) preceding ';' [D:\projectHome\build\myProject.vcxproj]
D:\projectHome\libpqxx\include\pqxx/result.hxx(136,39): error C3646: 'end': unknown override specifier [D:\projectHome\build\myProject.vcxproj]
D:\projectHome\libpqxx\include\pqxx/result.hxx(136,43): error C2059: syntax error: ')' [D:\projectHome\build\myProject.vcxproj]
D:\projectHome\libpqxx\include\pqxx/result.hxx(136,59): error C2238: unexpected token(s) preceding ';' [D:\projectHome\build\myProject.vcxproj]
D:\projectHome\libpqxx\include\pqxx/result.hxx(137,39): error C3646: 'cend': unknown override specifier [D:\projectHome\build\myProject.vcxproj]
D:\projectHome\libpqxx\include\pqxx/result.hxx(137,44): error C2059: syntax error: ')' [D:\projectHome\build\myProject.vcxproj]
D:\projectHome\libpqxx\include\pqxx/result.hxx(137,60): error C2238: unexpected token(s) preceding ';' [D:\projectHome\build\myProject.vcxproj]
D:\projectHome\libpqxx\include\pqxx/result.hxx(139,27): error C3646: 'front': unknown override specifier [D:\projectHome\build\myProject.vcxproj]
D:\projectHome\libpqxx\include\pqxx/result.hxx(139,32): error C2059: syntax error: '(' [D:\projectHome\build\myProject.vcxproj]
D:\projectHome\libpqxx\include\pqxx/result.hxx(139,49): error C2238: unexpected token(s) preceding ';' [D:\projectHome\build\myProject.vcxproj]
D:\projectHome\libpqxx\include\pqxx/result.hxx(139,49): fatal error C1003: error count exceeds 100; stopping compilation [D:\projectHome\build\myProject.vcxproj]
After some research, it seems these errors might be due to lack of c++ standard 17 during build. So I addded following line in main CMakeLists.txt of my project.
add_subdirectory(libpqxx build-pqxx) #libpqxx is the directory containing pqxx source tree
include_directories(libpqxx)
add_executable(myProject gmClientApi.cpp)
target_compile_features(myProject PUBLIC cxx_std_17) // new line added
target_link_libraries(myProject PRIVATE pqxx)
But still no progress. Now the build is failing with the above errors. Does someone have an idea what could be going wrong here?
Thanks to Tsyvarev.
The issue really resolved by adding the directories to PATH system variable.
Changes to PATH took effect after system restart (Which is usually not the case).