I am trying to do it, but all I can get is some source code that I don't know how to do deal with I downloaded from http://pkgconfig.freedesktop.org/releases/.
8 Answers
This is a step-by-step procedure to get pkg-config working on Windows, based on my experience, using the info from Oliver Zendel's comment.
I assume here that MinGW was installed to C:\MinGW. There were multiple versions of the packages available, and in each case I just downloaded the latest version.
- go to http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/
- download the file pkg-config_0.26-1_win32.zip
- extract the file bin/pkg-config.exe to C:\MinGW\bin
- download the file gettext-runtime_0.18.1.1-2_win32.zip
- extract the file bin/intl.dll to C:\MinGW\bin
- go to http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.28
- download the file glib_2.28.8-1_win32.zip
- extract the file bin/libglib-2.0-0.dll to C:\MinGW\bin
Now CMake will be able to use pkg-config if it is configured to use MinGW.
- 49,619
- 19
- 114
- 198
- 1,342
- 9
- 11
-
3how to change cmake to configure to use MinGW? – cindywmiao Jun 16 '14 at 22:17
-
2@cindywmiao: choose a CMake generator with MinGW in its name, like "MinGW Makefiles", from the list of generators. I personally use "CodeBlocks - MinGW Makefiles" which additionally generates a project file for the CodeBlocks IDE. – HyperQuantum Jun 18 '14 at 07:43
-
2You don't have to use MinGW - you can follow these steps but extract pk-config.exe and the required DLL's to any folder of your choosing (including a new folder), just be sure the folder is in your PATH. – yoyo May 08 '20 at 23:55
-
it's complicated. is there any newer answer for 2021? it's different now. – Yen Dang Oct 04 '21 at 20:32
Get the precompiled binaries from http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/
Download pkg-config and its depend libraries :
- 24,143
- 12
- 85
- 121
- 43,610
- 8
- 84
- 94
-
16I found the needed gtk binaries there too; for pkg-config_0.26-1_win32.zip you need the file libglib-2.0-0.dll from http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.28/glib_2.28.8-1_win32.zip and intl.dll from http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime_0.18.1.1-2_win32.zip – Oliver Zendel May 22 '13 at 14:40
-
7
-
3
-
10But where does pkg-config on Windows look for installed libs?? Where does it go to search for pc files? This is SO confusing and a shame for everybody involved in such garbage software... :) – Zordid Mar 28 '19 at 13:34
-
-
1Put the pkg-config executables and dependent DLLs in any folder on the path, e.g. C:\WINDOWS – SmacL Nov 18 '19 at 12:50
A alternative without glib dependency is pkg-config-lite.
Extract pkg-config.exe from the archive and put it in your path.
Nowdays this package is available using chocolatey, then it could be installed with
choco install pkgconfiglite
- 10,379
- 42
- 54
- 85
-
Works well, also the *other* pkg-config listed in the FAQ [here](http://mingw.org/wiki/FAQ) crashes for me on Windows 10 Home as well as Pro. – kumarharsh Dec 07 '17 at 07:57
-
-
Add the directory where you extract the executable in the environnement variable PATH, in order to access it. – mpromonet Oct 05 '21 at 11:57
I did this by installing Cygwin64 from this link https://www.cygwin.com/ Then - View Full, Search gcc and scroll down to find pkg-config. Click on icon to select latest version. This worked for me well.
- 1,122
- 17
- 25
I would like to extend the answer of @dzintars about the Cygwin version of pkg-config in that focus how should one use it properly with CMake, because I see various comments about CMake in this topic.
I have experienced many troubles with CMake + Cygwin's pkg-config and I want to share my experience how to avoid them.
1. The symlink C:/Cygwin64/bin/pkg-config -> pkgconf.exe does not work in Windows console.
It is not a native Windows .lnk symlink and it won't be callable in Windows console cmd.exe even if you add ".;" to your %PATHEXT% (see https://www.mail-archive.com/cygwin@cygwin.com/msg104088.html).
It won't work from CMake, because CMake calls pkg-config with the method execute_process() (FindPkgConfig.cmake) which opens a new cmd.exe.
Solution: Add -DPKG_CONFIG_EXECUTABLE=C:/Cygwin64/bin/pkgconf.exe to the CMake command line (or set it in CMakeLists.txt).
2. Cygwin's pkg-config recognizes only Cygwin paths in PKG_CONFIG_PATH (no Windows paths).
For example, on my system the .pc files are located in C:\Cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\lib\pkgconfig. The following three paths are valid, but only path C works in PKG_CONFIG_PATH:
- A) c:/Cygwin64/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig - does not work.
- B) /c/cygdrive/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig - does not work.
- C) /usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig - works.
Solution: add .pc files location always as a Cygwin path into PKG_CONFIG_PATH.
3) CMake converts forward slashes to backslashes in PKG_CONFIG_PATH on Cygwin.
It happens due to the bug https://gitlab.kitware.com/cmake/cmake/-/issues/21629. It prevents using the workaround described in [2].
Solution: manually update the function _pkg_set_path_internal() in the file C:/Program Files/CMake/share/cmake-3.x/Modules/FindPkgConfig.cmake. Comment/remove the line:
file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path)
4) CMAKE_PREFIX_PATH, CMAKE_FRAMEWORK_PATH, CMAKE_APPBUNDLE_PATH have no effect on pkg-config in Cygwin.
Reason: the bug https://gitlab.kitware.com/cmake/cmake/-/issues/21775.
Solution: Use only PKG_CONFIG_PATH as an environment variable if you run CMake builds on Cygwin. Forget about CMAKE_PREFIX_PATH, CMAKE_FRAMEWORK_PATH, CMAKE_APPBUNDLE_PATH.
- 1,868
- 1
- 19
- 26
- Install mingw64 from https://sourceforge.net/projects/mingw-w64/. Avoid program files/(x86) folder for installation. Ex. c:/mingw-w64
- Download pkg-config__win64.zip from here
- Extract above zip file and copy paste all the files from pkg-config/bin folder to mingw-w64. In my case its 'C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin'
- Now set path = C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin taddaaa you are done.
If you find any security issue then follow steps as well
- Search for windows defender security center in system
- Navigate to apps & browser control> Exploit protection settings> Program setting> Click on '+add program customize'
- Select add program by name
- Enter program name: pkgconf.exe
- OK
- Now check all the settings and set it all the settings to off and apply.
Thats DONE!
- 31
- 1
Another place where you can get more updated binaries can be found at Fedora Build System site. Direct link to mingw-pkg-config package is: http://koji.fedoraproject.org/koji/buildinfo?buildID=354619
- 367
- 3
- 3
-
That site does seem to have more recent builds, but the build you linked to is out of date. The package link is actually http://koji.fedoraproject.org/koji/packageinfo?packageID=13212 – player_03 Aug 14 '13 at 03:41
-
Following up to my previous comment: those downloads don't help; I extracted the file with 7-Zip and had no idea what to do next. Instead I went with the instructions on the following site, despite them calling for a less up-to-date build: http://www.gaia-gis.it/spatialite-3.0.0-BETA/mingw_how_to.html#pkg-config – player_03 Aug 14 '13 at 03:57
-
3that page assumes Mingw. I run Visual Studio 2008 on my Mac from a VM. Hard disk space is scarce. I don't want to install mingw or Cygwin only to be able to run pkg-config. pkg-config missing is an error spat out by cmake. I feel lost in that mess – Jean-Denis Muys Aug 28 '13 at 08:13
for w64-based computers you have to install mingw64. If pkg-config.exe is missing then, you can refer to http://ftp.acc.umu.se/pub/gnome/binaries/win64/dependencies/
Unzip and copy/merge pkg-config.exe into your C:\mingw-w64 installation, eg. into on my pc into C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin
- 375
- 2
- 16