一半君的总结纸

听话只听一半君

Master Miki Hoshii指点的Linux下编译Maya 2013 可用的 PyQt的步骤( CentOS 6.3 x64)

首先必须声明的是,我不是一个程序员,其实我是一个果粉,所以如果下面写错了的地方敬请指正。

我的破笔记本装的win7挂了,于是就想装个linux玩玩,同时还可以学习下工作上要用的PyQt,没想到痛苦的旅程就开始了。

ps:Linux还是留给程序猿去用吧….

pss:还有女程序猿…

以下为个人理解(from a non-programmer’s perspective)

所以总步骤是:

1.下自动桌网站的qt,compile, 自己拷到某个地方

2.sip搞出来 这个我会

3.下pyqt (怎么告知他qt在我自己考的那地方 不会 是不是设一堆env var 之类的 我猜是在python config.py后面加一堆各种flag)

4.搞出来之后 pyqt放到pythonpath里就可以用了

下面开始:

准备工作:

  • 先安装openssl-devel ( 自动桌官网qt source压缩包里linux说明里写的)
    packageyum install openssl-devel
  • 正式开始之前得有gcc 4.1.2,可是centos6.3里yum装出来是4.6.x ,上网一搜发现4.1.2是2007年的 不知道上哪儿装,所以得自己编译(?是么)
    yum groupinstall "Developer Tools"
    
    yum groupinstall "Developer Libraries"

    (这是某人说的在RHEL里的group的名字),CentOS里似乎名字不一样,有如下的4个

    yum grouplist | grep Devel
    
    Additional Development
    
    Development tools
    
    Desktop Platform Development
    
    Server Platform Development

    我只装了前两个

  • 网站为了compile qt还得预先安装以下package(根据around-the-corner网站的说明)
    yum install glibc-devel.i686
    
    yum install libXext-devel
  • 然后按照自动桌doc里的说明操作,具体如下To compile plug-ins and standalone applications for Maya 2013 for Linux, use the gcc compiler, version 4.1.2. Plug-ins built with any other compiler will not work because the C++ ABI (Application Binary Interface) must match between Maya and plug-ins. For best compatibility with Maya, the operating system should be either Red Hat Enterprise Linux 6.0 or Fedora Core 14.Note that the compiler should be renamed with the “412” extension to avoid conflict with the default version of gcc on the system.Unlike other platforms, on Linux we build the gcc compiler with certain options. Follow these steps to build the gcc compiler:
    Download the gcc 4.1.2 source tar file from http://gcc.gnu.org/install/ (官网2013 pyqt 说明里说要用自动桌给的修改版qt,不知为何这里又说用默认版,我用的还是官网修改版)
    
    Setup directories:
     % mkdir gcc412
     % cd gcc412
     % mkdir gcc-build
    
    Extract the source files:
     % tar zxvf gcc-4.1.2.tar.gz
     % cd gcc-build
    
    Configure the compiler. Run the following all on 1 line:
    ../gcc-4.1.2/configure --prefix=/opt/gcc412 --program-suffix=412
    --enable-shared --enable-threads=posix --enable-checking=release
    --with-system-zlib --disable-libunwind-exceptions
    --enable-__cxa_atexit
    
    Build the compiler:
     % make -j 2 bootstrap
    

    从这里开始 出问题了 最后几行错误提示如下:

    	if /home/oglop/Downloads/gcc412/gcc-4.1.2/missing makeinfo --split-size=5000000 --split-size=5000000 --split-size=5000000  -I ../../gcc-4.1.2/fastjar/../gcc/doc/include  -I ../../gcc-4.1.2/fastjar \
    	 -o fastjar.info `test -f 'fastjar.texi' || echo '../../gcc-4.1.2/fastjar/'`fastjar.texi; \
    	then \
    	  rc=0; \
    	else \
    	  rc=$?; \
    	  $restore $backupdir/* `echo "./fastjar.info" | sed 's|[^/]*$||'`; \
    	fi; \
    	rm -rf $backupdir; exit $rc
    WARNING: `makeinfo' is missing on your system.  You should only need it if
             you modified a `.texi' or `.texinfo' file, or any other file
             indirectly affecting the aspect of the manual.  The spurious
             call might also be the consequence of using a buggy `make' (AIX,
             DU, IRIX).  You might want to install the `Texinfo' package or
             the `GNU make' package.  Grab either from any GNU archive site.
    make[4]: *** [fastjar.info] Error 1
    make[4]: Leaving directory `/home/oglop/Downloads/gcc412/gcc-build/fastjar'
    make[3]: *** [all] Error 2
    make[3]: Leaving directory `/home/oglop/Downloads/gcc412/gcc-build/fastjar'
    make[2]: *** [all-fastjar] Error 2
    make[2]: *** Waiting for unfinished jobs....
    gcc -c -g -O2  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -pedantic -Wno-long-long   -DHAVE_CONFIG_H -I. -I../../gcc-4.1.2/fixincludes -I../include -I../../gcc-4.1.2/fixincludes/../include ../../gcc-4.1.2/fixincludes/fixtests.c
    gcc -c -g -O2  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -pedantic -Wno-long-long   -DHAVE_CONFIG_H -I. -I../../gcc-4.1.2/fixincludes -I../include -I../../gcc-4.1.2/fixincludes/../include ../../gcc-4.1.2/fixincludes/fixfixes.c
    gcc -c -g -O2  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -pedantic -Wno-long-long   -DHAVE_CONFIG_H -I. -I../../gcc-4.1.2/fixincludes -I../include -I../../gcc-4.1.2/fixincludes/../include ../../gcc-4.1.2/fixincludes/server.c
    gcc -c -g -O2  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -pedantic -Wno-long-long   -DHAVE_CONFIG_H -I. -I../../gcc-4.1.2/fixincludes -I../include -I../../gcc-4.1.2/fixincludes/../include ../../gcc-4.1.2/fixincludes/procopen.c
    gcc -c -g -O2  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -pedantic -Wno-long-long   -DHAVE_CONFIG_H -I. -I../../gcc-4.1.2/fixincludes -I../include -I../../gcc-4.1.2/fixincludes/../include ../../gcc-4.1.2/fixincludes/fixlib.c
    gcc -c -g -O2  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -pedantic -Wno-long-long   -DHAVE_CONFIG_H -I. -I../../gcc-4.1.2/fixincludes -I../include -I../../gcc-4.1.2/fixincludes/../include ../../gcc-4.1.2/fixincludes/fixopts.c
    srcdir="../../gcc-4.1.2/fixincludes" /bin/sh ../../gcc-4.1.2/fixincludes/mkfixinc.sh x86_64-unknown-linux-gnu
    sed -e 's/@gcc_version@/4.1.2/' < mkheaders.almost > mkheadersT
    gcc -g -O2   -o fixincl fixincl.o fixtests.o fixfixes.o server.o procopen.o fixlib.o fixopts.o ../libiberty/libiberty.a
    mv -f mkheadersT mkheaders
    echo timestamp > full-stamp
    make[3]: Leaving directory `/home/oglop/Downloads/gcc412/gcc-build/fixincludes'
    make[2]: Leaving directory `/home/oglop/Downloads/gcc412/gcc-build'
    make[1]: *** [all] Error 2
    make[1]: Leaving directory `/home/oglop/Downloads/gcc412/gcc-build'
    make: *** [bootstrap] Error 2

    至此卡壳中 望高手指点 Nov 20,2012

    edit:后又搜到一篇教程http://www.scroll-lock.eu/index.php?option=com_content&view=article&id=244:compile-gcc-412-on-ubuntu-1004&catid=1:scroll-blog

    根据此教程compille成功:

    操作步骤是

    • make distclean
    • ../gcc-4.1.2/configure –prefix=/opt/gcc412 –program-suffix=412 –enable-shared –enable-threads=posix –enable-checking=release –disable-libunwind-exceptions –enable-__cxa_atexit –disable-multilib

    (和官方的不同之处是 the –disable-multilib flag and the missing –with-system-zlib flag.)

    • Now because gcc-4.1.2 has a bug and thinks that versions of makeinfo greater than 10 are actually lower than 9 we need to do something manually. In our case if you run makeinfo –version you will see which version was installed by the first step, but it’s usually version 13. Open the Makefile that was created by the ./configure and edit the line where it says:MAKEINFO = /opt/YOURUSERNAME/newlib-1.15.0/missing makeinfoand change it to:MAKEINFO = makeinfoSave the file.

    然后 make -j 2 bootstrap

    最终成功了….

    最后使用 make install DESTDIR=/tmp/xxx 把结果安到临时找的位置

    Install compiler as root:

    % su root

    % make install

    Note: you can make a symlink in /usr/bin to make the call to gcc easier for the

    user:

    % cd /usr/bin

    % ln -s /opt/gcc412/bin/gcc412 .

    % ln -s /opt/gcc412/bin/g++412 .

      1. 首先第一步根据自动桌官网的pdf说明 http://images.autodesk.com/adsk/files/pyqtmaya2013.pdf 我去自动桌提供的地址下载了修改版的qt source,在这里http://www.autodesk.com/lgplsource
      2. ln -s /opt/gcc412/bin/gcc412 /usr/bin/gcc410ln -s /opt/gcc412/bin/g++412 /usr/bin/g++410mv /usr/bin/gcc /usr/bin/gcc4 # 此处把系统默认的gcc 4.6.4改了个名字ln -s /usr/bin/g++410 /usr/bin/g++ln -s /usr/bin/gcc410 /usr/bin/gcc
      3. ./configure -separate-debug-info -no-rpath -no-qt3support -no-phonon -no-phonon-backend
      4. make -j 8 >& build.log
      5. make install

Building SIP

1.cd sip‐4.13.3
2.python ./configure.py #此处应该换成/usr/autodesk/maya2013-x64/bin/mayapy
3.make
4.sudo make install

Building PyQt

python ./configure  #此处应该换成/usr/autodesk/maya2013-x64/bin/mayapy

开始的时候碰到的错误提示是

Error: Make sure you have a working Qt qmake on your PATH or use the -q

argument to explicitly specify a working Qt qmake.

然后尝试 python ./configure -q /usr/local/Trolltech/Qt-4.7.1/bin/qmake

提示找不到QMAKESPEC

export QMAKESPEC=/usr/local/Trolltech/Qt-4.7.1/mkspecs/default/

然后发现依然不行 再尝试QTDIR=/usr/local/Trolltech/Qt-4.7.1

这次可以了但是configure结果显示找不到qt xml module

pylupdate4 and pyrcc4 will not be built because the Qt XML module is missing.

爬文无数 无法解决 最后发现是因为configure找去了系统自带qt 3.3的library path
所以编辑了 /etc/ld.so.conf.d的qt-86_64.conf
默认内容是/usr/lib64/qt-3.3/lib 现在在第一行添加 /usr/local/Trolltech/Qt-4.7.1/lib/
再次configure 成功
make
make install 也成功了

这样得到的PyQt在maya外面用正常,在Maya里用的时候出现如下错误提示

没办法只好又用 /usr/autodesk/maya2013-x64/bin/mayapy 替换上面的python,又重新compile了一次

如自动桌官方pdf里所说 configure的时候会出现如下错误提示 可以忽略

Exception TypeError: TypeError("'NoneType' object is not callable",) in <bound method Popen.__del__ of <subprocess.Popen object at 0x1004ab7d0>> ignored

最终结果…用不了不要喷我
PyQt4.9.5-Py2.6-Qt-4.7.1-gpl-maya2013-x64.tar.gz

纯属乱搞,这种东西就该某人写个自动compile script 然后共享一下好了…

抄袭资料来源:

http://around-the-corner.typepad.com/adn/2012/10/building-qt-pyqt-pyside-for-maya-2013.html

http://around-the-corner.typepad.com/adn/2012/10/building-qt-pyqt-pyside-for-maya-2013-part-2.html

http://www.ilbozo.com/wordpress/?p=28

http://gcc.gnu.org/ml/gcc-help/2011-01/msg00279.html

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: