[英]Cannot run c file in clion
I configure CLion toolchain with MinGW and set environment variable in Windows 7, and I also can use GCC to complile and built and run hello.c
in cmd
console. 我使用MinGW配置CLion工具链,并在Windows 7中设置环境变量,也可以使用GCC在cmd
控制台中编译和构建并运行hello.c
。
F:\c_cpp\
|-- cmake-build-debug\
|-- CMakeLists.txt
|-- hello.c
|-- library.c
`-- library.h
The following is my CMake file: 以下是我的CMake文件:
cmake_minimum_required(VERSION 3.8)
project(c_cpp)
set(CMAKE_C_STANDARD 99)
set(SOURCE_FILES library.c library.h hello.c)
add_library(c_cpp ${SOURCE_FILES})
When I click run button and choose "run c_cpp", the error happened. 当我单击运行按钮并选择“运行c_cpp”时,发生了错误。
Error running 'c_cpp': Cannot run program "F:\\c_cpp\\library.c" (in directory "F:\\c_cpp"): CreateProcess error=193, %1 不是有效的 Win32 应用程序。 运行'c_cpp'时出错:无法运行程序“ F:\\ c_cpp \\ library.c”(在目录“ F:\\ c_cpp”中):CreateProcess error = 193,%1不是有效的Win32应用程序。
What should I do? 我该怎么办?
Your building a library, which you can't execute. 您正在构建无法执行的库。
If hello.c
is an application using your library, change 如果hello.c
是使用您的库的应用程序,请更改
add_library(c_cpp ${SOURCE_FILES})
to 至
add_executable(hello ${SOURCE_FILES})
After which you should be able to run hello
. 之后,您应该可以运行hello
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.