SRS configure error in Mac pro m1 (arm64 cpu)- ld: symbol(s) not found for architecture i386 - simple-realtime-server

Operation on 'Mac M1 pro' which cpu is arm64 architecture.
on srs branch: 4.0release
do
cd trunk
./configure --osx
Get error as below:
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [apps/openssl] Error 1
make: *** [all] Error 2
Build openssl-1.1-fit failed.
Log is:
User config: --osx
Detail config: --prefix=/usr/local/srs --config=conf/srs.conf --hls=on --hds=off --dvr=on --ssl=on --https=on --ssl-1-0=off --ssl-local=off --sys-ssl=off --transcode=on --ingest=on --stat=on --http-callback=on --http-server=on --stream-caster=on --http-api=on --utest=off --cherrypy=off --srt=off --rtc=on --simulator=off --cxx11=off --cxx14=off --ffmpeg-fit=on --nasm=on --srtp-nasm=on --clean=on --gperf=off --gmc=off --gmd=off --gmp=off --gcp=off --gprof=off --static=off --shared-st=off --shared-srt=off --shared-ffmpeg=off --log-verbose=off --log-info=off --log-trace=on --gcov=off --debug=off --debug-stats=off --cross-build=off --cc=gcc --cxx=g++ --ar=ar --ld=gcc --randlib=randlib
SRS_WORKDIR: ., SRS_OBJS_DIR: objs, SRS_OBJS: ./objs, SRS_PLATFORM: Platform-Darwin-21.2.0-Clang13.1.6-SRS4-arm64
Alias python2 as python
Checking gcc/g++/gdb/make.
Required tools are ok.
OSX detected, install tools if needed
OSX install tools success
SED is sed_utility
The state-threads is ok.
Building openssl-1.1-fit.
Operating system: i686-apple-darwinDarwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000
Configuring OpenSSL version 1.1.1b (0x1010102fL) for darwin-i386-cc
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile
...
gcc -I. -Iinclude -fPIC -arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DRC4_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DPADLOCK_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/Users/hangwu/git/srs/trunk/objs/Platform-Darwin-21.2.0-Clang13.1.6-SRS4-arm64/openssl-1.1-fit/_release/ssl\"" -DENGINESDIR="\"/Users/hangwu/git/srs/trunk/objs/Platform-Darwin-21.2.0-Clang13.1.6-SRS4-arm64/openssl-1.1-fit/_release/lib/engines-1.1\"" -DNDEBUG -DOPENSSL_NO_HEARTBEATS -MMD -MF apps/app_rand.d.tmp -MT apps/app_rand.o -c -o apps/app_rand.o apps/app_rand.c
...
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [apps/openssl] Error 1
make: *** [all] Error 2
Build openssl-1.1-fit failed.
What's the possible reason for this error?
Is there any way to avoid it?
It seems the gcc config param '-arch i386' is not right for my environment, is it the root cause of this error?

Now, at 2022.08.22, Apple M1 is ok to build and run SRS 5.0. Please see issue M1: Not possible to build on Apple Silicon for detail.
We have the docker images for linux/arm/v7 and linux/arm64/v8, it should work on Apple M1 also, see #3058.
Aside from openssl build issue, we also adopt the ST(state-threads) for Apple M1. Apart from the ST(state-threads) adaption, the configure script was updated to identify M1.
ST also is avaialble for Apple M1 now, please see #22.

Related

x265 - Undefined symbols for architecture arm64 (Apple Silicon)

