Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OSX] build fails #166

Open
altafan opened this issue Jun 27, 2022 · 4 comments · May be fixed by #167
Open

[OSX] build fails #166

altafan opened this issue Jun 27, 2022 · 4 comments · May be fixed by #167

Comments

@altafan
Copy link

altafan commented Jun 27, 2022

I'm trying to build the python wrapper for gdk on my mac (BigSur) with these steps:

$ mkdir gdk-python
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install -r ./tools/requirements.txt
$ ./tools/build.sh --install $PWD/gdk-python --clang --python-version 3.9

but i get following error on the very last command (./tools/build.sh ...):

The Meson build system
Version: 0.58.0
Source dir: <datadir>/gdk
Build dir: <datadir>/gdk/build-clang
Build type: native build
Project name: gdk
Project version: 0.0.54

meson.build:1:0: ERROR: Compiler clang can not compile programs.

A full log can be found at <datadir>/gdk/build-clang/meson-logs/meson-log.txt

And this is the content of the meson-log.txt log file:

Build started at 2022-06-27T16:48:48.830448
Main binary: /usr/local/opt/[email protected]/bin/python3.9
Build Options: -Dpython-version=3.8 -Dbuildtype=release -Ddefault_library=shared -Dwerror=True
Python system: Darwin
The Meson build system
Version: 0.62.2
Source dir: <datadir>/gdk
Build dir: <datadir>/gdk/build-clang
Build type: native build
Project name: gdk
Project version: 0.0.54
Sanity testing C compiler: clang
Is cross compiler: False.
Sanity check compiler command line: clang sanitycheckc.c -o sanitycheckc.exe -isysroot /Library/Developer/CommandLineTools/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=10.13 -O3
Sanity check compile stdout:

-----
Sanity check compile stderr:
clang: warning: no such sysroot directory: '/Library/Developer/CommandLineTools/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk' [-Wmissing-sysroot]
ld: library not found for -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)

-----

meson.build:1:0: ERROR: Compiler clang can not compile programs.

How can I fix this?

@jgriffiths
Copy link
Contributor

The build script does the following for OSX:

if [ \( "$BUILD" = "--clang" \) ]; then
    if [ \( "$(uname)" = "Darwin" \) ]; then
        export XCODE_PATH=$(xcode-select --print-path 2>/dev/null)
        export PLATFORM="MacOSX"
        export SDK_PATH="$XCODE_PATH/Platforms/$PLATFORM.platform/Developer/SDKs/$PLATFORM.sdk"
        export SDK_CFLAGS="$SDK_CFLAGS -isysroot ${SDK_PATH} -mmacosx-version-min=10.13"
        export SDK_LDFLAGS="$SDK_LDFLAGS -isysroot ${SDK_PATH} -mmacosx-version-min=10.13"
        export CFLAGS="${SDK_CFLAGS} -O3"
        export LDFLAGS="${SDK_LDFLAGS}"
    fi
    build clang clang++
fi

So I'd try running xcode-select --print-path and make sure the path it prints exists. If not, you will probably need to install or select the correct installed version of the xcode build tools.

Disclaimer, I'm not familiar with Apple platforms, @lvaccaro may have an idea if this isn't your issue.

@altafan
Copy link
Author

altafan commented Jun 28, 2022

@jgriffiths I was finally able to build the python SDK but I had to manually change the SDK_PATH to:

export SDK_PATH="$XCODE_PATH/SDKs/$PLATFORM.sdk"

An even better way to retrieve the SDK path instead of constructing it could be:

export SDK_PATH=$(xcrun --show-sdk-path)

I can eventually open a PR if you think the fix makes sense.

@jgriffiths
Copy link
Contributor

@altafan I you could PR this and cc: @lvaccaro for review that would be great, thanks!

@altafan altafan linked a pull request Jun 29, 2022 that will close this issue
@lvaccaro
Copy link
Member

lvaccaro commented Jul 4, 2022

It looks a nice sdk path improvement for the building system. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants