windows 使用 gcc 和 SciTE 编译代码?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1106770/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 12:47:34  来源:igfitidea点击:

Compiling code using gcc and SciTE?

linuxwindowsgccopen-sourcescite

提问by Secko

I'm trying to compile C/C++ code from an external source using SciTE. The SciTE has a built-in feature where it searches for the gcc compiler and libraries in the same folder. The problem occurs if I try to compile from SciTE externally. Compiling with F5(compile and run) or CTRL-F7(compile) results in SciTE not being able to find the compiler.

我正在尝试使用 SciTE 从外部源编译 C/C++ 代码。SciTE 有一个内置功能,它可以在同一文件夹中搜索 gcc 编译器和库。如果我尝试从外部从 SciTE 编译,就会出现问题。使用F5(compile and run) 或CTRL-F7(compile) 进行编译会导致 SciTE 无法找到编译器。

I'm wondering if there is a way (there always is) to embed the gcc compiler's path into one of SciTE's files without generally rewriting SciTE's code?

我想知道是否有一种方法(总是有)将 gcc 编译器的路径嵌入到 SciTE 的文件之一中,而无需通常重写 SciTE 的代码?

EDIT: Found a solution in Linux.

编辑:在 Linux 中找到了解决方案。

回答by Oli4

I used MinGW as an external source to compile in C and C++ code in scite.

我使用 MinGW 作为外部源,在 scite 中编译 C 和 C++ 代码。

If you do not have MinGW you can get MinGW here: http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/

如果您没有 MinGW,您可以在此处获取 MinGWhttp: //sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/

  • mingw may have problems if installed into directories containing spaces.

  • After installing MinGW add the bin directory to sysytem path environment variables.

    • Go to Control pannel.
    • System
    • Advanced system settings
    • Click on the Environment Variablestab
    • Add the MinGW's bin directory to the path system variables list.
    • Default directory: "C:\MinGW\bin"
  • 如果安装到包含空格的目录中,mingw 可能会出现问题。

  • 安装 MinGW 后,将 bin 目录添加到系统路径环境变量中。

    • 进入控制面板。
    • 系统
    • 高级系统设置
    • 单击环境变量选项卡
    • 将 MinGW 的 bin 目录添加到路径系统变量列表中。
    • 默认目录:“C:\MinGW\bin”

In scite:

在 scite 中:

  • Open cpp.properties
  • Search for: cc=g++ $(ccopts) -c $(FileNameExt) -o $(FileName).o
  • Change the g++ part to MinGW's bin directory plus compiler exe ex:
    • cc=C:\MinGW\bin\g++.exe $(ccopts) -c $(FileNameExt) -o $(FileName).o
  • For gcc compiling change ccc=gcc.exe $(ccopts) -c $(FileNameExt) -o $(FileName).oto ccc=C:\MinGW\bin\gcc $(ccopts) -c $(FileNameExt) -o $(FileName).o
  • Now search for command.go.$(file.patterns.cplusplus)=./$(FileName)
  • Change it to command.go.$(file.patterns.cplusplus)=$(FileName).exe
  • For gcc compiling search for command.go.*.c=./$(FileName)and change it similarly.
  • Save the changes to file
  • 打开cpp.properties
  • 搜索: cc=g++ $(ccopts) -c $(FileNameExt) -o $(FileName).o
  • 将g++部分改成MinGW的bin目录加上编译器exe ex:
    • cc=C:\MinGW\bin\g++.exe $(ccopts) -c $(FileNameExt) -o $(FileName).o
  • 对于 gcc 编译更改ccc=gcc.exe $(ccopts) -c $(FileNameExt) -o $(FileName).occc=C:\MinGW\bin\gcc $(ccopts) -c $(FileNameExt) -o $(FileName).o
  • 现在搜索 command.go.$(file.patterns.cplusplus)=./$(FileName)
  • 将其更改为 command.go.$(file.patterns.cplusplus)=$(FileName).exe
  • 对于 gcc 编译搜索command.go.*.c=./$(FileName)并类似地更改它。
  • 将更改保存到文件

Please note that you may have to change permissions in the scite folder before you will be able to save the changes to cpp.properties

请注意,您可能必须先更改 scite 文件夹中的权限,然后才能将更改保存到 cpp.properties

Your code will now be able to compile (use shift+F7) and run(F5).

您的代码现在将能够编译(使用 shift+F7)和运行(F5)。

回答by Saqib Farooq

Go to options -> cpp.properties -> goto line 303 or find the following line:

转到选项 -> cpp.properties -> 转到第 303 行或找到以下行:

cc=g++ $(ccopts) -c $(FileNameExt) -o $(FileName).o

cc=g++ $(ccopts) -c $(FileNameExt) -o $(FileName).o

next line will be for gcc option.

下一行将用于 gcc 选项。

Now set full path for gcc or g++ as follows,

现在为 gcc 或 g++ 设置完整路径,如下所示,

ccc=D:\Dev-Cpp\bin\gcc.exe $(ccopts) -c $(FileNameExt) -o $(FileName).o

ccc=D:\Dev-Cpp\bin\gcc.exe $(ccopts) -c $(FileNameExt) -o $(FileName).o

In the above line D:\Dev-Cpp\bin\gcc.exe is the path for gcc on my system. You can do the similar thing by editing the path according to your own installation of gcc. Once set write a program and compile.

在上面的行中 D:\Dev-Cpp\bin\gcc.exe 是我系统上 gcc 的路径。您可以根据自己的gcc安装通过编辑路径来做类似的事情。一旦设置编写程序并编译。

Note: There are other options for you to set for example the standard to use for compiling your programs.

注意:还有其他选项供您设置,例如用于编译程序的标准。

I hope it helps.

我希望它有帮助。