Windows C/C++ CLion 开发环境搭建 |
您所在的位置:网站首页 › clion编译环境 › Windows C/C++ CLion 开发环境搭建 |
博文目录 文章目录 IDE CLion安装设置MinGW如何在 UTF-8 编码下在控制台正常输出中文生成的 exe 运行时报错, 缺失 libgcc_s_seh-1.dll / libstdc++-6.dll生成的 exe 在没有 MinGW 环境的机器上如何正常运行在命令行 CMD 中运行 exe 时如何正常输出中文 插件测试 特殊配置 使用 CLion 开发 C++ CUDA 应用注意不要走如下弯路 IDE CLion 安装官网 官方全版本下载 CLion-2021.2.3.exe 或 CLion-2021.2.3.win.zip, 从 2021.3 起, IDE Eval Reset 不再可用, 复制评估 key 的方式从 2021.2.3 起不再可用 设置 File | Settings | Appearance & Behavior | System Settings - Project 取消勾选 Reopen projects on startupOpen project in 选择 New WindowDefault project directory 选择为 CLion 分配的工作空间目录, 如 C:\mrathena\develop\workspace\clion File | Settings | Editor | General | Code Completion 取消勾选 Match case File | Settings | Editor | General | Editor Tabs Appearance - Tab placement 选 LeftClosing Policy - Tab limit 填 100 File | Settings | Editor | Font Font 选 Courier NewSize 填 16 File | Settings | Build, Execution, Deployment | Toolchains 添加编译器 MinGW, 有捆绑的用捆绑的, 否则自行下载配置 (点击 Environment 后面的 download) MinGWMinGW与Clion下载安装及使用详解
解压到合适目录 Set up the CUDA compiler On Windows, CUDA projects can be developed only with the Microsoft Visual C++ toolchain. Check the toolchain settings to make sure that the selected architecture matches with the architecture of the installed CUDA toolkit (usually, amd64). Microsoft Visual C++ Install Visual Studio 2013, 2015, 2017, or 2019 on your system.In CLion, go to File | Settings | Build, Execution, Deployment | Toolchains.Click Icons general add and select Visual Studio from the list of toolchain templates.Check the Environment field. CLion will attempt to automatically detect the installed Visual Studio distribution. If the detection fails, set the path to Visual Studio manually.If required, specify the Architecture (x86, amd64, x86_arm, or another), Platform (store, uwp, onecore, or leave it blank), and Version. To build your project for the selected architecture, CLion will call the script to configure the environment with the specified parameters. If the version of your compiler toolset is earlier than the version of your Visual Studio installation, pass it in the Version field via the vcvars_ver flag, for example, -vcvars_ver=14.16. Wait until the tools detection is finished![]() CLion 开发 CUDA 应用, 工具链必须使用 Visual Studio. 安装 Visual Studio 时必须选择 C++ 桌面开发里的 MSVC 和 Windows SDK 我的 CLion 是 2021.2.3, 最高支持 VS 2019, 所以我下载并安装了 VS 2019 社区版 Visual Studio 较旧的下载 - 2019、2017、2015 和以前的版本 Visual Studio Installer 2019.exe CLion配置visual studio(msvc)和JOM多核编译
在 Toolchains 里创建 Visual Studio 并设置成默认(点到第一个), 确保默认的测试编译能成功通过(无法通过的例子见下面弯路说明) CMake 里要确认 Toolchains 与当前使用的 Toolchains 对应 注意不要走如下弯路先说结论, MSVC 和 Windows SDK 都得安装 我根据经验, 觉得配置 Visual Studio 工具链应该只需要用到 MSVC 编译器, 所以最开始就只安装了 MSVC. 结果在配置 Visual Studio 工具链的时候, 怎么都无法通过测试验证. 同时使用该工具链的任何工程做 Reload CMake Project 操作都会报相同的错. 因为输出信息乱码而不知道具体内容, 尝试百度错误代码也没百出来, 无奈只能先解决乱码问题 Clion编译输出乱码问题解决方案 乱码问题可通过在 Help | Edit Custom VM Optisions… (不存在则点击 Create) 末尾添加如下两个参数解决. 添加后重启 CLion -Dconsole.encoding=UTF-8 -Dfile.encoding=UTF-8根据描述找到一篇 文章 解决了这个问题, 在 CMake 里配置参数 -G "Visual Studio 16 2019". 有用, 但是又出了一个新的报错. 这次输出内容里涉及到 Windwos SDK, 让我联想到 VS Install 里面的可选安装 Windows 10 SDK, 同时我也想起来看到过有 文章 里就只安装 MSVC 和 Windows SDK. 试了一下同时安装这两项内容. 试了一下, 两项都装果真就直接成了 C:\mrathena\develop\clion-2021.2.3\bin\cmake\win\bin\cmake.exe -G "Visual Studio 16 2019" C:\mrathena\develop\workspace\clion\test -- Selecting Windows SDK version to target Windows 10.0.22621. -- The C compiler identification is unknown -- The CXX compiler identification is unknown CMake Error at CMakeLists.txt:2 (project): No CMAKE_C_COMPILER could be found. CMake Error at CMakeLists.txt:2 (project): No CMAKE_CXX_COMPILER could be found. -- Configuring incomplete, errors occurred! See also "C:/mrathena/develop/workspace/clion/test/cmake-build-debug/CMakeFiles/CMakeOutput.log". See also "C:/mrathena/develop/workspace/clion/test/cmake-build-debug/CMakeFiles/CMakeError.log". [Finished] |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |