Adding OR-Tools Library to Visual Studio

假如想象 提交于 2021-02-09 09:20:06

问题


I am trying to write a code using Google's OR-Tools library on Microsoft Visual Studio 2019. I followed the following steps:

  1. Installed OR-Tools from Binary on Windows on their website.
  2. Extracted the .zip file in C:\Libraries
  3. Wrote my code on VS (I wrote #include <ortools/linear_solver/linear_solver.h> and using namespace operations_research; rest is usual C++ Code)
  4. In Visual Studio, went to Project > Properties > C/C++ > Additional Include Directories
  5. Added "C:\Libraries\or-tools\include" (which contains the folder "ortools" that I included)
  6. Clicked Apply then OK then compiled my code.

I am getting a bunch of linking errors "error LINK2019". Is there anything else I should do so I can use this library freely on my machine?


回答1:


From the supplied makefile:

Compile flags:

  DEBUG = /O2 -DNDEBUG
  CXXFLAGS = /std:c++17 /EHsc /MD /nologo /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS -nologo $(DEBUG) \
    /DPSAPI_VERSION=1 /D__WIN32__ /DNOMINMAX /DWIN32_LEAN_AND_MEAN=1 /D_CRT_SECURE_NO_WARNINGS \
    /DGFLAGS_DLL_DECL= /DGFLAGS_DLL_DECLARE_FLAG= /DGFLAGS_DLL_DEFINE_FLAG= /DGOOGLE_GLOG_DLL_DECL= \
    /I$(INC_DIR)\\src\\windows /I$(INC_DIR) /I. \
    /DUSE_BOP /DUSE_GLOP \
    /DUSE_CBC /DUSE_CLP \
    /DUSE_SCIP

Link flags:

  LDFLAGS = psapi.lib ws2_32.lib
  OR_TOOLS_LNK = lib\\ortools.lib


来源:https://stackoverflow.com/questions/65559940/adding-or-tools-library-to-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!