ubuntu下wxWidget的安装及相关问题解决

来源:互联网 发布:星空软件哪个好 编辑:程序博客网 时间:2024/05/16 03:33
一、首先,重新创建一个新的用户,起名为hr2000,在终端输入以下命令:useradd –d /home/hr2000 –m hr2000
          (注:当然你也可以在你自己的帐户下安装)
二、设置新用户密码,终端输入:passwd hr2000
三、复制wxGTK安装文件到此目录下/home/hr2000
四、修改目录/home/hr2000下的.profile文件,添加内容如下:
LD_LIBRARY_PATH=/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
注:LD_LIBRARY_PATH环境变量主要用于指定查找共享库(动态链接库)时除了默认路径之外的其他路径;DISPLAY用来设置将图形显示到何处;环境变量PATH 是由一连串由冒号隔开的目录名组成,它定义了用户执行的命令在系统中的查找顺序。
五.然后执行下面三条语句:
   tar zxvf wxGTK-2.8.10.tar.gz
   cd wxGTK-2.8.10
   mkdir bldgtk
   cd bldgtk
   ../configure --enable-xrc --enable-monolithic --enable-unicode

注:若出现下面错误:
   1. checking for GTK+ - version >= 2.0.0... no
   2. *** Could not run GTK+ test program, checking why...
   3. *** The test program failed to compile or link. See the file config.log for the
   4. *** exact error that occured. This usually means GTK+ is incorrectly installed.
   5. configure: error:
   6. The development files for GTK+ were not found. For GTK+ 2, please
   7. ensure that pkg-config is in the path and that gtk+-2.0.pc is
   8. installed. For GTK+ 1.2 please check that gtk-config is in the path,
   9. and that the version is 1.2.3 or above. Also check that the
  10. libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
  11. --libs' are in the LD_LIBRARY_PATH or equivalent.

解决方法:
   sudo apt-get install libgtk2.0-dev


完成后提示信息如下:

   1. configure: creating ./config.status
   2. config.status: creating Makefile
   3. config.status: creating expat_config.h
   4.  
   5. Configured wxWidgets 2.8.10 for `x86_64-unknown-linux-gnu'
   6.  
   7.   Which GUI toolkit should wxWidgets use?                 GTK+ 2
   8.   Should wxWidgets be compiled into single library?       no
   9.   Should wxWidgets be compiled in debug mode?             no
  10.   Should wxWidgets be linked as a shared library?         yes
  11.   Should wxWidgets be compiled in Unicode mode?           no
  12.   What level of wxWidgets compatibility should be enabled?
  13.                                        wxWidgets 2.4      no
  14.                                        wxWidgets 2.6      yes
  15.   Which libraries should wxWidgets use?
  16.                                        jpeg               sys
  17.                                        png                sys
  18.                                        regex              sys
  19.                                        tiff               builtin
  20.                                        zlib               sys
  21.                                        odbc               no
  22.                                        expat              builtin
  23.                                        libmspack          no
  24.                                        sdl                no



六、继续
   make
   

注:若make时出现问题:
       In file included from ./src/gtk/gsockgtk.cpp:21:
    ./include/wx/gsocket.h:40: error: using typedef-name 'GSocket' after 'class'
    /usr/include/glib-2.0/gio/giotypes.h:120: error: 'GSocket' has a previous declaration here
    In file included from ./include/wx/gsocket.h:179,

        from ./src/gtk/gsockgtk.cpp:21:

    ./include/wx/unix/gsockunx.h:40: error: using typedef-name 'GSocket' after 'class'
    /usr/include/glib-2.0/gio/giotypes.h:120: error: 'GSocket' has a previous declaration here
    ./src/gtk/gsockgtk.cpp: In function 'void _GSocket_GDK_Input(void*, gint, GdkInputCondition)':
    ./src/gtk/gsockgtk.cpp:34: error: 'struct _GSocket' has no member named 'Detected_Read'
    ./src/gtk/gsockgtk.cpp:36: error: 'struct _GSocket' has no member named 'Detected_Write'
    ./src/gtk/gsockgtk.cpp: In member function 'virtual bool  GSocketGUIFunctionsTableConcrete::Init_Socket    (GSocket*)':
    ./src/gtk/gsockgtk.cpp:56: error: 'struct _GSocket' has no member named 'm_gui_dependent'
    ./src/gtk/gsockgtk.cpp:57: error: 'struct _GSocket' has no member named 'm_gui_dependent'
    ./src/gtk/gsockgtk.cpp: In member function 'virtual void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket*)':
    ./src/gtk/gsockgtk.cpp:67: error: 'struct _GSocket' has no member named 'm_gui_dependent'
    ./src/gtk/gsockgtk.cpp: In member function 'virtual void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket*, GSocketEvent)':
    ./src/gtk/gsockgtk.cpp:72: error: 'struct _GSocket' has no member named 'm_gui_dependent'
    ./src/gtk/gsockgtk.cpp:75: error: 'struct _GSocket' has no member named 'm_fd'
    ./src/gtk/gsockgtk.cpp:83: error: 'struct _GSocket' has no member named 'm_server'
    ./src/gtk/gsockgtk.cpp:90: error: 'struct _GSocket' has no member named 'm_fd'
    ./src/gtk/gsockgtk.cpp: In member function 'virtual void GSocketGUIFunctionsTableConcrete::Uninstall_Callback(GSocket*, GSocketEvent)':
    ./src/gtk/gsockgtk.cpp:98: error: 'struct _GSocket' has no member named 'm_gui_dependent'
    ./src/gtk/gsockgtk.cpp:108: error: 'struct _GSocket' has no member named 'm_server'


解决方法:
      Index: 2.8/src/gtk/gsockgtk.cpp
    ===================================================================
    --- 2.8/src/gtk/gsockgtk.cpp (revision 60599)
    +++ 2.8/src/gtk/gsockgtk.cpp (working copy)
    @@ -15,8 +15,13 @@
     #include <stdlib.h>
     #include <stdio.h>

    // newer versions of glib define its own GSocket but we unfortunately use this    //add
    // name in our own (semi-)public header and so can't change it -- rename glib    //add
    // one instead
    #define GSocket GlibGSocket      //add
     #include <gdk/gdk.h>
     #include <glib.h>
    #undef GSocket        //add

     #include "wx/gsocket.h"
     #include "wx/unix/gsockunx.h"

七、继续
   sudo make install
   sudo vi /etc/ld.so.conf
   将/usr/local/lib加入后,
    运行:sudo ldconfig
八、最后成功编译安装的提示信息是如下:

   1. The installation of wxWidgets is finished.  On certain
   2. platforms (e.g. Linux) you'll now have to run ldconfig
   3. if you installed a shared library and also modify the
   4. LD_LIBRARY_PATH (or equivalent) environment variable.
   5.  
   6. wxWidgets comes with no guarantees and doesn't claim
   7. to be suitable for any purpose.
   8.  
   9. Read the wxWidgets Licence on licencing conditions.


九、测试
   cd /home/hr2000/wxWidget-2.8.10/sample/listctrl
   make clean
   make all
   ./listctrl
如果出现一个列表框就说明wxWidget安装成功了。
哈哈!!!!!!!

原创粉丝点击