Reputation: 273
i am trying to use free type in android native and i am trying to follow this tutorial: http://en.wikibooks.org/wiki/OpenGL_Programming/Installation/Android#FreeType which seems to be the standard tutorial that everyone links to.
my problem now is that i have never cross compiled anything before and when i try to prepare the cross-compiler with: make-standalone-toolchain.sh ... in cygwin (im on windows 7) i get:
-bash: make-standalone-toolchain.sh: command not found
even though it definitely is there. what am i missing? or is that not to be done in cygwin at all but somewhere else? this standard tutorial is not detailed enough for me, can anyone give me a more detailed explanation on where i have to give those commands?
Upvotes: 1
Views: 1676
Reputation: 5310
on macos platform:
build64
#!/bin/bash
export NDK= /Users/xxxxx/Library/Android/sdk/ndk/21.3.6528147 # set your path
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/darwin-x86_64
SYSROOT=$TOOLCHAIN/sysroot
export API=21
export TARGET=aarch64-linux-android
CPU=arm64-v8a
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
# old
#export CFLAGS="-g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -O3 -DNDEBUG -fPIC --target=aarch64-none-linux-android21 --gcc-toolchain=$TOOLCHAIN "
# with -g
export CFLAGS="-g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -O3 -DNDEBUG -fPIC --target=$TARGET$API --gcc-toolchain=$TOOLCHAIN "
# without -g
#export CFLAGS="-DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -O3 -DNDEBUG -fPIC --target=$TARGET$API --gcc-toolchain=$TOOLCHAIN "
export AR=$TOOLCHAIN/bin/llvm-ar
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
PREFIX=$(pwd)/android/$CPU
function build
{
./configure \
--host=$TARGET \
--prefix=$PREFIX \
--disable-shared \
--enable-static \
--without-brotli \
--with-zlib=no \
--with-bzip2=no \
--with-png=no \
--with-harfbuzz=no \
--with-sysroot=$SYSROOT \
make -j12 VERBOSE=1
make install
}
build
build32
#!/bin/bash
export NDK=/Users/xxxxx/Library/Android/sdk/ndk/21.3.6528147 # set your path
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/darwin-x86_64
SYSROOT=$TOOLCHAIN/sysroot
export API=21
export TARGET=armv7a-linux-androideabi
CPU=armeabi-v7a
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
# old
#export CFLAGS="-g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -O3 -DNDEBUG -fPIC --target=aarch64-none-linux-android21 --gcc-toolchain=$TOOLCHAIN "
# with -g
export CFLAGS="-g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -O3 -DNDEBUG -fPIC --target=$TARGET$API --gcc-toolchain=$TOOLCHAIN "
# without -g
#export CFLAGS="-DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -O3 -DNDEBUG -fPIC --target=$TARGET$API --gcc-toolchain=$TOOLCHAIN "
export AR=$TOOLCHAIN/bin/llvm-ar
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
PREFIX=$(pwd)/android/$CPU
function build
{
./configure \
--host=$TARGET \
--prefix=$PREFIX \
--disable-shared \
--enable-static \
--without-brotli \
--with-zlib=no \
--with-bzip2=no \
--with-png=no \
--with-harfbuzz=no \
--with-sysroot=$SYSROOT \
make -j12 VERBOSE=1
make install
}
build
Upvotes: 0
Reputation: 309
I have managed to compile and use freetype 2.7.1 library in ndk with CMake:
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# freetype 2.7.1
add_definitions(-DFT2_BUILD_LIBRARY)
set(FTDIR "src/main/cpp/freetype")
include_directories(${FTDIR}/include)
set(FTSRC
${FTDIR}/src/autofit/autofit.c
${FTDIR}/src/base/ftbase.c
${FTDIR}/src/base/ftbbox.c
${FTDIR}/src/base/ftbdf.c
${FTDIR}/src/base/ftbitmap.c
${FTDIR}/src/base/ftcid.c
${FTDIR}/src/base/ftfntfmt.c
${FTDIR}/src/base/ftfstype.c
${FTDIR}/src/base/ftgasp.c
${FTDIR}/src/base/ftglyph.c
${FTDIR}/src/base/ftgxval.c
${FTDIR}/src/base/ftinit.c
${FTDIR}/src/base/ftlcdfil.c
${FTDIR}/src/base/ftmm.c
${FTDIR}/src/base/ftotval.c
${FTDIR}/src/base/ftpatent.c
${FTDIR}/src/base/ftpfr.c
${FTDIR}/src/base/ftstroke.c
${FTDIR}/src/base/ftsynth.c
${FTDIR}/src/base/ftsystem.c
${FTDIR}/src/base/fttype1.c
${FTDIR}/src/base/ftwinfnt.c
${FTDIR}/src/bdf/bdf.c
${FTDIR}/src/bzip2/ftbzip2.c
${FTDIR}/src/cache/ftcache.c
${FTDIR}/src/cff/cff.c
${FTDIR}/src/cid/type1cid.c
${FTDIR}/src/gzip/ftgzip.c
${FTDIR}/src/lzw/ftlzw.c
${FTDIR}/src/pcf/pcf.c
${FTDIR}/src/pfr/pfr.c
${FTDIR}/src/psaux/psaux.c
${FTDIR}/src/pshinter/pshinter.c
${FTDIR}/src/psnames/psnames.c
${FTDIR}/src/raster/raster.c
${FTDIR}/src/sfnt/sfnt.c
${FTDIR}/src/smooth/smooth.c
${FTDIR}/src/truetype/truetype.c
${FTDIR}/src/type1/type1.c
${FTDIR}/src/type42/type42.c
${FTDIR}/src/winfonts/winfnt.c
${FTDIR}/src/base/ftdebug.c
${FTDIR}/include/ft2build.h
${FTDIR}/include/freetype/config/ftconfig.h
${FTDIR}/include/freetype/config/ftheader.h
${FTDIR}/include/freetype/config/ftmodule.h
${FTDIR}/include/freetype/config/ftoption.h
${FTDIR}/include/freetype/config/ftstdlib.h
)
add_library( freetype SHARED ${FTSRC} )
and then you link it to your ndk library : e.g.
add_library(native-lib SHARED src/main/cpp/native-lib.cpp)
target_link_libraries(native-lib freetype)
Upvotes: 2
Reputation: 3562
you can't just run .sh script in windows environment... You have to use sh.exe utility to strat your script... somethiong like:
path_to_cygwin\bin\sh make-standalone-toolchain.sh [options]
Upvotes: 0