meganz / MEGAcmd

Command Line Interactive and Scriptable Application to access MEGA
Other
1.92k stars 406 forks source link

`configure: error: readline library is required for the sample client.` #544

Open pcko1 opened 3 years ago

pcko1 commented 3 years ago
checking for a BSD-compatible install... /opt/homebrew/bin/ginstall -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /opt/homebrew/bin/gmkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: executing depfiles commands
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for wchar.h... yes
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether _XOPEN_SOURCE should be defined... no
checking dependency style of gcc... (cached) gcc3
checking build system type... aarch64-apple-darwin20.3.0
checking host system type... aarch64-apple-darwin20.3.0
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 786432
checking how to convert aarch64-apple-darwin20.3.0 file names to aarch64-apple-darwin20.3.0 format... func_convert_file_noop
checking how to convert aarch64-apple-darwin20.3.0 file names to toolchain format... func_convert_file_noop
checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin20.3.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking whether make supports nested variables... (cached) yes
checking for size_t... yes
checking for uint8_t... yes
checking for uint16_t... yes
checking for uint32_t... yes
checking for uint64_t... yes
checking for pid_t... yes
checking for off_t... yes
checking for ssize_t... yes
checking for g++... g++
checking whether the compiler supports GNU Objective C++... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking dependency style of g++... (cached) gcc3
checking for g++... g++
checking whether the compiler supports GNU C++... yes
checking whether g++ accepts -g... yes
checking for g++ option to enable C++11 features... none needed
checking dependency style of g++... gcc3
checking dependency style of g++... (cached) gcc3
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fno-common -DPIC
checking if g++ PIC flag -fno-common -DPIC works... yes
checking if g++ static flag -static works... no
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin20.3.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether build environment is sane... yes
checking for cppcheck... no
checking whether g++ supports C++11 features by default... no
checking whether g++ supports C++11 features with -std=c++11... yes
checking for egrep... (cached) /usr/bin/grep -E
checking for egrep... (cached) /usr/bin/grep -E
checking for _Bool... no
checking for stdbool.h that conforms to C99... yes
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking for _LARGEFILE_SOURCE value needed for large files... no
checking for off_t... (cached) yes
checking size of uint64_t... 8
checking whether struct tm is in sys/time.h or time.h... time.h
checking for off_t... (cached) yes
checking for size_t... (cached) yes
checking for arpa/inet.h... yes
checking for netdb.h... yes
checking for netinet/in.h... yes
checking for stddef.h... yes
checking for stdint.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for sys/socket.h... yes
checking for sys/timeb.h... yes
checking for htonl... no
checking for glob.h... yes
checking for malloc.h... no
checking for sys/malloc.h... yes
checking for malloc/malloc.h... yes
checking whether C++ compiler accepts -fPIC... yes
checking whether the linker accepts -fPIC... yes
checking if building for Win32 platform... no
checking for libpcrecpp... --with-pcre not specified
checking for pcrecpp.h... no
checking for main in -lpcrecpp... no
checking for pcre_compile in -lpcre... yes
checking for termcap... --with-termcap not specified
checking for tputs in -ltermcap... yes
checking for Readline... --with-readline not specified
checking for readline/readline.h... yes
checking for rl_save_prompt in -lreadline... no
configure: error: readline library is required for the sample client.
acristoffers commented 2 years ago

