我一直在尝试运行此链接C 或 CPP 示例下给出的 IUP 图形示例
如MinGW X64 windows环境下的plot.C或mathglsamples.c直接出源码改编,本身不做修改。但是文档太差了,以至于我碰壁了。经过反复尝试,我终于得到了 IUP、CD 和 IM 核心动态库的支持。
我现在很高兴地分享我对独立 exe 文件的成功配置,以受益并帮助那些避免面临挫折和错误,因为网站中目前没有明确的库要求。
在 netbeans IDE 上运行它会容易得多,只需指定所有需要的头文件和库。
下面是 Cmake,只需确保将所有这些 .dll 库复制到 exe 文件所在的同一输出文件夹中。
# cmake_minimum_required(VERSION <specify CMake version here>)
cmake_minimum_required(VERSION 3.10)
project(IUP)
#set (CMAKE_LEGACY_CYGWIN_WIN32 0)
set(CMAKE_CXX_STANDARD 17)
set(IUPDir "C:/iup-3.24_Win64_dllw4_lib")
set(CDDir "C:/cd-5.11.1_Win64_dllw4_lib")
set (IMDir "C:/im-3.12_Win64_dllw4_lib")
include_directories(${IUPDir})
include_directories(${IUPDir}/include)
include_directories(CDDir)
include_directories(${CDDir}/include)
include_directories(${IMDir}/include)
link_directories(${IUPDir})
link_directories(${CDDir})
add_executable(IUP mathglsamples.c)
#add_executable(IUP plot.cpp)
find_package(iup.dll)
find_package(iupimglib.dll)
add_custom_command(TARGET IUP POST_BUILD # Adds a post-build event to MyTest
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
"${IUPDir}/iup.dll"
"${IUPDir}/iupimglib.dll"
"${IUPDir}/iup_plot.dll"
"${IUPDir}/iupcontrols.dll"
"${IUPDir}/iupgl.dll"
"${IUPDir}/iupcd.dll"
"${IUPDir}/ftgl.dll"
"${IUPDir}/iup_mglplot.dll"
"${IUPDir}/iupim.dll"
"${IUPDir}/zlib1.dll"
"${CDDir}/cd.dll"
"${CDDir}/cdgl.dll"
"${CDDir}/freetype6.dll"
"${CDDir}/cdcontextplus.dll"
"${IMDir}/im.dll"
"${IMDir}/im_process.dll"
# <--this is in-file
$<TARGET_FILE_DIR:IUP>
)
target_include_directories(IUP PUBLIC ${IUPDir})
target_include_directories(IUP PUBLIC ${CDDir})
target_include_directories(IUP PUBLIC ${IMDir})
target_link_libraries (IUP PUBLIC
"${IUPDir}/iup.dll"
"${IUPDir}/iupimglib.dll"
"${IUPDir}/iup_plot.dll"
"${IUPDir}/iupcontrols.dll"
"${IUPDir}/iupgl.dll"
"${IUPDir}/iupcd.dll"
"${IUPDir}/ftgl.dll"
"${IUPDir}/iup_mglplot.dll"
"${IUPDir}/iupim.dll"
"${IUPDir}/zlib1.dll"
"${CDDir}/cd.dll"
"${CDDir}/cdgl.dll"
"${CDDir}/freetype6.dll"
"${CDDir}/cdcontextplus.dll"
"${IMDir}/im.dll"
"${IMDir}/im_process.dll"
)
谢谢