Search code examples
c++visual-studio-2019oat++

Questions about third-party library(oat++) configuration in visual studio


As a beginner, I want to use oat++ as a third-party library in visual studio, but I encountered some configuration problems.

First I downloaded the source file of the oat++ project and opened it in visual studio and cmake and install.

Then I created a new project in visual studio and started running the first example of the official website.

First of all, it need to configure the preprocessing, I will configure the Include directory first. What I did is:(my project name is web4)

  • Project -> Web4 properties -> configuration properties -> VC++ Directories
  • set the Include Directories include C:\Users\13925\Documents\cpp\oatpp\out\install\x64-Debug\include\oatpp-1.2.5\oatpp

That is great. The compiler can find the #include "file"

After that I'm having trouble,An error occurred when I tried to compile.

Error   LNK2019 unresolved external symbol __imp_WSAStartup referenced in function....

Error

By searching for information, it is found that the cause of this problem is that the related library is not included. But I tried the online method and it didn’t solve the problem,so ask for help here.

The online approach is like this:

  1. Project -> Web4 properties -> configuration properties -> VC++ Directories
  2. set the Library Directories include C:\Users\13925\Documents\cpp\oatpp\out\install\x64-Debug\lib\oatpp-1.2.5

In C:\Users\13925\Documents\cpp\oatpp\out\install\x64-Debug\lib\oatpp-1.2.5 has three files:oatpp.liboatpp-test.liband a .hfiles.

  1. Project -> Web4 properties -> configuration properties -> Linker -> Input
  2. set Additional Dependencies include oatpp.lib and oatpp-test.lib

Compile after completing the above four steps and find that the problem is still not solved. And the problen still unresolved external symbol.

I would be very grateful if you are willing to help.


Solution

  • As far as I'm concerned, the problem is you are not linking against the Ws2_32.lib library. To fix this you could try to add that to your additional dependencies tab of linker/Input settings for your project. And you could also try to add: #pragma comment(lib, "Ws2_32.lib")

    Best Regards,

    Jeanine