I a bit new to sqllite lite and linux commands so any help would be greatly appreciated! Is there something I am missing?
After the sqlite-3.7.3 installation, for some reason I am still still not seeing the new version (sqlite-3.7.3) when checking with
macbook-pro:sqlite-3.7.3 scott$ which sqlite3
/usr/bin/sqlite3
macbook-pro:sqlite-3.7.3 scott$ sqlite3 test.db
SQLite version 3.6.12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create virtual table vt using fts3();
SQL error: no such module: fts3
sqlite installation dump:
macbook-pro:sqlite-3.7.3 scott$ sudo make install
test -z "/usr/local/lib" || /Users/scott/sqlite-3.7.3/install-sh -d "/usr/local/lib"
/bin/sh ./libtool --mode=install /usr/bin/install -c 'libsqlite3.la' '/usr/local/lib/libsqlite3.la'
/usr/bin/install -c .libs/libsqlite3.0.8.6.dylib /usr/local/lib/libsqlite3.0.8.6.dylib
(cd /usr/local/lib && { ln -s -f libsqlite3.0.8.6.dylib libsqlite3.0.dylib || { rm -f libsqlite3.0.dylib && ln -s libsqlite3.0.8.6.dylib libsqlite3.0.dylib; }; })
(cd /usr/local/lib && { ln -s -f libsqlite3.0.8.6.dylib libsqlite3.dylib || { rm -f libsqlite3.dylib && ln -s libsqlite3.0.8.6.dylib libsqlite3.dylib; }; })
/usr/bin/install -c .libs/libsqlite3.lai /usr/local/lib/libsqlite3.la
/usr/bin/install -c .libs/libsqlite3.a /usr/local/lib/libsqlite3.a
chmod 644 /usr/local/lib/libsqlite3.a
ranlib /usr/local/lib/libsqlite3.a
Libraries have been installed in:
/usr/local/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the -LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to theDYLD_LIBRARY_PATH' environment variable
during execution
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
test -z "/usr/local/bin" || /Users/scott/sqlite-3.7.3/install-sh -d "/usr/local/bin"
/bin/sh ./libtool --mode=install /usr/bin/install -c 'sqlite3' '/usr/local/bin/sqlite3'
/usr/bin/install -c .libs/sqlite3 /usr/local/bin/sqlite3
test -z "/usr/local/include" || /Users/scott/sqlite-3.7.3/install-sh -d "/usr/local/include"
/usr/bin/install -c -m 644 'sqlite3.h' '/usr/local/include/sqlite3.h'
/usr/bin/install -c -m 644 'sqlite3ext.h' '/usr/local/include/sqlite3ext.h'
test -z "/usr/local/share/man/man1" || /Users/scott/sqlite-3.7.3/install-sh -d "/usr/local/share/man/man1"
/usr/bin/install -c -m 644 './sqlite3.1' '/usr/local/share/man/man1/sqlite3.1'
test -z "/usr/local/lib/pkgconfig" || /Users/scott/sqlite-3.7.3/install-sh -d "/usr/local/lib/pkgconfig"
/usr/bin/install -c -m 644 'sqlite3.pc' '/usr/local/lib/pkgconfig/sqlite3.pc'scott
Where did you install the sqlite3 command and what is your path? Type
echo $PATH
and check whether the dir where the command is located precedes /usr/bin, where SQLite 3.6 is installed. If it doesn't, change your path in .bashrc.
Related
I was tried install React Native following this guide https://kadikraman.github.io/react-native-v2/setup-rn in which redirected me to this guide https://reactnative.dev/docs/environment-setup and for a some reason i had to use the command pod install but this command show the follow error, I don't understand why do occur:
set -e
#!/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
set -e
PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}"
CURRENT_ARCH="${CURRENT_ARCH}"
if [ -z "$CURRENT_ARCH" ] || [ "$CURRENT_ARCH" == "undefined_arch" ]; then
# Xcode 10 beta sets CURRENT_ARCH to "undefined_arch", this leads to incorrect linker arg.
# it's better to rely on platform name as fallback because architecture differs between simulator and device
if [[ "$PLATFORM_NAME" == *"simulator"* ]]; then
CURRENT_ARCH="x86_64"
else
CURRENT_ARCH="armv7"
fi
fi
export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"
export CXX="$CC"
# Remove automake symlink if it exists
if [ -h "test-driver" ]; then
rm test-driver
fi
./configure --host arm-apple-darwin
# Fix build for tvOS
cat << EOF >> src/config.h
/* Add in so we have Apple Target Conditionals */
#ifdef __APPLE__
#include <TargetConditionals.h>
#include <Availability.h>
#endif
/* Special configuration for AppleTVOS */
#if TARGET_OS_TV
#undef HAVE_SYSCALL_H
#undef HAVE_SYS_SYSCALL_H
#undef OS_MACOSX
#endif
/* Special configuration for ucontext */
#undef HAVE_UCONTEXT_H
#undef PC_FROM_UCONTEXT
#if defined(__x86_64__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip
#elif defined(__i386__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip
#endif
EOF
# Prepare exported header include
EXPORTED_INCLUDE_DIR="exported/glog"
mkdir -p exported/glog
cp -f src/glog/log_severity.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/"
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-apple-darwin-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... ./install-sh -c -d
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 arm-apple-darwin-gcc... /Library/Developer/CommandLineTools/usr/bin/cc -arch armv7 -isysroot
checking whether the C compiler works... no
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'
/Users/cristianpuentes/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing: Unknown `--is-lightweight' option
Try `/Users/cristianpuentes/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
configure: error: in `/Users/cristianpuentes/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6':
configure: error: C compiler cannot create executables
See `config.log' for more details```
Try to run
sudo xcode-select --switch /Applications/Xcode.app
Then run pod install again
On X86, I need to build a gcc cross compiler for arm64 with things as below:
binutils-2.26.1.tar.gz gcc-5.4.0.tar.gz glibc-2.23.tar.gz gmp-6.1.2.tar.bz2 mpc-1.1.0.tar.gz mpfr-4.0.1.tar.gz
I've put all of them into a directory named download.
After reading this link: http://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/, I wrote a bash script as below to build the gcc cross compiler:
#!/bin/bash
sudo rm -rf build sources /opt/aarch64-linux-gnu-5.4.0
mkdir build
cp -r download sources
cd sources
for f in *.tar*; do tar xf $f; done
cd gcc-5.4.0/
ln -s ../mpfr-4.0.1 mpfr
ln -s ../mpc-1.1.0 mpc
ln -s ../gmp-6.1.2 gmp
cd ../..
export PREFIX=/opt/aarch64-linux-gnu-5.4.0
#export PATH=$PREFIX/bin:$PATH
export SYSROOT=$PREFIX/sysroot
export TARGET=aarch64-linux-gnu
cd build
mkdir binutils && cd binutils
../../sources/binutils-2.26.1/configure --prefix=/$PREFIX --target=$TARGET
make -j32
make install
cd ..
cd /home/me/projet/kernel/linux-4.1
make ARCH=arm64 INSTALL_HDR_PATH=$PREFIX/aarch64-linux-gnu/include headers_install
cd -
mkdir gcc && cd gcc
../../sources/gcc-5.4.0/configure --prefix=$PREFIX --target=$TARGET --enable-languages=c,c++ --without-headers
make -j32 all-gcc
make install-gcc
cd ..
mkdir -p glibc && cd glibc
../../sources/glibc-2.23/configure --prefix= --build=$MACHTYPE --host=$TARGET --target=$TARGET --with-headers=$PREFIX/aarch64-linux-gnu/include libc_cv_forced_unwind=yes
make prefix=$PREFIX/aarch64-linux-gnu install-bootstrap-headers=yes install-headers
make -j32 csu/subdir_lib
install csu/crt1.o csu/crti.o csu/crtn.o $PREFIX/aarch64-linux-gnu/lib
/opt/aarch64-linux-gnu-5.4.0/bin/aarch64-linux-gnu-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $PREFIX/aarch64-linux-gnu/lib/libc.so
touch $PREFIX/aarch64-linux-gnu/include/gnu/stubs.h
cd ..
cd gcc
make -j32 all-target-libgcc
make install-target-libgcc
cd ..
cd glibc
make -j32
make prefix=$PREFIX/aarch64-linux-gnu install
cd ..
cd gcc
make -j32
make install
cd ..
However, when I executed this bash script, I got two errors:
cc1: error: no include path in which to search for stdc-predef.h
In file included from ../../../../sources/gcc-5.4.0/libgcc/gthr.h:148:0,
from ../../../../sources/gcc-5.4.0/libgcc/libgcov-interface.c:27:
./gthr-default.h:35:21: fatal error: pthread.h: No such file or directory
I would like to use library fgsl, that depends on gsl. I have problem indicating where gsl is installed while configuring fgsl. I want to use the static version of these libraries. I can not use gsl library from Linux packages, these versions are not recent enough.
First I download, configure, compile and install gsl locally, i.e. using the --prefix option. (Instructions are presented below)
Then I download fgsl, configure it. This last operation fails because I do not succeed indicating where is gsl. I have tried to use gsl_LIBS unsuccessfully.
wget http://ftp.igh.cnrs.fr/pub/gnu/gsl/gsl-2.3.tar.gz -O gsl.tar.gz
mkdir -p gsl_build && cd gsl_build
tar -xzf ../gsl.tar.gz --strip 1
autoreconf -fi
./configure CFLAGS="-Wall" --prefix `pwd`/../gsl
make
make install
cd ..
rm -rf gsl_build
Here are the commands I run to install fgsl
wget https://github.com/reinh-bader/fgsl/archive/v1.2.0.tar.gz -O fgsl.tar.gz
mkdir -p fgsl_build
cd fgsl_build
tar -xzf ../fgsl.tar.gz --strip 1
autoreconf -fi
export gsl_LIBS=`pwd`/../gsl/lib
./configure CFLAGS="-Wall" FCFLAGS="-Wall" --prefix `pwd`/../fgsl --libdir=`pwd`/../gsl/lib --includedir=`pwd`/../gsl/include
make
make check
make install
cd ..
rm -rf fgsl_build
I try to do this for the open source project AcousticBEM. Here is the log presenting the problem.
Well, here are my updated scripts to install gsl and fgsl locally. I have used PKG_CONFIG_PATH to tell fgsl where gsl is installed. I end up with a directory named gsl containing gsl libraries and fgsl libraries.
First a shell script to install gsl
export gsl_INSTALL_DIR=`pwd`/gsl
[ -f ./gsl.tar.gz ] && echo "No need to download gsl" || wget http://ftp.igh.cnrs.fr/pub/gnu/gsl/gsl-2.3.tar.gz -O gsl.tar.gz
mkdir -p gsl_build
cd gsl_build
tar -xzf ../gsl.tar.gz --strip 1
autoreconf -fi
./configure CFLAGS="-Wall" --prefix=${gsl_INSTALL_DIR}
make
make install
cd ..
rm -rf gsl_build
Second, a script to install fgsl locally using the newly install gsl
export PKG_CONFIG_PATH=`pwd`/gsl/lib/pkgconfig
export gsl_LIBS=`pwd`/gsl
[ -f ./fgsl.tar.gz ] && echo "No need to download fgsl" || wget https://github.com/reinh-bader/fgsl/archive/v1.2.0.tar.gz -O fgsl.tar.gz
mkdir -p fgsl_build
cd fgsl_build
tar -xzf ../fgsl.tar.gz --strip 1
autoreconf -fi
./configure CFLAGS="-Wall" FCFLAGS="-Wall" --prefix=${gsl_LIBS}
make
make check
make install
cd ..
rm -rf fgsl_build
Problem overview
I am trying to learn how to build a cross-compiler, specifically a version of GNU gcc 4.7.2 on a 64-bit Intel OS X host that targets i386-apple-darwin (32-bit Intel). However, I keep getting stuck on the same error:
...
checking for i386-apple-darwin-gcc... /Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/xgcc -B/Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/bin/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/lib/ -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/include -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/sys-include
checking for suffix of object files... configure: error: in `/Users/alexpreynolds/Developer/third-party/build-gcc/i386-apple-darwin/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[1]: *** [configure-target-libgcc] Error 1
make: *** [all] Error 2
Build process
I first build a version of GNU binutils which targets i386-apple-darwin, which is accessible to the GNU gcc build folder:
$ cd third-party
$ wget http://ftp.gnu.org/gnu/binutils/binutils-2.23.2.tar.bz2
$ tar xjvf binutils-2.23.2.tar.bz2
$ mkdir i386-apple-darwin
$ mkdir build-binutils && cd build-binutils
$ ../binutils-2.23.2/configure --target=i386-apple-darwin --prefix="/Users/alexpreynolds/Developer/third-party/i386-apple-gcc"
$ make all && make install
...
Then I try to build a targeted version of gcc as follows:
$ cd ..
$ pwd
/Users/alexpreynolds/Developer/third-party
$ wget http://ftp.gnu.org/pub/gnu/gcc/gcc-4.7.2/gcc-4.7.2.tar.bz2
$ tar xvjf gcc-4.7.2.tar.bz2
$ cd gcc-4.7.2
$ ./contrib/download_prerequisites
... /* this grabs GMP, MPC and MPFR dependencies */
$ cd ..
$ mkdir build-gcc && cd build-gcc
$ ../gcc-4.7.2/configure --target=i386-apple-darwin --prefix="/Users/alexpreynolds/Developer/Bedops/bedops/third-party/i386-apple-gcc"
$ make
...
After about 30 minutes of compiling stuff, it gets stuck with the error message shown above.
Error details
To track down the source of the error, here is a snippet of build-gcc/i386-apple-darwin/libgcc/config.log:
configure:3344: /Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/xgcc -B/Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/bin/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/lib/ -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/include -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/sys-include -V >&5
xgcc: error: unrecognized command line option '-V'
xgcc: fatal error: no input files
compilation terminated.
configure:3355: $? = 1
configure:3344: /Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/xgcc -B/Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/bin/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/lib/ -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/include -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/sys-include -qversion >&5
xgcc: error: unrecognized command line option '-qversion'
xgcc: fatal error: no input files
compilation terminated.
configure:3355: $? = 1
configure:3371: /Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/xgcc -B/Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/bin/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/lib/ -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/include -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/sys-include -o conftest -g -O2 conftest.c >&5
Assembler messages:
Fatal error: invalid listing option `r'
configure:3374: $? = 1
configure:3562: checking for suffix of object files
configure:3584: /Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/xgcc -B/Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/bin/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/lib/ -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/include -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/sys-include -c -g -O2 conftest.c >&5
Assembler messages:
Fatal error: invalid listing option `r'
configure:3588: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL "http://www.gnu.org/software/libgcc/"
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:3602: error: in `/Users/alexpreynolds/Developer/third-party/build-gcc/i386-apple-darwin/libgcc':
configure:3605: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
The compiler I'm bootstrapping from
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin12/4.7.2/lto-wrapper
Target: x86_64-apple-darwin12
Configured with: ../gcc-4.7.2/configure --prefix=/opt/local --build=x86_64-apple-darwin12 --enable-languages=c,c++,objc,obj-c++,lto,fortran,java --libdir=/opt/local/lib/gcc47 --includedir=/opt/local/include/gcc47 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.7 --with-libiconv-prefix=/opt/local --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.7 --with-gxx-include-dir=/opt/local/include/gcc47/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-ppl=/opt/local --with-cloog=/opt/local --enable-cloog-backend=isl --disable-cloog-version-check --enable-stage1-checking --enable-lto --enable-libstdcxx-time --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --disable-ppl-version-check --with-pkgversion='MacPorts gcc47 4.7.2_2+universal'
Thread model: posix
gcc version 4.7.2 (MacPorts gcc47 4.7.2_2+universal)
Question
Is there a step I missed in setting up the build environment of coreutils or gcc such that this error results?
What else can I troubleshoot in trying to resolve this error? My Google searches on this error message are not bearing much fruit.
Changes
I changed the build script as follows:
#!/bin/bash -x
WORK_DIR=$PWD
INSTALL_DIR=$WORK_DIR/gcc-4.7.2-darwin
MIN_OSX_VERSION=10.5
if [ -d "$INSTALL_DIR" ]; then
echo "Directory $INSTALL_DIR already exists";
exit 1
fi
BINUTILS=binutils-2.23.2
TARBALL_BINUTILS=$BINUTILS.tar.bz2
URL_BINUTILS=http://ftp.gnu.org/gnu/binutils/$TARBALL_BINUTILS
SOURCE_BINUTILS_DIR=$WORK_DIR/$BINUTILS
BUILD_BINUTILS_DIR=$WORK_DIR/build-$BINUTILS
GCC=gcc-4.7.2
TARBALL_GCC=$GCC.tar.bz2
URL_GCC=http://ftp.gnu.org/pub/gnu/gcc/$GCC/$TARBALL_GCC
SOURCE_GCC_DIR=$WORK_DIR/$GCC
BUILD_GCC_DIR=$WORK_DIR/build-$GCC
curl -O $URL_BINUTILS
mkdir -p $SOURCE_BINUTILS_DIR
tar -xjvf $TARBALL_BINUTILS
rm $TARBALL_BINUTILS
mkdir -p $BUILD_BINUTILS_DIR
cd $BUILD_BINUTILS_DIR
$SOURCE_BINUTILS_DIR/configure --prefix=$INSTALL_DIR
make -j $(sysctl -n hw.availcpu) all CFLAGS='-Wno-error' && make install
find $INSTALL_DIR -name '*strip*' -delete
cd $WORK_DIR
curl -O $URL_GCC
mkdir -p $SOURCE_GCC_DIR
tar -xvjf $TARBALL_GCC
rm $TARBALL_GCC
cd $SOURCE_GCC_DIR
sed -i '' -e 's/wget/curl -O/g' $SOURCE_GCC_DIR/contrib/download_prerequisites
$SOURCE_GCC_DIR/contrib/download_prerequisites
cd $WORK_DIR
mkdir -p $BUILD_GCC_DIR
cd $BUILD_GCC_DIR
$SOURCE_GCC_DIR/configure --prefix=$INSTALL_DIR --enable-languages=c,c++
make -j $(sysctl -n hw.availcpu) CFLAGS="-mmacosx-version-min=$MIN_OSX_VERSION" && make install
find $INSTALL_DIR -name '*.a' -print0 | xargs -0 -n1 ranlib
rm -Rf $BUILD_GCC_DIR
rm -Rf $BUILD_BINUTILS_DIR
rm -Rf $SOURCE_GCC_DIR
rm -Rf $SOURCE_BINUTILS_DIR
The ranlib step was necessary due to numerous errors during the process of building a library.
To build an i386 binary, I had to do the following with my Makefile:
ARCH = i386
...
GCCDIR = ${PARTY3}/gcc-4.7.2-darwin
GCCBINDIR = ${GCCDIR}/bin
GCCLIBDIR = ${GCCDIR}/lib
GCCINCDIR = ${GCCDIR}/include
...
LIBCPP = libgcc_eh.a
LIBCXX = libstdc++.a
...
INCLUDES = -I${GCCINCDIR} ...
...
CC = ${GCCBINDIR}/gcc
CXX = ${GCCBINDIR}/g++
...
GCCCPPLIBPATH = ${GCCLIBDIR}/gcc/x86_64-apple-darwin12.3.0/4.7.2/${ARCH}/${LIBCPP}
GCCCXXLIBPATH = ${GCCLIBDIR}/${ARCH}/${LIBCXX}
...
FLAGS = ${SFLAGS} ${NONSTATICFLAGS} ${OBJS} -L${GCCLIBDIR} ...
...
run: dependencies
mkdir -p ${BIN} && ${CXX} -o ${BIN}/${PROG}_${ARCH} ${FLAGS} -static-libgcc -mmacosx-version-min=${MIN_OSX_VERSION} -arch ${ARCH} ... ${GCCCPPLIBPATH} ${GCCCXXLIBPATH} ${SOURCE1}
Summary of Makefile changes:
I had to add the -static-libgcc flag and leave out -static-libstdc++, which had no effect (except to cause the build to fail, until I ran ranlib on the static libraries, which fixed the build failure but had no effect on -static-libstdc++).
I added ${GCCCPPLIBPATH} and ${GCCCXXLIBPATH} to the run target, which each point to the static C anc C++ libraries libgcc_eh.a and libstdc++.a, respectively.
This allowed me to compile a working i386 (32-bit) binary, but the same GCC installation failed to build a working x86_64 (64-bit) binary.
After thinking about this a little, it occurs to me that by far the easiest solution would be to compile GCC for x86_64, and then to just pass -m32 when you wish to build for i386. Is that not sufficient for your needs for some reason? Building in this manner is dramatically simpler, and doesn't require any of the madness described below. Doing the following sequence of events results in a working compiler that will spit out i386 binaries when requested:
WORK_DIR=$PWD
INSTALL_DIR=$WORK_DIR/install
curl -O http://ftp.gnu.org/gnu/binutils/binutils-2.23.2.tar.bz2
tar xjvf binutils-2.23.2.tar.bz2
mkdir build-binutils && cd build-binutils
../binutils-2.23.2/configure --prefix=$INSTALL_DIR
make -j $(sysctl -n hw.availcpu) all CFLAGS='-Wno-error' && make install
find $INSTALL_DIR -name '*strip*' -delete
cd $WORK_DIR
curl -O http://ftp.gnu.org/pub/gnu/gcc/gcc-4.7.2/gcc-4.7.2.tar.bz2
tar xvjf gcc-4.7.2.tar.bz2
cd gcc-4.7.2
sed -i '' -e 's/wget/curl -O/g' ./contrib/download_prerequisites
./contrib/download_prerequisites
cd ..
mkdir build-gcc && cd build-gcc
../gcc-4.7.2/configure --prefix=$INSTALL_DIR --enable-languages=c,c++
make -j $(sysctl -n hw.availcpu) && make install
Once this completes you can see it in action like so:
mrowe#falcon:~/tmp$ cat > test.cpp
#include <iostream>
int main(int argc, char **argv) {
std::cerr << "Built with GCC 4.7" << std::endl;
return 0;
}
^D
mrowe#falcon:~/tmp$ ./install/bin/g++ -o test test.cpp
mrowe#falcon:~/tmp$ file test
test: Mach-O 64-bit executable x86_64
mrowe#falcon:~/tmp$ ./install/bin/g++ -m32 -static-libgcc -static-libstdc++ -o test test.cpp
mrowe#falcon:~/tmp$ file test
test: Mach-O executable i386
mrowe#falcon:~/tmp$ otool -L ./test
./test:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1192.0.0)
mrowe#falcon:~/tmp$ ./test
Built with GCC 4.7
mrowe#falcon:~/tmp$
If you see warnings like:
ignoring file …/4.7.2/i386/libgcc.a, file was built for archive which is not the architecture being linked (i386)
You can fix them by running ranlib on the static libraries:
find $INSTALL_DIR -name '*.a' -print0 | xargs -0 -n1 ranlib
Below is my attempt at helping you along the path you were attempting to follow. I don't think it's the ideal approach and it is fraught with problems.
The error you reported seeing is due to your GCC build trying to use the GNU assembler from binutils when the generated assembly is intended to be assembled with the GNU assembler from Apple's cctools. The dialect of assembly that is supported differs between the two as Apple's assembler diverged from the upstream GNU assembler many years ago.
All of the instructions I was able to find for building cctools were out of date so I experimented until I got something working. I did something close to the following:
curl -O http://opensource.apple.com/tarballs/cctools/cctools-829.tar.gz
tar xvzf cctools-829.tar.gz
cd cctools-829
You'll then need to patch two files in order to build without a dependency on LLVM:
diff -ru cctools-829/libstuff/lto.c cctools-829.modified/libstuff/lto.c
--- cctools-829/libstuff/lto.c 1969-12-31 16:00:00.000000000 -0800
+++ cctools-829.modified/libstuff/lto.c 2013-04-05 03:18:34.000000000 -0700
## -376,4 +376,18 ##
lto_dispose(mod);
}
+#else
+
+#include <stdlib.h>
+
+__private_extern__
+int
+is_llvm_bitcode(
+ struct ofile *ofile,
+ char *addr,
+ size_t size)
+{
+ return 0;
+}
+
#endif /* LTO_SUPPORT */
diff -ru cctools-829/misc/libtool.c cctools-829.modified/misc/libtool.c
--- cctools-829/misc/libtool.c 1969-12-31 16:00:00.000000000 -0800
+++ cctools-829.modified/misc/libtool.c 2013-04-05 03:20:21.000000000 -0700
## -1369,8 +1369,11 ##
}
}
}
- else if(ofiles[i].arch_type == OFILE_Mach_O ||
- ofiles[i].arch_type == OFILE_LLVM_BITCODE){
+ else if(ofiles[i].arch_type == OFILE_Mach_O
+#ifdef LTO_SUPPORT
+ || ofiles[i].arch_type == OFILE_LLVM_BITCODE
+#endif
+ ){
if(cmd_flags.ranlib == TRUE){
error("for architecture: %s file: %s is not an "
"archive (no processing done on this file)",
And then build:
make install USE_DEPENDENCY_FILE=NO BUILD_DYLIBS=NO LTO= TRIE= DSTROOT=../build-cctools
And install the necessary parts of by hand:
cd ..
cp build-cctools/usr/bin/as i386-apple-gcc/bin/i386-apple-darwin-as
cp build-cctools/usr/bin/as i386-apple-gcc/i386-apple-darwin/bin/as
cp build-cctools/usr/bin/lipo i386-apple-gcc/bin/i386-apple-darwin-lipo
cp build-cctools/usr/bin/lipo i386-apple-gcc/i386-apple-darwin/bin/lipo
cp build-cctools/usr/bin/strip i386-apple-gcc/bin/i386-apple-darwin-strip
cp build-cctools/usr/bin/strip i386-apple-gcc/i386-apple-darwin/bin/strip
If we then attempt to build GCC once more we'll discover that the build process is upset because our freshly-built assembler is unable to target x86_64. Since that doesn't seem relevant to what you're trying to achieve you can add the --disable-multilib argument to GCC's configure script to prevent it from trying that.
At this point I ran in to errors while attempting to build libgcc. These errors are because a suitable linker cannot be found, so I guess that now you'd need to download and build ld64 too.
And it's at this point that I've run out of time to make it any further. Good luck!
I build gcc 4.6.1 and when I run ldconfig it comes back with this result:
ldconfig: /usr/local/mpc/lib/libmpc.so.2 is not a symbolic link
ldconfig: /usr/local/gmp/lib/libgmp.so.3 is not a symbolic link
ldconfig: /usr/local/mpfr/lib/libmpfr.so.1 is not a symbolic link
Here is how I built gcc using the libraries:
tar jxf gmp-4.3.2.tar.bz2
cd gmp-4.3.2/
./configure --prefix=/usr/local/gmp
make
make install
cd ..
tar jxf mpfr-2.4.2.tar.bz2
cd mpfr-2.4.2/
./configure --prefix=/usr/local/mpfr --with-gmp=/usr/local/gmp
make
make install
cd ..
tar xzf mpc-0.8.1.tar.gz
cd mpc-0.8.1
./configure --prefix=/usr/local/mpc --with-mpfr=/usr/local/mpfr --with-gmp=/usr/local/gmp
make
make install
cd ..
tar jxf gcc-4.6.1.tar.bz2
cd gcc-4.6.1
./configure --prefix=/usr/local/gcc --enable-threads=posix --disable-checking -disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr/ --with-mpc=/usr/local/mpc/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/
make
make install
cp gcc.4.6.1.conf /etc/ld.so.conf.d/gcc.4.6.1.conf
ldconfig
mv /usr/bin/gcc /usr/bin/gcc_old
mv /usr/bin/g++ /usr/bin/g++_old
ln -s -f /usr/local/gcc/bin/gcc /usr/bin/gcc
ln -s -f /usr/local/gcc/bin/g++ /usr/bin/g++
cp /usr/local/gcc/lib64/libstdc++.so.6.0.16 /usr/lib64/.
mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bak
ln -s -f /usr/lib64/libstdc++.so.6.0.16 /usr/lib64/libstdc++.so.6
Please say I don't need to rebuild gcc! Is this symbolic link problem something that can really affect a program? Or will it not make any difference, it does pop up every now and again, for instance when I was yum install certain things as well. Thanks in advance.
I fixed this problem by installing gmp, mpc, and mpfr with the ./contrib/download_prerequisites command, which downloads the required files and sets up symbolic links during the install process.
My whole build was:
tar -xzvf gcc-4.6.2.tar.gz
cd gcc-4.6.2
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.6.2/configure --prefix=/opt/gcc-4.6.2
make
make install
ldconfig
mv /usr/bin/gcc /usr/bin/gcc_old
mv /usr/bin/g++ /usr/bin/g++_old
ln -s -f /usr/local/gcc/bin/gcc /usr/bin/gcc
ln -s -f /usr/local/gcc/bin/g++ /usr/bin/g++
cp /usr/local/gcc/lib64/libstdc++.so.6.0.16 /usr/lib64/.
mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bak
ln -s -f /usr/lib64/libstdc++.so.6.0.16 /usr/lib64/libstdc++.so.6
export CC=gcc
export CXX=g++
I don't know how to fully link the CC and CXX variables to the new gcc and g++, but it works!