使用命令提示符编译C源文件

时间:2023-01-17 09:52:28

I am having trouble while using the codeblocks-16.01mingw-setup.exe - installed in a file whose path does not contain spaces - when trying to compile at a comand prompt. A beginner's guide recommended using the following line in command prompt:

我在使用codeblocks-16.01mingw-setup.exe时遇到问题 - 安装在路径不包含空格的文件中 - 尝试在命令提示符下编译时。建议在初学者指南中使用命令提示符中的以下行:

gcc cards.c -o cards

for the source file named cards.c (on my desktop). This gives the error

对于名为cards.c的源文件(在我的桌面上)。这给出了错误

'gcc' is not recognised as an internal or external command, operable program or batch file.

When trying to figure this out, I have found out that you can drag and drop files in your command prompt and it specifies their path. Doing this with the gcc.exe taken from F:\Programare\Codeblocks\MinGW\bin\gcc.exe and adding the c source file as C:\Users\dream\Desktop\cards.c gives the error

在尝试解决这个问题时,我发现您可以在命令提示符中拖放文件并指定其路径。使用从F:\ Programare \ Codeblocks \ MinGW \ bin \ gcc.exe中获取的gcc.exe执行此操作并将c源文件添加为C:\ Users \ dream \ Desktop \ cards.c会出现错误

as.exe - System error: The program can't start because libintl-8.dll is missing from your computer. Try reinstalling the program to fix this problem.

I've reinstated my Codeblocks to no avail. I've also tried matching the paths of the compiler with the source file, bringing the source code where the compiler was, again to no avail.

我恢复了我的Codeblocks无济于事。我也尝试将编译器的路径与源文件进行匹配,将源代码与编译器放在一起,再次无济于事。

Please help me understand the issue. I must say that the file named libintl-8.dll is right there where gcc.exe is, trying to add it in the command prompt gives some syntax error.

请帮我理解这个问题。我必须说名为libintl-8.dll的文件就在gcc.exe所在的位置,尝试在命令提示符下添加它会产生一些语法错误。

2 个解决方案

#1


1  

gcc is trying to find that dll file in the working directory, so you need to cd into that directory cd /d F:\Programare\Codeblocks\MinGW\bin.

gcc试图在工作目录中找到该dll文件,因此你需要cd进入该目录cd / d F:\ Programare \ Codeblocks \ MinGW \ bin。

Dynamic-Link Library Search Order (Windows)

动态链接库搜索顺序(Windows)

  1. The directory specified by lpFileName.
  2. lpFileName指定的目录。
  3. The system directory. Use the GetSystemDirectory function to get the path of this directory.
  4. 系统目录。使用GetSystemDirectory函数获取此目录的路径。
  5. The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
  6. 16位系统目录。没有函数可以获取此目录的路径,但会搜索它。
  7. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
  8. Windows目录。使用GetWindowsDirectory函数获取此目录的路径。
  9. The current directory.
  10. 当前目录。
  11. The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.
  12. PATH环境变量中列出的目录。请注意,这不包括App Paths注册表项指定的每个应用程序路径。计算DLL搜索路径时不使用App Paths键。

#2


1  

You have to add F:\Programare\Codeblocks\MinGW\bin\ to your users or systems PATH environment variable.

您必须将F:\ Programare \ Codeblocks \ MinGW \ bin \添加到您的用户或系统PATH环境变量。

Once you have done this you can simply type

完成此操作后,您只需输入即可

gcc cards.c -o cards

#1


1  

gcc is trying to find that dll file in the working directory, so you need to cd into that directory cd /d F:\Programare\Codeblocks\MinGW\bin.

gcc试图在工作目录中找到该dll文件,因此你需要cd进入该目录cd / d F:\ Programare \ Codeblocks \ MinGW \ bin。

Dynamic-Link Library Search Order (Windows)

动态链接库搜索顺序(Windows)

  1. The directory specified by lpFileName.
  2. lpFileName指定的目录。
  3. The system directory. Use the GetSystemDirectory function to get the path of this directory.
  4. 系统目录。使用GetSystemDirectory函数获取此目录的路径。
  5. The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
  6. 16位系统目录。没有函数可以获取此目录的路径,但会搜索它。
  7. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
  8. Windows目录。使用GetWindowsDirectory函数获取此目录的路径。
  9. The current directory.
  10. 当前目录。
  11. The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.
  12. PATH环境变量中列出的目录。请注意,这不包括App Paths注册表项指定的每个应用程序路径。计算DLL搜索路径时不使用App Paths键。

#2


1  

You have to add F:\Programare\Codeblocks\MinGW\bin\ to your users or systems PATH environment variable.

您必须将F:\ Programare \ Codeblocks \ MinGW \ bin \添加到您的用户或系统PATH环境变量。

Once you have done this you can simply type

完成此操作后,您只需输入即可

gcc cards.c -o cards