0

I am trying to extend my knowledge of constrain programming and I want to build a simple example using google's or-tools in VS2015.

However I am constantly nagged by those linker errors. LNK2019 and LNK2001. Why is linking in VS so darn hard.

Google's or-tools comes in a perfect folder, with an include subfolder and lib subfolder with one single .lib file.

I have added Additional Library Dependencies.

Configuration Properties -> Linker -> General Additional Library Dependencies : C:\PATH\or-tools.VisualStudio2013-64b\lib

Set the Input under the Linker properties section.

Configuration Properties -> Linker -> Input Additional Dependencies : ortools.lib

Infomed VC++ where the include directory is.

Configuration Properties -> VC++ Directories : C:\PATH\or-tools.VisualStudio2013-64b

However it is still throwing link errors when building the solution. What am I missing here.

Thanks in advance.

edit:

spelling

Community
  • 1
  • 1
Montaldo
  • 863
  • 8
  • 16
  • 1
    Are you attempting to use Visual Studio 2013 binaries with Visual Studio 2015? – drescherjm Jan 22 '16 at 13:14
  • Uhm Yes, but It does not work under VS2013 either. I have the feeling that I am missing a step in the static library adding process. If I am trying any other .lib the #pragma comment(lib, "mylib") is not sufficient either. – Montaldo Jan 22 '16 at 13:19
  • 1
    Answering your question could be easier if you provided those link error messages here or at least through at link. – J.J. Hakala Jan 22 '16 at 13:23
  • Hold on, I am trying to link an old binary to a new version... fml – Montaldo Jan 22 '16 at 13:28
  • Libraries are searched for in the "Library Directories" not in the "Include Directories". – Werner Henze Jan 22 '16 at 14:57

1 Answers1

2

Since the VS2013 and VS2015 compiler versions are incompatible, you have to build the lib from source. Though beware that this might entail a bit more work when linking with VS2015. Specifically I've had to manually resolve the following issues:

  1. Change protobuf-3.0.0-beta-1 to protobuf-3.0.0-beta-2(bonus. not really necessary)
  2. gflags 2.1.2 failed to compile due to a conflict of names around snprintf. To resolve this download the latest gflags version from GitHub and overwrite the one in %OR_TOOLS%\dependencies
  3. Look up all VS solution files (.sln) in dependencies\sources\cbc-2.9.7 and convert to VS2015 format by simply double clicking them and following the instructions.
  4. Add the following code to makefiles\Makefile.port

ifeq ("$(VisualStudioVersion)", "14.0") VISUAL_STUDIO=2015 VS_RELEASE=v140 VS_COMTOOLS=140 else ... endif

  1. Replace Visual Studio 12 2013 with Visual Studio 14 2015

Rerun make third_party after each step.

Or you can just download the end result, linked on Windows 10 x64 VS2015 update 1. I've included the whole folder after running make third_party && make cc.

Zak Goichman
  • 71
  • 1
  • 4