简体   繁体   中英

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!

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:

gcc: error: pkg-config: No such file or directory
gcc: error: gtk+-3.0: No such file or directory
gcc: error: pkg-config: No such file or directory
gcc: error: gtk+-3.0: No such file or directory
gcc: error: unrecognized command line option --cflags
gcc: error: unrecognized command line option --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.

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?

Environment Variables

  1. 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:

gcc.exe: error: pkg-config.exe --cflags gtk+-3.0: No such file or directory
gcc.exe: error: pkg-config.exe --libs gtk+-3.0: No such file or directory


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.

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:

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: error: pkg-config.exe --libs gtk+-3.0: No such file or directory


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?

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!

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 . You can also use makefiles to create the .pc file ( Generate pkg-config out of Makefile )

Makefile: How to install a project with a file pkg-config

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM