Skip to content

How to compile shared library as a macos universal binary  #1

@yorkie

Description

@yorkie

MacOS Universay Binary is a format which is possible for running both on Intel and Apple chips, which is produced by the following command:

$ lipo -create -output libnode_universal.dylib libnode_x86.dylib libnode_arm64.dylib

Before the above merge, we need to compile a binary at M1/M2 macbook:

export CC_host="cc -arch x86_64" 
export CXX_host="c++ -arch x86_64"
export CC_target="cc -arch x86_64" 
export CXX_target="c++ -arch x86_64"

CC="cc -arch x86_64" CXX="c++ -arch x86_64" ./configure \
    --dest-cpu=x86_64 \
    --tag=$(TAG) \
    --with-intl=none \
    --without-inspector \
    --shared

arch -x86_64 make -j10

At MacOS, use arch to convert the target architecture such as x86_64, then do run ./configure && make command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions