简体   繁体   中英

Linker Issues VS2015. LNK2019 and LNK2001 unresolved external symbol

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM