简体   繁体   English

如何获得 gcc.exe 可执行文件来运行也是可执行文件的 arguments? pkg-config.exe 作为命令行参数?

[英]How can I get gcc.exe executable to run the arguments which are also an executable? pkg-config.exe as a command line argument?

pkg-config.exe is a executable which generates --cflags and or --libs for creating a text result which is used for typing all necessary -I and -L and -l flags and libs that are required for compiling with the gcc.exe compiler! pkg-config.exe 是一个可执行文件,它生成 --cflags 和/或 --libs 以创建文本结果,该文本结果用于键入所有必要的 -I 和 -L 以及 -l 标志和库,这些是使用 gcc 编译所需的。 exe编译器!

The example code which I am trying to run from command prompt is:我试图从命令提示符运行的示例代码是:

gcc `pkg-config --cflags gtk+-3.0` -o hello-world-gtk hello-world-gtk.c `pkg-config --libs gtk+-3.0`

gcc 'pkg-config --cflags gtk+-3.0' -o hello-world-gtk hello-world-gtk.c 'pkg-config --libs gtk+-3.0'

I get an error which is resulting in an output as follows:我收到一个错误,导致 output 如下:

gcc: error: pkg-config: No such file or directory gcc:错误:pkg-config:没有这样的文件或目录
gcc: error: gtk+-3.0: No such file or directory gcc:错误:gtk+-3.0:没有这样的文件或目录
gcc: error: pkg-config: No such file or directory gcc:错误:pkg-config:没有这样的文件或目录
gcc: error: gtk+-3.0: No such file or directory gcc:错误:gtk+-3.0:没有这样的文件或目录
gcc: error: unrecognized command line option --cflags gcc:错误:无法识别的命令行选项--cflags
gcc: error: unrecognized command line option --libs gcc:错误:无法识别的命令行选项--libs

ASSUMPTION假设

I assume that the pkg-config.exe executable is not being found in the location where it is located because of some specific type of Environment Variable which I do not have set or know what its called on the Windows User Environment Variables Settings on my Windows 10 computer since this maybe the reason the gcc.exe which is the current command to run and compile.c files does not have the ability to locate where pkg-config.exe would be located due to a missing Environment Variable.我假设在它所在的位置找不到 pkg-config.exe 可执行文件,因为我没有设置或知道它在 Windows 用户环境变量设置上调用的某些特定类型的环境变量在我的 Windows 10 台计算机,因为这可能是当前运行和编译命令 gcc.exe 的原因。由于缺少环境变量,c 文件无法定位 pkg-config.exe 所在的位置。

Does anyone happen to know which Environment Variable it is that I need so that the gcc.exe will know where to locate any other executable which is passed as an argument to the gcc.exe executable?有谁碰巧知道我需要哪个环境变量,以便 gcc.exe 知道在哪里找到作为参数传递给 gcc.exe 可执行文件的任何其他可执行文件?

Environment Variables环境变量

  1. GCC_EXEC_PREFIX GCC_EXEC_PREFIX
  2. COMPILER_PATH编译路径
  3. CPATH路径

gcc.exe "pkg-config.exe --cflags gtk+-3.0" -o hello-world-gtk hello-world-gtk.c "pkg-config.exe --libs gtk+-3.0"

I changed the single quotes to double quotes and it reduced the amount of errors from six errors for the output until and after the new command was executed to two errors which are:我将单引号更改为双引号,它将错误数量从 output 的六个错误减少到执行新命令之前和之后的两个错误,它们是:

gcc.exe: error: pkg-config.exe --cflags gtk+-3.0: No such file or directory gcc.exe:错误:pkg-config.exe --cflags gtk+-3.0:没有这样的文件或目录
gcc.exe: error: pkg-config.exe --libs gtk+-3.0: No such file or directory gcc.exe:错误:pkg-config.exe --libs gtk+-3.0:没有这样的文件或目录


Any suggestions to the new issue that occurs now after I changed the quotes to a better set of quotes?在我将引号更改为一组更好的引号后,对现在出现的新问题有什么建议吗?

I get the error down below when I try to just get the flags Individually from running these commands which are inside the Double quotes Individually and then add them to the command which is below this paragraph:当我尝试从单独运行双引号内的这些命令中单独获取标志然后将它们添加到本段下方的命令中时,我得到了下面的错误:

gcc.exe -mms-bitfields -IC:/gtk_32bit/include/gtk-3.0 -IC:/gtk_32bit/include/cairo -IC:/gtk_32bit/include/pango-1.0 -IC:/gtk_32bit/include/atk-1.0 -IC:/gtk_32bit/include/cairo -IC:/gtk_32bit/include/pixman-1 -IC:/gtk_32bit/include -IC:/gtk_32bit/include/freetype2 -IC:/gtk_32bit/include -IC:/gtk_32bit/include/libpng15 -IC:/gtk_32bit/include/gdk-pixbuf-2.0 -IC:/gtk_32bit/include/libpng15 -IC:/gtk_32bit/include/glib-2.0 -IC:/gtk_32bit/lib/glib-2.0/include -o hello-world-gtk.exe hello-world-gtk.c -LC:/gtk_32bit/lib -lgtk-3 -lgdk-3 -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lpangocairo-1.0 -lpangoft2-1.0 -lfreetype -lfontconfig -lpangowin32-1.0 -lgdi32 -lpango-1.0 -lm -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl

