问题
I am trying to build GObject-Introspection on Ubuntu 14.04 using Mingw-w64. I am currently running 64bit Linux and trying to build for a 32bit Windows target.
My first attempt used Python 2.7.8 installed in Wine, however, this did not work because Python's path separator was set to '\' (well '\') instead of Linux's '/'. Due to this I tried using the Python 2.7 in Ubuntu.
Using the Python provided by Ubuntu doesn't get past the configuration step. Config.log shows the following:
In file included from /usr/include/python2.7/Python.h:8:0,
from conftest.c:40:
/usr/include/python2.7/pyconfig.h:78:3: error: #error unknown multiarch locatio#
# error unknown multiarch location for pyconfig.h
^
In file included from /usr/include/python2.7/pyport.h:4:0,
from /usr/include/python2.7/Python.h:58,
from conftest.c:40:
/usr/include/python2.7/pyconfig.h:78:3: error: #error unknown multiarch locatio#
# error unknown multiarch location for pyconfig.h
^
In file included from /usr/include/python2.7/Python.h:58:0,
from conftest.c:40:
/usr/include/python2.7/pyport.h:241:9: error: #error "This platform's pyconfig.#
# error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T"
^
In file included from /usr/include/python2.7/pymath.h:4:0,
from /usr/include/python2.7/Python.h:77,
from conftest.c:40:
/usr/include/python2.7/pyconfig.h:78:3: error: #error unknown multiarch locatio#
# error unknown multiarch location for pyconfig.h
^
I understand that there are some differences between the platforms that pyconfig.h defines. Should I be gathering these files into seperate directories like the OS seems to be doing (/usr/include/x86_64-linux-gnu/python2.7/pyconfig.h)? What is the correct setup for Python so that I can cross-compile GObject-Introspection?
Environment setup
export PREFIX=$CROSS_DIR/windows
export INSTALL_PREFIX=$PREFIX
export TOOLCHAIN_FILE=$PREFIX/toolchain_windows.cmake
export PLATFORM=WINDOWS
export HOST=i686-w64-mingw32
export BUILD=x86_64-linux-gnu
export COMPILER_INCLUDE_DIR=/usr/$HOST/include
export COMPILER_LIB_DIR=/usr/$HOST/lib
export MINGW_32_LIBS=/usr/lib/gcc/$HOST/4.8
export CFLAGS="-I$PREFIX/include -I$COMPILER_INCLUDE_DIR"
export CPPFLAGS="-I$PREFIX/include -I$COMPILER_INCLUDE_DIR"
export CXXFLAGS="-I$PREFIX/include -I$COMPILER_INCLUDE_DIR"
export LDFLAGS="-L$PREFIX/lib -L$COMPILER_LIB_DIR"
export XDG_DATA_DIRS="$PREFIX/share"
export LD_LIBRARY_PATH=$PREFIX/lib:$PREFIX/bin:$COMPILER_LIB_DIR
export LIBRARY_PATH=$PREFIX/lib:$PREFIX/bin:$COMPILER_LIB_DIR
export INCLUDE_PATH=$PREFIX/include:$COMPILER_INCLUDE_DIR
export C_INCLUDE_PATH=$PREFIX/include:$COMPILER_INCLUDE_DIR
export CPLUS_INCLUDE_PATH=$PREFIX/include:$COMPILER_INCLUDE_DIR
export CC=$HOST-gcc
export CXX=$HOST-g++
export LD=$HOST-ld
export RANLIB=$HOST-ranlib
export AR=$HOST-ar
export AS=$HOST-as
export STRIP=$HOST-strip
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
Configure Windows Python Run
./configure --build="$BUILD" --host="$HOST" --prefix="$PREFIX" \
PKG_CONFIG="$PREFIX/bin/pkg-config.exe" \
PYTHON="$WINE_PYTHON_PATH/python.exe" \
PYTHON_INCLUDES="-I$WINE_PYTHON_PATH/include" \
PYTHON_LIBS="-L$WINE_PYTHON_PATH/libs -lpython27" \
PYTHON_LIB_LOC="$WINE_PYTHON_PATH/Lib" \
CFLAGS="$CFLAGS -I$PREFIX/include/glib-2.0 -I$PREFIX/lib/glib-2.0/include/" \
CPPFLAGS="$CPPFLAGS -I$PREFIX/include/glib-2.0 -I$PREFIX/lib/glib-2.0/include/"
Configure Linux Python Run
./configure --build="$BUILD" --host="$HOST" --prefix="$PREFIX" \
PKG_CONFIG="$PREFIX/bin/pkg-config.exe" \
PYTHON="/usr/bin/python2.7" \
PYTHON_INCLUDES="-I/usr/include/python2.7/ -I/usr/include/x86_64-linux-gnu/python2.7/" \
PYTHON_LIBS="-L/usr/lib/x86_64-linux-gnu/ -lpython2.7" \
PYTHON_LIB_LOC="/usr/lib/python2.7/" \
CFLAGS="$CFLAGS -I$PREFIX/include/glib-2.0 -I$PREFIX/lib/glib-2.0/include/" \
CPPFLAGS="$CPPFLAGS -I$PREFIX/include/glib-2.0 -I$PREFIX/lib/glib-2.0/include/"
回答1:
Try to insert this into your Makefile:
CFLAGS+= \
-DHAVE_SSIZE_T \
-DPY_FORMAT_SIZE_T="l" \
-DPY_FORMAT_LONG_LONG="ll" \
来源:https://stackoverflow.com/questions/26042077/cross-compiling-python-setup