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

Building on Mac M1 needs a tweak. #110

Open
SpaceMonkeyForever opened this issue Sep 15, 2022 · 1 comment
Open

Building on Mac M1 needs a tweak. #110

SpaceMonkeyForever opened this issue Sep 15, 2022 · 1 comment

Comments

@SpaceMonkeyForever
Copy link

I get the following error when compiling on Mac M1:

[ 98%] Building C object src/CMakeFiles/nng.dir/supplemental/http/http_server.c.o
[100%] Linking C static library ../libnng.a
[100%] Built target nng
creating build
creating build/lib.macosx-12-arm64-cpython-310
creating build/lib.macosx-12-arm64-cpython-310/pynng
copying pynng/options.py -> build/lib.macosx-12-arm64-cpython-310/pynng
copying pynng/_version.py -> build/lib.macosx-12-arm64-cpython-310/pynng
copying pynng/__init__.py -> build/lib.macosx-12-arm64-cpython-310/pynng
copying pynng/_aio.py -> build/lib.macosx-12-arm64-cpython-310/pynng
copying pynng/tls.py -> build/lib.macosx-12-arm64-cpython-310/pynng
copying pynng/sockaddr.py -> build/lib.macosx-12-arm64-cpython-310/pynng
copying pynng/exceptions.py -> build/lib.macosx-12-arm64-cpython-310/pynng
copying pynng/nng.py -> build/lib.macosx-12-arm64-cpython-310/pynng
running build_ext
generating cffi module 'build/temp.macosx-12-arm64-cpython-310/pynng._nng.c'
creating build/temp.macosx-12-arm64-cpython-310
build_nng_lib()
building 'pynng._nng' extension
creating build/temp.macosx-12-arm64-cpython-310/build
creating build/temp.macosx-12-arm64-cpython-310/build/temp.macosx-12-arm64-cpython-310
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Inng/include -I/Users/spacemonkey/Projects/mangotrader/mangotrader/env/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c build/temp.macosx-12-arm64-cpython-310/pynng._nng.c -o build/temp.macosx-12-arm64-cpython-310/build/temp.macosx-12-arm64-cpython-310/pynng._nng.o
clang -bundle -undefined dynamic_lookup build/temp.macosx-12-arm64-cpython-310/build/temp.macosx-12-arm64-cpython-310/pynng._nng.o ./nng/build/libnng.a ./mbedtls/prefix/lib/libmbedtls.a ./mbedtls/prefix/lib/libmbedx509.a ./mbedtls/prefix/lib/libmbedcrypto.a -lpthread -latomic -o build/lib.macosx-12-arm64-cpython-310/pynng/_nng.abi3.so
ld: library not found for -latomic
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/usr/bin/clang' failed with exit code 1

The main error ld: library not found for -latomic seems to be resolved by removing -latmoice from the linking step. So, instead, I can do:

clang -bundle -undefined dynamic_lookup build/temp.macosx-12-arm64-cpython-310/build/temp.macosx-12-arm64-cpython-310/pynng._nng.o ./nng/build/libnng.a ./mbedtls/prefix/lib/libmbedtls.a ./mbedtls/prefix/lib/libmbedx509.a ./mbedtls/prefix/lib/libmbedcrypto.a -lpthread ~-latomic~ -o build/lib.macosx-12-arm64-cpython-310/pynng/_nng.abi3.so

Then I can python setup.py install and I can import it fine. It seems to work fine when I tested REQ/REP against a Rust REP server.

@codypiersall
Copy link
Owner

I think there was a PR that fixed this, if it's possible for you to retry from master I'd appreciate it. I don't have a Mac so can't actually test anything on my end.

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

No branches or pull requests

2 participants