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

Script Failing on: ld: symbol(s) not found for architecture arm64 #3

Open
joeyboey opened this issue Dec 12, 2020 · 11 comments
Open

Script Failing on: ld: symbol(s) not found for architecture arm64 #3

joeyboey opened this issue Dec 12, 2020 · 11 comments

Comments

@joeyboey
Copy link

I alway get the error
ld: symbol(s) not found for architecture arm64
when trying to execute the build script.
Any advice?

@ssut
Copy link
Owner

ssut commented Dec 12, 2020

Can you post the log around that part?

@joeyboey
Copy link
Author

Of course!

ld: warning: ignoring file /usr/local/Cellar/libpng/1.6.37/lib/libpng16.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
  "_png_create_info_struct", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_create_read_struct", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_destroy_read_struct", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_error", referenced from:
      _read_data_from_FT_Stream in libfreetype.a(sfnt.o)
  "_png_get_IHDR", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_get_error_ptr", referenced from:
      _error_callback in libfreetype.a(sfnt.o)
      _read_data_from_FT_Stream in libfreetype.a(sfnt.o)
  "_png_get_io_ptr", referenced from:
      _read_data_from_FT_Stream in libfreetype.a(sfnt.o)
  "_png_get_valid", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_read_end", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_read_image", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_read_info", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_read_update_info", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_set_expand_gray_1_2_4_to_8", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_set_filler", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_set_gray_to_rgb", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_set_interlace_handling", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_set_longjmp_fn", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
      _error_callback in libfreetype.a(sfnt.o)
  "_png_set_packing", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_set_palette_to_rgb", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_set_read_fn", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_set_read_user_transform_fn", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_set_strip_16", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
  "_png_set_tRNS_to_alpha", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [fc-cache] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

@ssut
Copy link
Owner

ssut commented Dec 13, 2020

Can you try installing libtool with the arm64 version of Homebrew? (located in /opt/homebrew)

@joeyboey
Copy link
Author

It was already installed:

Warning: libtool 2.4.6_2 is already installed and up-to-date
To reinstall 2.4.6_2, run `brew reinstall libtool`

It still fails after a reinstall.

@joeyboey
Copy link
Author

joeyboey commented Dec 13, 2020

So I cleared the workdir. Now it failes even sooner because nasmis not downloaded at all. All I can find is yasm.

+ echo '♻️ ' Start compiling NASM
♻️  Start compiling NASM
+ cd /Users/joe/workdir/compile
+ cd nasm-2.15.05
./build.bash: line 167: cd: nasm-2.15.05: No such file or directory

It seems to download nasm but under the name yasm:

+ echo 'Downloading: nasm (2.15.05)'
Downloading: nasm (2.15.05)
+ curl -Ls -o - http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
+ tar zxf - -C /Users/joe/workdir/compile/
+ tar zxf - -C /Users/joe/workdir/compile/
+ tar zxf - -C /Users/joe/workdir/compile/

For comparison this is how homebrew is installed:

joe@MacBook-Pro ~ % which brew
/opt/homebrew/bin/brew
joe@MacBook-Pro ~ % brew --prefix
/opt/homebrew
joe@MacBook-Pro ~ % which ibrew
ibrew: aliased to arch -x86_64 /usr/local/bin/brew
joe@MacBook-Pro ~ % ibrew --prefix
/usr/local

After another clearing of the workdir, nasm works fine, the first error comes up again.

When I just try to execute ld this is the output:

joe@MacBook-Pro ~ % ld -v
@(#)PROGRAM:ld  PROJECT:ld64-609.7
BUILD 18:10:15 Oct 19 2020
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
LTO support using: LLVM version 12.0.0, (clang-1200.0.32.27) (static support for 27, runtime is 27)
TAPI support using: Apple TAPI version 12.0.0 (tapi-1200.0.23.4)

But this is the apple version, not the one from homebrew, right?

@joeyboey
Copy link
Author

joeyboey commented Dec 13, 2020

The nasm error is related to the download domain being temporarily unavailable.

Could you maybe provide your compiled version as a release, then we could just use this until the build process is a little bit more reliable.

Edit:
There is a prebuilt package available:
ffmpeg 4.3.1 arm64

@Prushka
Copy link

Prushka commented Jan 8, 2021

Same error happened to me

ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)```

@stang2019
Copy link

how do we create arm64e/x86_64 universal library? looks like it only generate the lib same as system CPU arch

@stang2019
Copy link

stang2019 commented Jan 8, 2021

I updated the 'arm64' to 'arm64 x86_64' to check if I could get the universal

if [[ "$(uname -m)" == "arm64" ]]; then
export ARCH=arm64 x86_64
else
export ARCH=x86_64
fi

@stang2019
Copy link

still only arm64

lipo -info ./libavcodec.a
Non-fat file: ./libavcodec.a is architecture: arm64

@nicklezheng
Copy link

nicklezheng commented Jun 4, 2022

ffmpeg depend other libs(libpng16, freetype .. ), you also need to link them to your target.

what's more, wrap ffmpeg header file with extern C while including them in c++ code. like:

extern "C" {
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
#include "libavutil/mathematics.h"
}

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

5 participants