EasyX安装目前仅支持VC和VS系列,如果想在Clion上使用,则需要自己手动配置。百度了一下发现关于这个问题的搜索结果很少,也不是特别清楚,这里就记录一下我的方法吧。
首先安装到Visual Studio 2019,鼠标放在安装路径上记下头文件和库文件的完整安装路径。

发布于 2021-01-29 31 次阅读
EasyX安装目前仅支持VC和VS系列,如果想在Clion上使用,则需要自己手动配置。百度了一下发现关于这个问题的搜索结果很少,也不是特别清楚,这里就记录一下我的方法吧。
首先安装到Visual Studio 2019,鼠标放在安装路径上记下头文件和库文件的完整安装路径。
可以看到我的安装路径分别是 D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\VS\include
和 D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\VS\lib\x86
。
然后在Clion的项目根目录下新建两个文件夹,命名为 include
和 lib
,把刚才记的安装路径下的对应文件复制过去
( lib
文件夹直接复制 x86
里面的内容)。
接下来打开 CMakeLists.txt
,在 set(CMAKE_CXX_STANDARD XX)
后增加:
set(INC_DIR ./include)
set(LINK_DIR ./lib)
include_directories(${INC_DIR})
link_directories(${LINK_DIR})
在最后一行增加:
target_link_libraries({{项目名称}} EasyXa EasyXw VSCustomNativeHeapEtwProvider VsGraphicsHelper)
例如我有一个叫GoBang的项目,那么对应 CMakeLists.txt
的内容为:
cmake_minimum_required(VERSION 3.17)
project(GoBang)
set(CMAKE_CXX_STANDARD 14)
set(INC_DIR ./include)
set(LINK_DIR ./lib)
include_directories(${INC_DIR})
link_directories(${LINK_DIR})
add_executable(GoBang main.cpp)
target_link_libraries(GoBang EasyXa EasyXw VSCustomNativeHeapEtwProvider VsGraphicsHelper)
这样一来就可以在Clion里面使用EasyX了,遗憾的是每个项目都需要手动配置一次,目前还没有发现解决这个问题的办法。
Comments | 2 条评论
求教,按照上面的方法后仍然显示以下该怎么办
CMakeFilesuntitled3.dir/objects.a(main.cpp.obj): In function
main': C:/Users/DELL/CLionProjects/untitled3/main.cpp:24: undefined reference to
initgraph(int, int, int)’C:/Users/DELL/CLionProjects/untitled3/main.cpp:34: undefined reference to
setcolor(unsigned long)' C:/Users/DELL/CLionProjects/untitled3/main.cpp:35: undefined reference to
setfillcolor(unsigned long)’C:/Users/DELL/CLionProjects/untitled3/main.cpp:36: undefined reference to
fillcircle(int, int, int)' C:/Users/DELL/CLionProjects/untitled3/main.cpp:48: undefined reference to
setcolor(unsigned long)’C:/Users/DELL/CLionProjects/untitled3/main.cpp:49: undefined reference to
setfillcolor(unsigned long)' C:/Users/DELL/CLionProjects/untitled3/main.cpp:50: undefined reference to
fillcircle(int, int, int)’collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: [CMakeFilesuntitled3.dirbuild.make:106: untitled3.exe] Error 1
mingw32-make.exe[2]: [CMakeFilesMakefile2:95: CMakeFiles/untitled3.dir/all] Error 2
mingw32-make.exe[1]: [CMakeFilesMakefile2:102: CMakeFiles/untitled3.dir/rule] Error 2
mingw32-make.exe: [Makefile:137: untitled3] Error 2
@Dylon 啊这,其实我也一知半解的,没太看的出来,抱歉