any ideas for this?
I try to build SDRangel on my M1 Mac but at 77% I get this error ...
-- GIT_EXECUTABLE /opt/local/bin/git
-- GIT LIVE REPO VERSION RETRIEVED
-- X265 RELEASE VERSION 3.5+68-40e37bce9
-- Detected CXX compiler using -O3 optimization level
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/build/sdrangel/build/external/x265/src/x265-build
[ 27%] Performing build step for 'x265'
Consolidate compiler generated dependencies of target common
[ 45%] Built target common
Consolidate compiler generated dependencies of target encoder
[ 65%] Built target encoder
[ 76%] Built target x265-static
[ 77%] Linking CXX shared library libx265.dylib
Undefined symbols for architecture arm64:
"x265_entropyStateBits", referenced from:
_x265_costCoeffNxN_neon in pixel-util.S.o
(maybe you meant: _x265_entropyStateBits)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[5]: *** [libx265.206.dylib] Error 1
make[4]: *** [CMakeFiles/x265-shared.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [external/x265/src/x265-stamp/x265-build] Error 2
make[1]: *** [external/CMakeFiles/x265.dir/all] Error 2
make: *** [all] Error 2
I am stuck. Don't know what to try to solve this issue.
I did not find anything anywhere ...
Working on it for most of 2 days, I did find this site that presents a working method of building libx265 stuff on Apple Silicon and works for me on macOS 13.0.1. https://www.osxexperts.net/ Problem is, it only builds the libraries for building it into ffmpeg, no executable binary.
When I tried to get the executable also, by removing -DENABLE_CLI=OFF from the last cmake command, the error comes back. Put it back in, everything completes without error.
Here is the full process that works for me (no executable). It builds a multilibrary that can encode 8, 10, or 12-bit video:
cd x265/source
#### 12 bit
cmake -DCMAKE_INSTALL_PREFIX:PATH=${TARGET} -DHIGH_BIT_DEPTH=ON -DMAIN12=ON -DENABLE_SHARED=NO -DEXPORT_C_API=NO -DENABLE_CLI=OFF .
make
mv libx265.a libx265_main12.a
make clean-generated
rm CMakeCache.txt
#### 10bit
cmake -DCMAKE_INSTALL_PREFIX:PATH=${TARGET} -DHIGH_BIT_DEPTH=ON -DMAIN10=ON -DENABLE_SHARED=NO -DEXPORT_C_API=NO -DENABLE_CLI=OFF .
make clean
make
mv libx265.a libx265_main10.a
make clean-generated && rm CMakeCache.txt
#### 8 bit and all together
# removed -DENABLE_CLI=OFF from last one so we get the x265 binary
cmake -DCMAKE_INSTALL_PREFIX:PATH=${TARGET} -DEXTRA_LIB="x265_main10.a;x265_main12.a" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON -DENABLE_SHARED=OFF -DENABLE_CLI=OFF .
make clean
make
mv libx265.a libx265_main.a
# this is Apple's libtool
libtool -static -o libx265.a libx265_main.a libx265_main10.a libx265_main12.a
make install
When I remove the last -DENABLE_CLI=OFF, here's the error:
[100%] Linking CXX executable x265
Undefined symbols for architecture arm64:
"x265_entropyStateBits", referenced from:
_x265_costCoeffNxN_neon in libx265.a(pixel-util.S.o)
_x265_10bit_costCoeffNxN_neon in libx265_main10.a(pixel-util.S.o)
_x265_12bit_costCoeffNxN_neon in libx265_main12.a(pixel-util.S.o)
(maybe you meant: _x265_entropyStateBits)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [x265] Error 1
make[1]: *** [CMakeFiles/cli.dir/all] Error 2
make: *** [all] Error 2
JimsMBPro:source jim$
EDIT: #Peter Betz, see the issue report. Until the developers correct this error, it will compile if you edit x265/source/common/aarch64/pixel-util.S, line 2410. Add an underscore as follows. Change:
movrel x1, x265_entropyStateBits
to
movrel x1, _x265_entropyStateBits

Errors in p4est and cmake when install dealii

Can anyone help me with this issue?
In order to use dealii, I tried to install p4est using the command
./configure && make && make install
and
cmake .. -DP4EST_DIR=/usr/local -DDEAL_II_WITH_P4EST=ON -DDEAL_II_WITH_MPI=ON -DCMAKE_INSTALL_PREFIX=/usr/local
under "build" folder, but some error occurs.
I also opened the file dealii-9.0.0/build/CMakeFiles/CMakeError.log, it says:
Source file was:
int main() { return 0; }
Performing C++ SOURCE FILE Test rt_LIBRARY failed with the following output:
Change Dir: /Users/chuxiaoyun/Downloads/dealii-9.0.0/build/CMakeFiles/CMakeScratch/TryCompile-Fscvq9
Run Build Command(s):/usr/bin/make -f Makefile cmTC_bc7f9/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_bc7f9.dir/build.make CMakeFiles/cmTC_bc7f9.dir/build
Building CXX object CMakeFiles/cmTC_bc7f9.dir/src.cxx.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -Drt_LIBRARY -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -mmacosx-version-min=11.6 -MD -MT CMakeFiles/cmTC_bc7f9.dir/src.cxx.o -MF CMakeFiles/cmTC_bc7f9.dir/src.cxx.o.d -o CMakeFiles/cmTC_bc7f9.dir/src.cxx.o -c /Users/chuxiaoyun/Downloads/dealii-9.0.0/build/CMakeFiles/CMakeScratch/TryCompile-Fscvq9/src.cxx
Linking CXX executable cmTC_bc7f9
/opt/homebrew/Cellar/cmake/3.25.0/bin/cmake -E cmake_link_script CMakeFiles/cmTC_bc7f9.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -mmacosx-version-min=11.6 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_bc7f9.dir/src.cxx.o -o cmTC_bc7f9 -lrt
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cmTC_bc7f9] Error 1
make: *** [cmTC_bc7f9/fast] Error 2
CMake Error at cmake/macros/macro_configure_feature.cmake:112 (MESSAGE):
Could not find the p4est library!
Insufficient p4est installation found!
p4est has to be configured with MPI enabled.
Please ensure that a suitable p4est library is installed on your computer.
If the library is not at a default location, either provide some hints for
autodetection,
$ P4EST_DIR="..." cmake <...>
$ cmake -DP4EST_DIR="..." <...>
or set the relevant variables by hand in ccmake.
Call Stack (most recent call first):
cmake/macros/macro_configure_feature.cmake:269 (FEATURE_ERROR_MESSAGE)
cmake/configure/configure_p4est.cmake:78 (CONFIGURE_FEATURE)
cmake/macros/macro_verbose_include.cmake:19 (INCLUDE)
CMakeLists.txt:124 (VERBOSE_INCLUDE)
I guess I haven't installed p4est correctly, so I configure it again.
# p4est-2.8 ./configure --enable-mpi.
( Here shows we are using MPI. I also tried p4est-2.8 ./configure --enable-mpi --prefix=/usr/local)
Then I tried to build and install p4est, but it gives me an error during installation:
# make
# ➜ p4est-2.8 make install
/Applications/Xcode.app/Contents/Developer/usr/bin/make install-recursive
Making install in sc
/Applications/Xcode.app/Contents/Developer/usr/bin/make install-am
build-aux/install-sh -c -d '/Users/xiaoyun/Downloads/p4est-2.8/local/lib'
/bin/sh ./libtool --mode=install /usr/bin/install -c src/libsc.la '/Users/xiaoyun/Downloads/p4est-2.8/local/lib'
libtool: install: /usr/bin/install -c src/.libs/libsc.0.dylib /Users/xiaoyun/Downloads/p4est-2.8/local/lib/libsc.0.dylib
install: /Users/xiaoyun/Downloads/p4est-2.8/local/lib/libsc.0.dylib: Permission denied
make[4]: *** [install-libLTLIBRARIES] Error 71
make[3]: *** [install-am] Error 2
make[2]: *** [install] Error 2
make[1]: *** [install-recursive] Error 1
I have no idea why the permission is denied, I also tried sudo make install:
objc[71909]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x20230f7e8) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10c9082c8). One of the two will be used. Which one is undefined.
objc[71909]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x20230f838) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10c908318). One of the two will be used. Which one is undefined.
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
make: getcwd: Operation not permitted
make: Nothing to be done for `install'.

SDL2 doesn't compile on macos Big Sur

In one of my projects I'm using git submodules to download the SDL2 Library and compile it. This is giving me a strange error so I tried to compile SDL2 Standalone and I got the same error.
I'm on a 13" MacBook Pro Big Sur
Steps to reproduce:
git clone https://github.com/libsdl-org/SDL.git
cd SDL
cmake . -Bbuild
make -C ./build
The error I get is
In file included from /Users/<user>/Documents/side side projects/neural networks/libs/SDL/src/file/cocoa/SDL_rwopsbundlesupport.m:24:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:12:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:91:143: error: function does not return NSString
- (NSAttributedString *)localizedAttributedStringForKey:(NSString *)key value:(nullable NSString *)value table:(nullable NSString *)tableName NS_FORMAT_ARGUMENT(1) NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0));
~~~~~~~~~~~~~~ ^ ~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:103:48: note: expanded from macro 'NS_FORMAT_ARGUMENT'
#define NS_FORMAT_ARGUMENT(A) __attribute__ ((format_arg(A)))
^ ~
1 error generated.
make[2]: *** [libs/SDL/CMakeFiles/SDL2.dir/src/file/cocoa/SDL_rwopsbundlesupport.m.o] Error 1
make[1]: *** [libs/SDL/CMakeFiles/SDL2.dir/all] Error 2
make: *** [all] Error 2
The message would imply that Apple's own SDK files don't compile, but that can't be right. What's even stranger is that I'm using git submodules with SDL2 in another project but that compiles successfully and I can't find any discernible difference between this and the other project.
Edit:
I user make -C ./build VERBOSE=1 to compare the output with the project that successfully compiled and the project that failed to compile.
Successfully compiled:
[ 0%] Building C object libs/SDL/CMakeFiles/SDL2.dir/src/file/cocoa/SDL_rwopsbundlesupport.m.o
cd "/Users/<user>/Documents/side side projects/Legion/build/libs/SDL" && /usr/local/opt/llvm/bin/clang -DSDL2_EXPORTS -DUSING_GENERATED_CONFIG_H -I"/Users/<user>/Documents/side side projects/Legion/build/libs/SDL/include" -I"/Users/<user>/Documents/side side projects/Legion/libs/SDL/include" -g -O3 -idirafter "/Users/<user>/Documents/side side projects/Legion/libs/SDL/src/video/khronos" -D_THREAD_SAFE -msse3 -msse2 -msse -m3dnow -mmmx -Wshadow -fvisibility=hidden -Wdeclaration-after-statement -Werror=declaration-after-statement -fno-strict-aliasing -Wall -fPIC -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks -o CMakeFiles/SDL2.dir/src/file/cocoa/SDL_rwopsbundlesupport.m.o -c "/Users/<user>/Documents/side side projects/Legion/libs/SDL/src/file/cocoa/SDL_rwopsbundlesupport.m"
Take note of: -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks
Failed to compile:
[ 0%] Building C object CMakeFiles/SDL2.dir/src/file/cocoa/SDL_rwopsbundlesupport.m.o
/usr/local/opt/llvm/bin/clang -DSDL2_EXPORTS -DUSING_GENERATED_CONFIG_H -I/Users/<user>/Desktop/SDL-main/build/include -I/Users/<user>/Desktop/SDL-main/include -idirafter "/Users/<user>/Desktop/SDL-main/src/video/khronos" -I/usr/local/Cellar/libusb/1.0.24/include/libusb-1.0 -D_THREAD_SAFE -msse3 -msse2 -msse -m3dnow -mmmx -Wshadow -fvisibility=hidden -Wdeclaration-after-statement -Werror=declaration-after-statement -fno-strict-aliasing -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk -mmacosx-version-min=11.5 -fPIC -o CMakeFiles/SDL2.dir/src/file/cocoa/SDL_rwopsbundlesupport.m.o -c /Users/<user>/Desktop/SDL-main/src/file/cocoa/SDL_rwopsbundlesupport.m
Take note of: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk
The only difference between the successfully compiled project and the project that failed to compile is the MacOS SDK version. The one that failed to compile used MacOS SDK 12 while the successful one used MacOS 11.3. Until this is fixed a temporary solution is to downgrade your MacOS SDK to 11.3.

cmake error with grpc in tensorflow

When trying to build tensorflow using cmake, I got the following error. I'm not sure whether it's an issue related to tensorflow or grpc. Any idea on what's going on?
This is on Mac OS Sierra.
steps to reproduce:
# clone tensorflow repo
# in tensorflow directory
cd tensorflow/contrib/cmake
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/local/bin/python3
make tf_tutorials_example_trainer
Errors:
# ...
Scanning dependencies of target tf_tutorials_example_trainer
[100%] Building CXX object CMakeFiles/tf_tutorials_example_trainer.dir/Users/kevenwang/VirtualBoxShared/another_tf/tensorflow/cc/tutorials/example_trainer.cc.o
[100%] Linking CXX executable tf_tutorials_example_trainer
Undefined symbols for architecture x86_64:
"_ares_cancel", referenced from:
on_readable_cb(grpc_exec_ctx*, void*, grpc_error*) in libgrpc_unsecure.a(grpc_ares_ev_driver_posix.cc.o)
on_writable_cb(grpc_exec_ctx*, void*, grpc_error*) in libgrpc_unsecure.a(grpc_ares_ev_driver_posix.cc.o)
"_ares_destroy", referenced from:
grpc_ares_ev_driver_unref(grpc_ares_ev_driver*) in libgrpc_unsecure.a(grpc_ares_ev_driver_posix.cc.o)
...
_grpc_ares_ev_driver_create in libgrpc_unsecure.a(grpc_ares_ev_driver_posix.cc.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [tf_tutorials_example_trainer] Error 1
make[2]: *** [CMakeFiles/tf_tutorials_example_trainer.dir/all] Error 2
make[1]: *** [CMakeFiles/tf_tutorials_example_trainer.dir/rule] Error 2
Maybe you install the grpc lib by Homebrew.
In that case , you need to link the c-ares lib.
e.g.
TARGET_LINK_LIBRARIES(demo "/usr/local/lib/libcares.a" ...)

Error installing global on Arch linux

I was trying to install global from source. I run
./configure --with-exuberant-ctags=/usr/bin/ctags
and it runs OK. However, when I run
make
it gives the error
/bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -o gtags-cscope gtags-cscope.o alloc.o basename.o
build.o command.o display.o edit.o exec.o find.o help.o history.o input.o logdir.o mouse.o mygetenv.o mypop
en.o ../libparser/libgloparser.a ../libutil/libgloutil.a ../libdb/libglodb.a ../libglibc/libgloglibc.a -llt
dl -lncurses
libtool: link: gcc -g -O2 -o gtags-cscope gtags-cscope.o alloc.o basename.o build.o command.o display.o edi
t.o exec.o find.o help.o history.o input.o logdir.o mouse.o mygetenv.o mypopen.o ../libparser/libgloparser
.a ../libutil/libgloutil.a ../libdb/libglodb.a ../libglibc/libgloglibc.a -lltdl -lncurses
/usr/bin/ld: input.o: undefined reference to symbol 'erasechar'
/usr/lib/libtinfo.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:461: gtags-cscope] Error 1
make[2]: Leaving directory '/home/pspencil/tmp/global-6.5.7/gtags-cscope'
make[1]: *** [Makefile:517: all-recursive] Error 1
make[1]: Leaving directory '/home/pspencil/tmp/global-6.5.7'
make: *** [Makefile:424: all] Error 2
I have installed the package ncurses which apparently should provide the erase char symbol. I cannot find anything useful on Google.
Explicitly link the tinfo library.
NCurses uses tinfo, from what I have read ncurses should include the tinfo functionality in it's own library, maybe this has changed recently.