[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Building PyTave on windows - cygwin
From: |
Tatsuro MATSUOKA |
Subject: |
Re: Building PyTave on windows - cygwin |
Date: |
Tue, 28 Jun 2016 10:40:48 +0900 (JST) |
----- Original Message -----
> From: Tatsuro MATSUOKA
> To: tmacchant Mike Miller Abhinav Tripathi
> Cc: "Octave-maintainers
> Date: 2016/6/28, Tue 08:43
> Subject: Re: Building PyTave on windows - cygwin
Although I still is in failure at building shared library and
building a final PyTave executable file, I summarize what I reach
that stage.
64 bit build cannot be done due to the failure of building shared library of
liboost-python.
So I describe for only 32bit case
1. Build 32bit 4.1.0+ for windows by mxe-octave on linux
2. Install octave 4.1.0 from archived one
3. Install msys2, update and install tools
4. Install numpy on 32 bit Python for windows
5. Build liboost-python with shared libraries
6. Build PyTave
From 1 to 4 are completed, I stay at 5 linking shared library for Pytave and
library handling.
I will describe in detail.
1. Build 32bit 4.1.0+ for windows by mxe-octave on linux
Please refer
http://wiki.octave.org/Windows_Installer
Note at present (End of June, 2016)
A patch the below is required
http://hg.savannah.gnu.org/hgweb/octave/rev/590c39b94618
See: http://savannah.gnu.org/bugs/?47968#comment8
2. Install 32 bit Python for windows
* Goto https://www.python.org/ and download the latest 32bit version of
python2.7 for
windows and install it.
3. Install msys2, update and install tools
* Download msys2 installer (current msys2-x86_64-20160205.exe ) from
https://sourceforge.net/projects/msys2/files/Base/x86_64/
and install it
* Startup msys2 prompt from shortcut C:\msys64\
Execute update-core
update-core
After update finished, please exit with "x" button and do not use exit
command.
* Startup msys2 prompt from shortcut C:\msys64\
Execute below to update to the recent msys2
pacman -Suu
After update finished, please exit with "x" button and do not use exit
command.
* Install build toolkit and mercurial
Startup msys2 prompt from shortcut C:\msys64\
Execute below to install toolkit and mercurial
pacman -S --needed base-devel msys/dos2unix
pacman -S mercurial
4. Install numpy on 32 bit Python for windows
* Get get-pip.py (e.g. https://bootstrap.pypa.io/get-pip.py)
* Goto python2.7 32bit directory e.g. "cd c:\python27_32" and Execute
python get-pip.py
* Goto Scripts directory e.g. "C:\Python27_32\Scripts"
pip install numpy
(Thanks to Abhinav for numpy install)
5. Build liboost-python with shared libraries
* download boost_1_61_0.tar.bz2 from
https://sourceforge.net/projects/boost/files/boost/1.61.0/
* Un-archive it to the suitable directory
* Startup octave and goto bash promt to use octave development environments
Goto C:\octave\(octave 32 bit dev dir)\bin and execute octave-cli
* Start bash shell from octave prompt
start bash
* Goto build path
cd (un-archived directory)
Note that if you want \ as path sepatator, you can write cd command like
the below (quoting by double quotes)
cd "D:\usr\Tatsu\program\Pytave\PytaveBuild\boost\mingw32\boost_1_61_0"
* PATH setting
Set path to msys2 only to give additional command to msys on octave
environments
and path to Python
export PATH=$PATH:/c/msys64/usr/bin:/c/Python27_32:/c/Python27_32/scripts
* Execute bootstrap.sh
./bootstrap.sh
Then b2.exe and bjam.exe are built.
* Compile source files and link object files to generate (shared) libraries.
e.g.
./b2 install link=static,shared --with-python
cflags='-IC:/Python27_32/include' \
cxxflags='-IC:/Python27_32/include' linkflags='-LC:/Python27_32/libs' \
--prefix=/d/usr/Tatsu/program/Pytave/PytaveBuild/boost/mingw32/boost_1_16_inst \
2>&1 | tee make.log
cflags, cxxflags and linkflags are not required if youinstall python2.7
(32bit) to the
default directory (C:\Python27)
link=static,shared gives static and shared libraries
--with-python gives only libboost_python
--prefix specify install directory
2>&1 | tee make.log is added to memorize build process.
* copy (install dir )/lib/libboost_python-mgw49-mt-1_61.dll.a and
rename it as libboost_python.dll.a
6. Build PyTave
* Startup octave and goto bash promt to use octave development environments
Goto C:\octave\(octave 32 bit dev dir)\bin and execute octave-cli
* Start bash shell from octave prompt
start bash
* PATH setting
Set path to msys2 only to give additional command to msys on octave
environments,
path to Python and path to libboost_python dll
export PATH=$PATH:/c/msys64/usr/bin:/c/Python27_32:/c/Python27_32/scripts
export
PATH=$PATH:/d/usr/Tatsu/program/Pytave/PytaveBuild/boost/mingw32/boost_1_16_inst/lib
Unlike unixy environments, path to shared libraries should be set by a PATH
environments variable.
* Goto build path
cd (un-archived directory)
Note that if you want \ as path sepatator, you can write cd command like
the below (quoting by double quotes)
cd "D:\usr\Tatsu\program\Pytave\PytaveBuild\Pytave\build32"
* configure
The below is an example configure
export CPPFLAGS='-IC:/Python27_32/include
-ID:/usr/Tatsu/program/Pytave/PytaveBuild/boost/mingw32/boost_1_16_inst/include
-ID:/usr/Tatsu/program/Pytave/PytaveBuild/boost/mingw32/boost_1_16_inst/include/boost-1_61
-IC:/octave/octave-4.1.0plus_x86-2016-06-25-08-57/include/octave-4.1.0+
-IC:/octave/octave-4.1.0plus_x86-2016-06-25-08-57/include/octave-4.1.0+/octave
-Ic:/Python27_32/include -Ic:/Python27_32/lib/site-packages/numpy/core/include'
export LDFLAGS='-Wl,--enable-auto-import -Wl,-export-all-symbols
-LC:/Python27_32/libs
-LD:/usr/Tatsu/program/Pytave/PytaveBuild/boost/mingw32/boost_1_16_inst/lib
-LC:/octave/octave-4.1.0plus_x86-2016-06-25-08-57/lib
-LC:/octave/octave-4.1.0plus_x86-2016-06-25-08-57/lib/octave/4.1.0+' \
../pytave/configure LIBS='-LC:/Python27/libs'
--prefix='D:/usr/Tatsu/program/Pytave/PytaveInst32' \
--build=i686-w64-mingw32 --host=i686-w64-mingw32 \
--with-boost='D:/usr/Tatsu/program/Pytave\/PytaveBuild/boost/mingw32/boost_1_16_inst'
Sorry one line is too long to see.
Setting CPPFLAGS from two reason
i) PyTave detect octave install path with path separator '\' but lobtool(?)
omit it.
ii) PyYhave misdirect library directory of python as
c:\Python27_32\Lib\config.
Correct place is C:/Python27_32/libs
From similar reason I set LDFLAGS
The build and host --build=i686-w64-mingw32 --host=i686-w64-mingw32 because
many configure
scripts mis-detect them when msys2 is 64bit.
* make
execute make
For me make fails to build shared libraries and library management.
make[1]: Entering directory
`/d/usr/Tatsu/program/Pytave/PytaveBuild/Pytave/build32'
/bin/sh ./libtool --tag=CXX --mode=link i686-w64-mingw32-g++ -std=gnu++11
-g -O2 -module
-LC:\octave\octave-4.1.0plus_x86-2016-06-25-08-57\lib\octave\4.1.0+
-LC:/Python27_32/libs
-LD:/usr/Tatsu/program/Pytave/PytaveBuild/boost/mingw32/boost_1_16_inst/lib
-LC:/octave/octave-4.1.0plus_x86-2016-06-25-08-57/lib/octave/4.1.0+ -o
_pytave.la -rpath D:/usr/Tatsu/program/Pytave/PytaveInst32 _pytave_la-pytave.lo
libpytave.la -lboost_python -loctinterp -loctave -LC:/Python27/libs
libtool: warning: undefined symbols not allowed in i686-w64-mingw32 shared
libraries; building static only
libtool: link: rm -fr .libs/_pytave.lax
libtool: link: (cd .libs/_pytave.lax/libpytave.a && ar x
"/d/usr/Tatsu/program/Pytave/PytaveBuild/Pytave/build32/./.libs/libpytave.a")
libtool: error: object name conflicts in archive:
.libs/_pytave.lax/libpytave.a//d/usr/Tatsu/program/Pytave/PytaveBuild/Pytave/build32/./.libs/libpytave.a
make[1]: *** [_pytave.la] Error 1
make[1]: Leaving directory
`/d/usr/Tatsu/program/Pytave/PytaveBuild/Pytave/build32'
make: *** [all] Error 2
I tried to build shared libraries from object file manually but it failed
i686-w64-mingw32-g++ -shared \
-Wl,--enable-auto-import -Wl,-export-all-symbols
-Wl,--enable-runtime-pseudo-reloc-v2 \
-Wl,--out-implib=libpytave.dll.a -o libpytave.dll \
-Wl,--output-def=libpytave.def \
libpytave_la-exceptions.o libpytave_la-octave_to_python.o
libpytave_la-python_to_octave.o \
-LC:/Python27_32/libs \
-LD:/usr/Tatsu/program/Pytave/PytaveBuild/boost/mingw32/boost_1_16_inst/lib \
-LC:/octave/octave-4.1.0plus_x86-2016-06-25-08-57/lib/octave/4.1.0+ \
-lboost_python -loctinterp -loctave
libpytave_la-exceptions.o: In function
`ZN6pytave22octave_error_exception4initEv':
d:\usr\Tatsu\program\Pytave\PytaveBuild\Pytave\build32/../pytave/exceptions.h:52:
undefined reference to `_imp__PyExc_RuntimeError'
d:\usr\Tatsu\program\Pytave\PytaveBuild\Pytave\build32/../pytave/exceptions.h:52:
undefined reference to `_imp__PyErr_NewException'
<snip>
A lot of _imp__ symbols errors are detected because no _imp__(symbol)s exist
in object files.
While object files libboost_python for threading-multi have _imp__(symbol)s
in their object files.
Boost does not show full compiling states. Therefore I do not know what
libboost is to do.
I have googled extensively but have gotten no useful information.
Tatsuro
Re: Building PyTave on windows - cygwin, address@hidden, 2016/06/27