Libraries to include under Windows VSIDE #3903
-
Hello, Thanks to help from this forum, I have been able to install or-tools successfully on Windows, VS2022. I am trying to follow the example given here: https://developers.google.com/optimization/introduction/cpp However, I am doing this in Windows under Visual Studio IDE with the idea of stepping through the code. So, within the IDE, when I copy the file and provide C:\Program Files (x86)\ortools\include as the additional include directories, the code looks fine with no IDE generated red squiggly line underneath. In Debug mode, I set up a breakpoint in the first line of Severity Code Description Project File Line Suppression State Obviously, I seem to be missing some libraries to include in the Linker part of the IDE. Could it please be pointed out what these would be? I also provided C:\Program Files (x86)\ortools\lib as additional library directories under the Linker option of VSIDE. Also, in additional dependencies, I have specified ortools_full.lib The tutorial getting started link above seems to assume that one is operating under a gnu system where it requires the user to use Is it possible to set it up so that one can step through the code of the C++ examples that go with the documentation? I did do a search on SO as well as previous issues here under "Visual Studio Setup" but they do not seem to be about how to setup a Visual Studio project and step through the code. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 5 replies
-
You should look at https://github.com/or-tools/cmake_or-tools and import the cmake in your environment |
Beta Was this translation helpful? Give feedback.
-
@ozan-cb Thank you. Your suggestion worked. I had to do a bit of modification since I was already linking to CPLEX and Boost and wanted to get cmake to work with those in addition to OR-Tools. target_link_libraries(CMakeProject cplex-library Boost::boost ortools::ortools) since I believe CMake has to accept all target link libraries using a single command in a single line and was able to verify that it works with all 3 libraries. |
Beta Was this translation helpful? Give feedback.
-
Sorry. I have to reopen discussion. I ended up having to reinstall. But that went without any errors. I know that the install went well because I am able to run the following without any errors:
I presume the above indicates that OR Tools has installed properly. Now, via code, I have a very minimal
On opening this in VSIDE 2022 with a very simple OrTools C++ program, I obtain the following error:
Is it possible to figure out what is going wrong here? Thanks. |
Beta Was this translation helpful? Give feedback.
-
To add to this -- before This ends up compiling fine without any CMake errors, yet, build/linking gives rise to a bunch of linking errors like so:
|
Beta Was this translation helpful? Give feedback.
-
You are mixing debug and release libraries.
Laurent Perron | Operations Research | ***@***.*** | (33) 1 42 68 53
00
Le mer. 6 sept. 2023 à 16:11, TryerGit ***@***.***> a écrit :
… To add to this -- before find_package(), I added set(CMAKE_PREFIX_PATH
"C:\\Program Files (x86)\\ortools")
This ends up *compiling* fine without any CMake errors, yet,
build/linking gives rise to a bunch of linking errors like so:
Severity Code Description Project File Line Suppression State
Error LNK2038 mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Main.cpp.obj D:\trials\cmake\windows\build\x64-Debug\trials D:\trials\cmake\windows\build\x64-Debug\ortools.lib(linear_solver.obj) 1
—
Reply to this email directly, view it on GitHub
<#3903 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUPL3PMFD2SHBRH734FQPTXZCACPANCNFSM6AAAAAA4BODXO4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I have a follow up question. After having setup my IDE to work in Release mode, I am able to run ORTools, however, I am not able to setup break points and step through the code in debug mode though. Is the fact that I am unable to run in Debug mode in Visual Studio on Windows (when I link in Debug mode, I get a bunch of errors which you pointed out above) a result of having run
in the final installation step of the document https://developers.google.com/optimization/install/cpp/source_windows? Had I run would I be able to step through the code in Debug mode? If yes, then, that is quite suboptimal because I want to have the ability to run in Debug mode as well as Release mode without having to build ortools again and the IDE provides for choosing the appropriate configuration to run under. Surprisingly, in Linux, even though I ended up giving the same final command as in Windows above, I am able to setup break points and step through the code in Debug mode, hence the question. This leads me to believe that it is something else is the cause of my not being able to run in Debug mode in Windows VSIDE. In VS IDE, in Project -> CMake Settings menu item -> CMake Variables and Cache -> show advanced variables, I am able to see that ZLIB_LIBRARY_DEBUG has value ZLIB_LIBRARY_DEBUG-NOTFOUND, while ZLIB_LIBRARY_RELEASE has value C:/Program Files (x86)/ortools/lib/zlib.lib Thank you. I am close to fully understanding the configuration needed to run ortools on linux and windows but not yet sufficiently there as yet and hence these persistent questions! |
Beta Was this translation helpful? Give feedback.
After installing OR-Tools on your system as you have already did, in a clean directory with a CMakeLists.txt as:
and a
main.cpp
file containing some OR-Tools use should work. Also as noted in the documentation, you might need to supply a CMAKE_PREFIX_PATH.It seems like the
cmake_or-tools
example project in your message fetches OR-Tools from Github and builds it from scratch, that is what you were trying to avoid when you were installing OR-Tools on your system. If fetching and building OR-Tools for your ever…