C ++:使用Clion与MinGW和g ++编译器进行项目构建时,Cplex/cp优化器makefile问题 [英] C++: Cplex/cp optimizer makefile issues on project build using Clion with MinGW and g++ compiler

查看:97
本文介绍了C ++:使用Clion与MinGW和g ++编译器进行项目构建时,Cplex/cp优化器makefile问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用cplex/cp优化器外部库时,我的C ++项目无法构建.我在Windows 7上使用g ++编译器使用Cplex版本12.9.我收到以下错误:

my C++ project fails to build when I use the cplex/cp optimizer external libraries. I am using Cplex version 12.9 on Windows 7 with g++ compiler. I get the following error:

C:/PROGRA~1/IBM/ILOG/CPLEX_~1/concert/include/ilconcert/ilosys.h:262:10:严重错误:generic.h :无此类文件或目录

我已经检查过我的编译器/MinGw是最新的.我也尝试过将Clion中的工具链切换到Visual Studio,但这会导致其他错误.我已经能够使用Visual Studio在cplex \ examples \ x64_windows_vs2017 \ stat_mda中运行示例代码,但是不幸的是,这些示例项目没有示例makefile可与之进行比较.我的同事已经能够在Clion中使用g ++编译器在Linux上运行代码.

I have checked that my compiler/MinGw are up to date. I have also tried switching the toolchain in Clion to Visual Studio, but this results in other errors. I have been able to run the example code in cplex\examples\x64_windows_vs2017\stat_mda using Visual Studio but these example projects don't have example makefiles to compare against unfortunately. My coworker has been able to run the code on Linux with a g++ compiler in Clion.

我正在使用的make文件如下:

The make file I am using is below:

cmake_minimum_required(VERSION 3.15)
project(M_MDD)

include_directories("C:/Program Files/IBM/ILOG/CPLEX_Studio129/cpoptimizer/include/")
include_directories("C:/Program Files/IBM/ILOG/CPLEX_Studio129/concert/include/")
include_directories("C:/Program Files/IBM/ILOG/CPLEX_Studio129/cplex/include/")
include_directories("C:/Program Files/boost_1_55_0")

set(CMAKE_CXX_FLAGS  "-Wall ${CMAKE_CXX_FLAGS} -DIL_STD -g -O0 -ggdb -std=c++11")

include_directories(src)

add_executable(M_MDD
        src/instances/flowshop_instances.cpp
        src/instances/flowshop_instances.hpp
        src/main.cpp
        src/mip.cpp
        src/mip.hpp
        src/util.hpp)

link_directories("C:/Program Files/IBM/ILOG/CPLEX_Studio129/cplex/lib/x64_windows_vs2017/stat_mdd/")
link_directories("C:/Program Files/IBM/ILOG/CPLEX_Studio129/concert/lib/x64_windows_vs2017/stat_mdd/")
link_directories("C:/Program Files/IBM/ILOG/CPLEX_Studio129/cpoptimizer/lib/x64_windows_vs2017/stat_mdd/")

target_link_libraries(M_MDD cplex)
target_link_libraries(M_MDD concert)
target_link_libraries(M_MDD cp)
target_link_libraries(M_MDD pthread)

谢谢!

推荐答案

CPLEX .

The CPLEX detailed system requirements (click on "Version 12.9.0", "Windows", "Prerequisites") show that Visual Studio 2015-2019 are the only supported compilers on Windows. The C++ libraries in particular cannot be expected to be compatible with g++ (e.g., due to name mangling, etc.). In contrast, if you look at the system requirements on Linux, you'll see that g++ is supported there.

如果我们考虑到您遇到的错误,这是有道理的.在 ilosys.h 的第262行中,我们有:

If we consider the error you're getting, it makes sense. In ilosys.h, line 262, we have:

#if !(defined(name2))
# if defined(ILO_MSVC) || defined(ILO_LINUX) || defined(ILO_APPLE) || defined(ILO_HP11)
#  undef name2
#  define name2(a,b)      _name2_aux(a,b)
#  define _name2_aux(a,b)      a##b
# else
#include "generic.h"
# endif
#endif

ILO_MSVC 未定义,因此我们点击了 #include"generic.h" 行.

ILO_MSVC is not defined, so we hit the #include "generic.h" line.

正如您所提到的,Windows上没有用于C/C ++示例的makefile.但是,Visual Studio项目文件确实包含在Visual Studio中设置项目所需的一切.有关在Visual Studio中设置C ++项目的更多信息,请参见< COSDIR>/cplex/readmeWindows.html ,其中< COSDIR> 是CPLEX Optimization的安装位置.工作室.

As you mentioned, there are no makefiles for the C/C++ examples on Windows. However, the Visual Studio project files do contain everything you need to setup your project in Visual Studio. For more information on setting up your C++ projects in Visual Studio see <COSDIR>/cplex/readmeWindows.html, where <COSDIR> is the location you installed CPLEX Optimization Studio.

这篇关于C ++:使用Clion与MinGW和g ++编译器进行项目构建时,Cplex/cp优化器makefile问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