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

MacOS Distributable using Homebrew has workarounds due to metacall nature #13

Open
brillard1 opened this issue Apr 11, 2023 · 2 comments

Comments

@brillard1
Copy link
Contributor

While testing the MacOS distributable, @viferga found a way to make a portable version from Homebrew. However, there are still some workarounds due to the nature of Metacall.

  • The post on Stack Overflow explains how to make MacOS look for libraries relative to the executable location at run-time. Essentially, It used the install_name_tool -change command to replace the absolute path to the library with a relative one. There's an automated script implemented that replaces all @executable_path/../Frameworks/ with @executable_path/, so that all frameworks can be in the same folder as the executable stackoverflow

  • Metacall Homebrew is a package manager for the Metacall project on macOS. It allows users to easily install and manage the Metacall runtime by automating the build and installation process. By using Metacall Homebrew, we can quickly and easily set up a development environment for the Metacall runtime on macOS.

  • By utilizing brew-pkg, we can create a distributable package for our command-line application that includes all the dependencies and libraries required to run it on a different machine. This will help to simplify the deployment process and make it easier for users to install and run the application.

From the above explanation, Metacall Homebrew and brew-pkg can be used together to create a distributable package for a macOS command-line application that uses Metacall.

Building the MacOS Distributable


The following steps describes the general workflow:

  1. Install the Metacall Homebrew formula using Homebrew package manager and build.sh from Metcall Homebrew repository
  2. Install any other dependencies required for the distributable.
  3. Build the application and its dependencies.
  4. Use the automated script provided in the previous answer to replace all @executable_path/../Frameworks/ with @executable_path/.
  5. Copy the Metacall library and any other dependencies to the same folder as the executable.
  6. Build the distributable package using the brew-pkg command.

Resources


For utilzing above scripts,

@FirePing32
Copy link
Contributor

FirePing32 commented Jan 11, 2024

Build the application and its dependencies.

@brillard1 I tried building the application using build.sh, but cmake could not find a header file named backward.hpp. Pasting last few lines of the trace below -

[ 97%] Linking CXX shared module ../../../libplugin_extension.so
[ 97%] Built target plugin_extension
[ 97%] Built target backtrace_plugin_config
[ 97%] Building CXX object source/plugins/backtrace_plugin/CMakeFiles/backtrace_plugin.dir/source/backtrace_plugin.cpp.o
/Users/prakhargurunani/dev/metacall-distributable-macos/metacall/core/source/plugins/backtrace_plugin/source/backtrace_plugin.cpp:23:10: fatal error: 'backward.hpp' file not found
#include <backward.hpp>
         ^~~~~~~~~~~~~~
1 error generated.
make[2]: *** [source/plugins/backtrace_plugin/CMakeFiles/backtrace_plugin.dir/source/backtrace_plugin.cpp.o] Error 1
make[1]: *** [source/plugins/backtrace_plugin/CMakeFiles/backtrace_plugin.dir/all] Error 2
make: *** [all] Error 2
+ error 'Cmake build target install failed.'
+ echo 'Error: Cmake build target install failed., build stopping, probably dependencies could not be downloaded.'
Error: Cmake build target install failed., build stopping, probably dependencies could not be downloaded.
+ exit 1

Although I have the file in /usr/local/include.

@viferga
Copy link
Member

viferga commented Nov 6, 2024

This has been partially solved towards a more general solution, I am leaving this here for reference: metacall/brew-pkg#4

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

3 participants