spasm-ng icon indicating copy to clipboard operation
spasm-ng copied to clipboard

Add instructions on how to build on macOS

Open AlienKevin opened this issue 2 years ago • 0 comments

I need to make 2 changes to start building on macOS Monterey (M1):

  1. Replace -lgmp with -L/opt/homebrew/Cellar/gmp/6.2.1_1/lib/ in the line LDFLAGS += -lgmp -lcrypto
  2. Add the following flags to link OpenSSL installed through brew install [email protected]
CXXFLAGS+= -I/opt/homebrew/opt/[email protected]/include
LDFLAGS+= -L/opt/homebrew/opt/[email protected]/lib

After those changes, I got stuck on undefined symbols for gmp:

g++ -o spasm main.o opcodes.o pass_one.o pass_two.o utils.o export.o preop.o directive.o console.o expand_buf.o hash.o list.o parser.o storage.o errors.o bitmap.o modp_ascii.o opcodes_ez80.o -lm -L/opt/homebrew/opt/[email protected]/lib -L/opt/homebrew/Cellar/gmp/6.2.1_1/lib/ -lcrypto
Undefined symbols for architecture arm64:
  "___gmpz_add", referenced from:
      siggen(unsigned char const*, unsigned char*, int*) in export.o
  "___gmpz_add_ui", referenced from:
      siggen(unsigned char const*, unsigned char*, int*) in export.o
  "___gmpz_clear", referenced from:
      siggen(unsigned char const*, unsigned char*, int*) in export.o
  "___gmpz_export", referenced from:
      siggen(unsigned char const*, unsigned char*, int*) in export.o
  "___gmpz_import", referenced from:
      siggen(unsigned char const*, unsigned char*, int*) in export.o
  "___gmpz_init", referenced from:
      siggen(unsigned char const*, unsigned char*, int*) in export.o
  "___gmpz_jacobi", referenced from:
      siggen(unsigned char const*, unsigned char*, int*) in export.o
  "___gmpz_mod", referenced from:
      siggen(unsigned char const*, unsigned char*, int*) in export.o
  "___gmpz_mul", referenced from:
      siggen(unsigned char const*, unsigned char*, int*) in export.o
  "___gmpz_mul_ui", referenced from:
      siggen(unsigned char const*, unsigned char*, int*) in export.o
  "___gmpz_powm", referenced from:
      siggen(unsigned char const*, unsigned char*, int*) in export.o
  "___gmpz_set_ui", referenced from:
      siggen(unsigned char const*, unsigned char*, int*) in export.o
  "___gmpz_sizeinbase", referenced from:
      siggen(unsigned char const*, unsigned char*, int*) in export.o
  "___gmpz_sub", referenced from:
      siggen(unsigned char const*, unsigned char*, int*) in export.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

workaround

Disable app signing eliminates the dependency on OpenSSL and GMP, thus the problem is solved:

NO_APPSIGN=1 make

AlienKevin avatar Jul 24 '23 23:07 AlienKevin