This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
pass in -fshort_wchar when build newlib
- From: "Weiyang Zhou" <weiyangz at codecorp dot com>
- To: <newlib at sourceware dot org>
- Date: Thu, 23 Feb 2006 10:02:08 -0700
- Subject: pass in -fshort_wchar when build newlib
I have built a cross compile toolchain for mips-elf with binutils-2.16.1,
gcc-4.0.2, newlib-1.14.0 and gdb-6.4. It works fine and I can build the
application for the target system on my Windows machine.
Now we have some third party code uses "unsigned short" to store Unicode
character. But the default size of wchar_t in GCC is 4 bytes. I tried to use
-fshort_wchar flag when build the application, but it crashes in wcslen on
startup. I think it is because the standard C library was built with
-fshort_wchar flag. Does anyone know how can pass that flag when I build
newlib?
Here is the scripts I used to build the toolchain.
INSTALL=/usr/local/comp
ARCHIVE=.
TARGET=mips-elf
BINUTILS=binutils-2.16.1
GCC=gcc-4.0.2
NEWLIB=newlib-1.14.0
GDB=gdb-6.4
PREFIX=${INSTALL}/${TARGET}/${GCC}
CFG="--target=${TARGET} --with-gnu-as --with-gnu-ld --with-newlib
--prefix=${PREFIX} --enable-languages=c,c++ --enable-gofast"
if [ ! -d ${BINUTILS} ]; then
tar xvzf ${ARCHIVE}/${BINUTILS}.tar.gz
fi
if [ ! -d ${GCC} ]; then
tar xvzf ${ARCHIVE}/${GCC}.tar.gz
fi
if [ ! -d ${NEWLIB} ]; then
tar xvzf ${ARCHIVE}/${NEWLIB}.tar.gz
fi
if [ ! -d ${GDB} ]; then
tar xvzf ${ARCHIVE}/${GDB}.tar.gz
fi
# binutils
mkdir ob ; cd ob
../${BINUTILS}/configure ${CFG}
make
make install
cd ..
# update PATH
PATH=${PREFIX}/bin:$PATH ; export PATH
# gcc/g++ - pass one
mkdir og ; cd og
../${GCC}/configure ${CFG}
make
make install
cd ..
# newlib
mkdir on ; cd on
../${NEWLIB}/configure ${CFG}
make
make install
cd ..
# gcc/g++ - pass two
rm -fr og
mkdir og ; cd og
../${GCC}/configure ${CFG}
make
make install
cd ..
# insight or gdb
mkdir od ; cd od
../${GDB}/configure ${CFG}
make
make install
cd ..
Thank you,
Weiyang Zhou