Visual Studio Code and library libpq

Hello

How can I add libpq sample project to connect to postgresql database, can't add libpq-fe.h?


I previously installed vcpkg.




Can anyone help?



  • Hi,

    Could you provide more information on what are you trying to do in this project?

    After installation of vcpkg, there is a message that "-DCMAKE_TOOLCHAIN_FILE=<vcpkg path>/scripts/buildsystems/vcpkg.cmake" should be used by CMake projects. Based on this answer, it seems that using CMAKE_TOOLCHAIN_FILE is not supported.

    You could try building the library from the source, but there are many other library dependencies. Therefore, this approach might not work as well.

    You could also have a look at Zephyr external library sample which explains how to include external library to the Zephyr build system.

    Best regards,
    Dejan

  • Hello

    Thank you for the answer.

    In the project, I want to send data to a postgresql database. The data I send is temperature and humidity from the sensor.

     https://www.farnell.com/datasheets/2773931.pdf

    In your answer, I understood that it is not possible to do it in the way I tried to do it.

    So do I have to somehow libpq a static library and then add it to the CMakeLists.txt file and then try to built it?

    But how can I make libpq a static library?

  • Hi,

    Libpq is a third party library which we do not support. You could ask for support from postgresql community. You could probably build libpq from the source, but there might be many dependencies for which we do not have support. Additionally, it is unlikely that it would work. Therefore, I do not think it would be good way forward. Another option is to implement communication protocol yourself which could communicate with your database. This may not be easy to implement yourself. Finally, you can set up a server which could connect to the database. You could use CoAP or MQTT for this purpose. You could use nRF9160 to connect to the server which would communicate with the database.

    Best regards,
    Dejan

Related