To compile on an M1 machine, with macOS 12.3, I had to do the following (It's a https://fish.sh script, not bash!!!):

#!/usr/bin/env fish

brew install cmake qt

git clone https://github.com/meganz/MEGAcmd.git
cd MEGAcmd
git submodule update --init --recursive

# cryptopp is not on Homebrew
git clone https://github.com/weidai11/cryptopp
pushd cryptopp
make
popd

# pdfium is not on HomeBrew, but we have arm64 binaries available
mkdir pdfium
pushd pdfium
curl -LO https://github.com/bblanchon/pdfium-binaries/releases/latest/download/pdfium-mac-arm64.tgz
tar -xf pdfium-mac-arm64.tgz
popd

# This project builds sqlite instead of using binaries
curl -LO https://www.sqlite.org/2022/sqlite-amalgamation-3380500.zip
unzip sqlite-amalgamation-3380500.zip
mkdir -p sdk/bindings/qt/3rdparty/{include,libs}
cp sqlite-amalgamation-3380500/sqlite3.c sdk/bindings/qt/3rdparty/sqlite3.c
cp sqlite-amalgamation-3380500/sqlite3.h sdk/bindings/qt/3rdparty/include/sqlite3.h

# We need static c-ares and homebrew only gives us a dynamic one
git clone https://github.com/c-ares/c-ares.git
pushd c-ares
mkdir build
pushd build
cmake .. -DCARES_STATIC=ON
make
popd
popd

set LIBS readline openssl@1.1 c-ares curl freeimage libsodium ffmpeg media-info pcre libuv libnghttp2 libssh2 openldap libidn2 krb5 brotli rtmpdump zstd

brew install $LIBS

# Patches FreeImage to turn typedef's into #define's
echo "
--- /opt/homebrew/opt/freeimage/include/FreeImage.h 2022-05-14 17:45:04.000000000 +0200
+++ FreeImage.h 2022-05-14 17:48:11.000000000 +0200
@@ -150,22 +150,22 @@
 #ifndef _MSC_VER
 // define portable types for 32-bit / 64-bit OS
 #include <inttypes.h>
-typedef int32_t BOOL;
-typedef uint8_t BYTE;
-typedef uint16_t WORD;
-typedef uint32_t DWORD;
-typedef int32_t LONG;
-typedef int64_t INT64;
-typedef uint64_t UINT64;
+#define BOOL int32_t
+#define BYTE uint8_t
+#define WORD uint16_t
+#define DWORD uint32_t
+#define LONG int32_t
+#define FIINT64 int64_t
+#define FIUINT64 uint64_t
 #else
 // MS is not C99 ISO compliant
-typedef long BOOL;
-typedef unsigned char BYTE;
-typedef unsigned short WORD;
-typedef unsigned long DWORD;
-typedef long LONG;
-typedef signed __int64 INT64;
-typedef unsigned __int64 UINT64;
+#define BOOL long
+#define BYTE unsigned char
+#define WORD unsigned short
+#define DWORD unsigned long
+#define LONG long
+#define FIINT64 signed __int64
+#define FIUINT64 unsigned __int64
 #endif // _MSC_VER

 #if (defined(_WIN32) || defined(__WIN32__))" | patch -N (brew --prefix freeimage)/include/FreeImage.h

# Patches the SDK because it's calling a property which was hidden by the AVCodec guys.
echo "
--- sdk/src/gfx/freeimage.cpp   2022-05-14 18:47:50.000000000 +0200
+++ sdk/src/gfx/freeimage.cpp   2022-05-14 18:49:08.000000000 +0200
@@ -236,7 +236,7 @@

     // Find decoder for video stream
     AVCodecID codecId = codecParm->codec_id;
-    AVCodec* decoder = avcodec_find_decoder(codecId);
+    const AVCodec* decoder = avcodec_find_decoder(codecId);
     if (!decoder)
     {
         LOG_warn << "Codec not found: " << codecId;
@@ -253,7 +253,7 @@

     // Force seeking to key frames
     formatContext->seek2any = false;
-    videoStream->skip_to_keyframe = true;
+   // videoStream->skip_to_keyframe = true;
     if (decoder->capabilities & CAP_TRUNCATED)
     {
         codecContext->flags |= CAP_TRUNCATED;" | patch -N sdk/src/gfx/freeimage.cpp

# Patches installer_mac.sh to not build itself and to get the correct binaries.
echo '
--- /Users/alan/Developer/MEGAcmd/build/installer_mac.sh    2022-05-13 11:39:30.000000000 +0200
+++ installer_mac.sh    2022-05-14 23:23:57.000000000 +0200
@@ -7,17 +7,17 @@
 APP_NAME=MEGAcmd
 MOUNTDIR=tmp
 RESOURCES=installer/resourcesDMG
-QTBASE=/QT/qt5/qtbase
+QTBASE=$(brew --prefix qt)

-AVCODEC_VERSION=libavcodec.57.dylib
-AVFORMAT_VERSION=libavformat.57.dylib
-AVUTIL_VERSION=libavutil.55.dylib
-SWSCALE_VERSION=libswscale.4.dylib
-
-AVCODEC_PATH=sdk/bindings/qt/3rdparty/libs/$AVCODEC_VERSION
-AVFORMAT_PATH=sdk/bindings/qt/3rdparty/libs/$AVFORMAT_VERSION
-AVUTIL_PATH=sdk/bindings/qt/3rdparty/libs/$AVUTIL_VERSION
-SWSCALE_PATH=sdk/bindings/qt/3rdparty/libs/$SWSCALE_VERSION
+AVCODEC_VERSION=$(basename $(ls $(brew --prefix ffmpeg)/lib/libavcodec.??.dylib))
+AVFORMAT_VERSION=$(basename $(ls $(brew --prefix ffmpeg)/lib/libavformat.??.dylib))
+AVUTIL_VERSION=$(basename $(ls $(brew --prefix ffmpeg)/lib/libavutil.??.dylib))
+SWSCALE_VERSION=$(basename $(ls $(brew --prefix ffmpeg)/lib/libswscale.?.dylib))
+
+AVCODEC_PATH=$(brew --prefix ffmpeg)/lib/$AVCODEC_VERSION
+AVFORMAT_PATH=$(brew --prefix ffmpeg)/lib/$AVFORMAT_VERSION
+AVUTIL_PATH=$(brew --prefix ffmpeg)/lib/$AVUTIL_VERSION
+SWSCALE_PATH=$(brew --prefix ffmpeg)/lib/$SWSCALE_VERSION

 sign=0
 createdmg=0
@@ -37,11 +37,11 @@
     shift
 done

-rm -rf Release_x64
-mkdir Release_x64
+# rm -rf Release_x64
+# mkdir Release_x64
 cd Release_x64
-$QTBASE/bin/qmake -r ../../contrib/QtCreator/MEGAcmd/ -spec macx-g++ CONFIG+=release CONFIG+=x86_64 -nocache
-make -j$(sysctl -n hw.ncpu)
+# $QTBASE/bin/qmake -r ../../contrib/QtCreator/MEGAcmd/ -spec macx-g++ CONFIG+=release CONFIG+=x86_64 -nocache
+# make -j$(sysctl -n hw.ncpu)

 #After building, we will have 5 folders (one per project: MEGAcmdServer, MEGAcmdClient, MEGAcmdLoader, MEGAcmdUpdater & MEGAcmdShell)
 # we will include the stuff from the other 4 into MEGAcmdServer folder
@@ -98,10 +98,10 @@
 mv MEGAcmdServer/MEGAcmd.app ./MEGAcmd.app

 mkdir -p MEGAcmd.app/Contents/Frameworks
-cp -L ../../$AVCODEC_PATH MEGAcmd.app/Contents/Frameworks/
-cp -L ../../$AVFORMAT_PATH MEGAcmd.app/Contents/Frameworks/
-cp -L ../../$AVUTIL_PATH MEGAcmd.app/Contents/Frameworks/
-cp -L ../../$SWSCALE_PATH MEGAcmd.app/Contents/Frameworks/
+cp -L $AVCODEC_PATH MEGAcmd.app/Contents/Frameworks/
+cp -L $AVFORMAT_PATH MEGAcmd.app/Contents/Frameworks/
+cp -L $AVUTIL_PATH MEGAcmd.app/Contents/Frameworks/
+cp -L $SWSCALE_PATH MEGAcmd.app/Contents/Frameworks/

 if [ ! -f MEGAcmd.app/Contents/Frameworks/$AVCODEC_VERSION ]  \
    || [ ! -f MEGAcmd.app/Contents/Frameworks/$AVFORMAT_VERSION ]  \
@@ -163,11 +163,4 @@
    rmdir $MOUNTDIR
 fi

-echo "Cleaning"
-rm -rf MEGAcmdServer
-rm -rf MEGAcmdClient
-rm -rf MEGAcmdShell
-rm -rf MEGAcmdLoader
-rm -rf MEGAcmdUpdater
-
 echo "DONE"' | patch -N build/installer_mac.sh

sh autogen.sh

set LDFLAGS -L(pwd)/cryptopp -L(pwd)/pdfium/lib -lnghttp2 -lssh2 -lldap -llber -lidn2 -lgssapi_krb5 -lssl -lcrypto -lbrotli{common,dec,enc}-static -lrtmp -lzstd -lresolv
set CFLAGS  -I(pwd) -I(pwd)/pdfium/include -I(pwd)/cryptopp

for lib in $LIBS
    set -p LDFLAGS -L(brew --prefix $lib)/lib
    set -p CFLAGS  -I(brew --prefix $lib)/include
    cp (brew --prefix $lib)/lib/*.a sdk/bindings/qt/3rdparty/libs
end

cp c-ares/build/lib/libcares_static.a sdk/bindings/qt/3rdparty/libs/libcares.a
cp pdfium/lib/* sdk/bindings/qt/3rdparty/libs

./configure LDFLAGS="$LDFLAGS" CXXFLAGS="-std=c++17 $CFLAGS" OBJCXXFLAGS="-std=c++17 $CFLAGS" CFLAGS="$CFLAGS" CPPFLAGS="$CFLAGS"

find contrib/QtCreator -type f -name '*.pr*' -exec sed -i '' -e "s/10.9/$(sw_vers -productVersion)/g" {} \;
mkdir -p build/Release_x64
pushd build/Release_x64
qmake ../../contrib/QtCreator/MEGAcmd QMAKE_CFLAGS_RELEASE="$CFLAGS" QMAKE_CXXFLAGS_RELEASE="-std=c++17 $CFLAGS" QMAKE_LFLAGS_RELEASE="$LDFLAGS"
make
for exe in */*.app/Contents/MacOS/*
    install_name_tool -change ./libpdfium.dylib (pwd)/../../pdfium/lib/libpdfium.dylib $exe
end
cd ..
zsh installer_mac.sh
popd

However, mega-cmd SIGSEGV (Address boundary error), which is the same problem I have with the binaries I download from the site.

genialcode2077 commented 7 months ago

hello, how fix the issue on mac m1 ?