Here is the ERROR I get from running the command above:这是我从运行上面的命令得到的错误:

gcc.exe: fatal error: cannot execute 'cc1': CreateProcess: No such file or directory compilation terminated. gcc.exe:致命错误:无法执行“cc1”:CreateProcess:没有此类文件或目录编译终止。

This code below should perform the same function as me typing the result from the code below instead of running what is included within the double quotes within the command itself which gives me two errors attempting to do so that's why I tried to do what's above this paragraph instead of what's below this paragraph:下面的代码应该执行相同的 function,因为我从下面的代码中输入结果,而不是运行命令本身的双引号中包含的内容,这给了我两个尝试这样做的错误,这就是为什么我尝试执行本段上方的操作而不是本段下面的内容:

gcc.exe "pkg-config.exe --cflags gtk+-3.0" -o hello-world-gtk hello-world-gtk.c "pkg-config.exe --libs gtk+-3.0"

Here is the ERROR I get from running the command above:这是我从运行上面的命令得到的错误:

gcc.exe: error: pkg-config.exe --cflags gtk+-3.0: No such file or directory gcc.exe:错误:pkg-config.exe --cflags gtk+-3.0:没有这样的文件或目录
gcc.exe: error: pkg-config.exe --libs gtk+-3.0: No such file or directory gcc.exe:错误:pkg-config.exe --libs gtk+-3.0:没有这样的文件或目录


Here is a link which is what I am trying to accomplish from a command prompt with gcc.exe which is shown in the link with the command above that I am trying to determine how to get the command to work?这是一个链接,我正在尝试使用 gcc.exe 从命令提示符完成该链接,该链接显示在上面的命令的链接中,我试图确定如何使命令工作?

https://www.gtk.org/docs/getting-started/hello-world/ https://www.gtk.org/docs/getting-started/hello-world/

So as example is shown in link I am trying to use Command Prompt to compile program above which is the example in the link I provide.因此,如链接中所示的示例,我正在尝试使用命令提示符来编译上面的程序,这是我提供的链接中的示例。 I did install everything correctly although the example does not seem to work as shown in the link with the command provided when typing command in CMD.exe console!我确实正确安装了所有内容,尽管该示例似乎无法正常工作,如在 CMD.exe 控制台中键入命令时提供的命令的链接所示!

gcc.exe "pkg-config.exe --cflags gtk+-3.0" -o hello-world-gtk.exe hello-world-gtk.c "pkg-config.exe --libs gtk+-3.0"

Normally you create a .pc file for pkg-config use it with gcc like in https://en.wikipedia.org/wiki/Pkg-config .通常,您为 pkg-config 创建一个.pc文件,将其与gcc一起使用,例如https://en.wikipedia.org/wiki/Pkg-config You can also use makefiles to create the .pc file ( Generate pkg-config out of Makefile )您还可以使用 makefiles 创建.pc文件( Generate pkg-config out of Makefile

Makefile: How to install a project with a file pkg-config Makefile:如何使用文件 pkg-config 安装项目

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 C 文件编译为可执行 (.exe) 文件? - How can I compile C files into an executable (.exe) file? 如何使用 `execl()` 在 C/C++ 中运行系统命令,将 function arguments 仅作为命令行而不是可执行文件传递? - How can I run system commands in C/C++ using `execl()`, passing the function arguments only as a command line, not as an executable file? 如何使用C ++获取有关Windows可执行文件(.exe)的信息 - How to get information about a Windows executable (.exe) using C++ 提供命令行参数以使用ltrace / strace运行可执行文件 - Giving command line arguments to executable being run with ltrace/strace 从命令行将参数传递给可执行文件 - Passing arguments to executable from command line gcc.exe 错误 缺少 libwinpthread-1.dll,但没有丢失 - gcc.exe error Missing libwinpthread-1.dll, but it is not missing gSOAP-Windows中使用gcc.exe的未定义引用错误 - gSOAP - Undefined References Error in Windows using gcc.exe gcc使用pkg-config引发“无法识别的命令行选项”错误 - gcc raises “unrecognized command line option” error with pkg-config Is the location of gcc.exe for studio running R 4.2.1 on windows 10 causing gcc.exe, the c compiler, to error in compiling? - Is the location of gcc.exe for studio running R 4.2.1 on windows 10 causing gcc.exe, the c compiler, to error in compiling? Cmd无法在不提供“ .exe”的情况下运行我的可执行文件 - Cmd cannot run my executable without providing “.exe”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM