I am trying to use cygwin as a build environment under Windows. I have some dependencies on third-party packages like GTK +.
Usually, when I build on Linux, in my Makefile I can add a call to pkg-config as a gcc argument, so it looks like this:
gcc example.c `pkg-config --libs --cflags gtk + -2.0`
This works fine under Linux, but in cygwin I get:
: Invalid argument
make: *** [example] Error 1
Now I just run pkg-config manually and paste the output into the Makefile, which is really terrible. Is there a good way to work around or fix this problem?
Make is not a criminal. I can copy and paste the command line, which makes use for calling gcc, and on its own will run gcc, which stops with ": Invalid argument".
I wrote a small test program to output command line arguments:
for (i = 0; i < argc; i++) printf("'%s'\n", argv[i]);
Pay attention to single quotes.
$ pkg-config --libs gtk + -2.0
-Lc: / mingw / lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpang
owin32-1.0 -lgdi32 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-
2.0 -lglib-2.0 -lintl
Test program execution:
$ ./t `pkg-config --libs gtk + -2.0`
'C: \ cygwin \ home \ smo \ pvm \ src \ t.exe'
'-Lc: / mingw / lib'
'-lgtk-win32-2.0'
'-lgdk-win32-2.0'
'-latk-1.0'
'-lgdk_pixbuf-2.0'
'-lpangowin32-1.0'
'-lgdi32'
'-lpangocairo-1.0'
'-lpango-1.0'
'-lcairo'
'-lgobject-2.0'
'-lgmodule-2.0'
'-lglib-2.0'
'-lintl'
''
Pay attention to one single quote in the last line. It seems that argc alone is bigger than it should be, and argv [argc - 1] is null. Running the same test on Linux does not have this result.
However, is there, say, in some way I can make the Makefile save the result of pkg-config in a variable and then use this variable instead of using the back-tick operator?