Skip to content

Instantly share code, notes, and snippets.

@jl
Created February 20, 2016 05:40
Show Gist options
  • Select an option

  • Save jl/9e5ebbc9ccf44f3c804e to your computer and use it in GitHub Desktop.

Select an option

Save jl/9e5ebbc9ccf44f3c804e to your computer and use it in GitHub Desktop.
Installing pkg-config from source on OS X
@givingwu
Copy link

givingwu commented Aug 2, 2019

First, thanks for your share.

And i am confusing about the first line of the code LDFLAGS="-framework CoreFoundation -framework Carbon" ./configure --with-internal-glib,

what's that means LDFLAGS="-framework CoreFoundation -framework Carbon"?

@meschbach
Copy link

OSX & iOS uses a mechanism for managing development resources such as a libraries called Frameworks. These are generally frameworks in the Software Engineering sense however might also just be libraries. The flag informs the tool chain to build against these libraries.

See Apple's documentation about it for more details.

@Kampouse
Copy link

@scrutinizer11
Copy link

scrutinizer11 commented Jun 18, 2022

Thank you very much. To compile another binary pkg-config was a requirement although I'll never use it. You're the first one to explain how to compile the damn thing on macOS in plain human language. Additionally, the official GitLab link given on freedesktop.org to download "the source code" landed me with a package without the configure exec but with vastly inarticulate instructions.

@rangelfn
Copy link

I went to compile OS Sonoma on my Mac and got this error:

gatomic.c:392:10: error: incompatible integer to pointer conversion passing 'gssize' (aka 'long') to parameter of type 'gpointer' (aka 'void *') [-Wint-conversion]
  return g_atomic_pointer_add ((volatile gpointer *) atomic, val);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./gatomic.h:170:46: note: expanded from macro 'g_atomic_pointer_add'
    (gssize) __sync_fetch_and_add ((atomic), (val));                         \
                                             ^~~~~
gatomic.c:416:10: error: incompatible integer to pointer conversion passing 'gsize' (aka 'unsigned long') to parameter of type 'gpointer' (aka 'void *') [-Wint-conversion]
  return g_atomic_pointer_and ((volatile gpointer *) atomic, val);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./gatomic.h:177:45: note: expanded from macro 'g_atomic_pointer_and'
    (gsize) __sync_fetch_and_and ((atomic), (val));                          \
                                            ^~~~~
gatomic.c:440:10: error: incompatible integer to pointer conversion passing 'gsize' (aka 'unsigned long') to parameter of type 'gpointer' (aka 'void *') [-Wint-conversion]
  return g_atomic_pointer_or ((volatile gpointer *) atomic, val);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./gatomic.h:184:44: note: expanded from macro 'g_atomic_pointer_or'
    (gsize) __sync_fetch_and_or ((atomic), (val));                           \
                                           ^~~~~
gatomic.c:464:10: error: incompatible integer to pointer conversion passing 'gsize' (aka 'unsigned long') to parameter of type 'gpointer' (aka 'void *') [-Wint-conversion]
  return g_atomic_pointer_xor ((volatile gpointer *) atomic, val);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./gatomic.h:191:45: note: expanded from macro 'g_atomic_pointer_xor'
    (gsize) __sync_fetch_and_xor ((atomic), (val));                          \
                                            ^~~~~
4 errors generated.
make[6]: *** [libglib_2_0_la-gatomic.lo] Error 1
make[5]: *** [all-recursive] Error 1
make[4]: *** [all] Error 2
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

@m-bob
Copy link

m-bob commented May 29, 2024

Same issue as [rangelfn]. So far, I've been unable to work around it.

@mkdeak
Copy link

mkdeak commented Jun 17, 2024

Running into the same issue as well. Sonoma 14.5 on Apple Silicon.

@mkdeak
Copy link

mkdeak commented Jun 17, 2024

@m-bob
Copy link

m-bob commented Jun 17, 2024

@mkdeak

Thanks for the info. I'm also running Sonoma 14.5 on Apple Silicon (M1 Air).

But no joy. I tried to make pkgconfig 0.28.

From what I gleaned from the link you provided, I tried:

CFLAGS="-Wno-int-conversion"
CXXFLAGS="-Wno-int-conversion"
./configure --with-internal-glib

Same errors as before when I tried to make.

Did I misinterpret the link? Should I try a newer pkgconfig?

Should I try to build glib separately and then try to build pkgconfig without using its internal glib?

Again, thanks!

@rangelfn

@mkdeak
Copy link

mkdeak commented Jun 18, 2024

@m-bob try running the three things on the same line: CFLAGS="-Wno-int-conversion" CXXFLAGS="-Wno-int-conversion" ./configure --with-internal-glib

@m-bob
Copy link

m-bob commented Jun 18, 2024 via email

@math-steam
Copy link

@mkdeak Your solution is very useful!

@paulmromer
Copy link

If you are not familiar with Make (and I am not), it is not clear whether the advice given above about setting CFLAGS on a single line means that one should run these two different lines one after the other:

LDFLAGS="-framework CoreFoundation -framework Carbon" ./configure --with-internal-glib
CFLAGS="-Wno-int-conversion" CXXFLAGS="-Wno-int-conversion" ./configure --with-internal-glib

or run a single line like this:

LDFLAGS="-framework CoreFoundation -framework Carbon" CFLAGS="-Wno-int-conversion" CXXFLAGS="-Wno-int-conversion" ./configure --with-internal-glib

When I tried running the two lines one after another, the Makefile had a line

LDFLAGS =

which suggests that the second command overwrote the version where the LDFLAGS were set.

When I ran the single line command, the same line in Makefile was

LDFLAGS = -framework CoreFoundation -framework Carbon

All other lines were the same. So it looks like the right approach is to set LDFLAGS, CFLAGS and CXXFLAGS on a single line.

BTW, after I created the Makefile that did not set LDFLAGS, the make and sudo make install commands ran without generating errors. The version of pkg-config created this way may work for some purposes, but if you want a version that has the LDFLAGS set to -framework CoreFoundation -framework Carbon, you probably need to run a single line that sets all the flags and then run the other two commands.

@abaqueiro
Copy link

Thank you very much to everyone for the contributions, you helped me to finally get pkg-config to compile

What I learn from this is that we can't go through life blindly, we have to learn to use the tools, for me this worked to fix the errors compiling in Apple Silicon M2 (2025):

I install my self compiled stuff in /opt/pokemon

This commands make the tric:

tar xvf pkg-config-0.29.2.tar.gz
mkdir pkg-config-build
cd pkg-config-build
export CFLAGS="-Wno-int-conversion"
export CXXFLAGS="-Wno-int-conversion"
../pkg-config-0.29.2/configure --prefix=/opt/pokemon --exec-prefix=/opt/pokemon --with-internal-glib
make
make install

  • /opt/pokemon should have rwx file permissions for the user running the commands

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment