64位centOS 5.3下编译安装codeblocks

December 11, 2009 – 12:11 am

上学的时候编译C++程序使用Microsoft Visual C++,现在转到linux下,自然就不能用那个了,虽然vim + gcc可以搞定一切,但是为了最大程度得提高开发效率,安装一个IDE是必须的。codeblocks是再好不过的选择了。
codeblocks官方没有提供基于centos的发行版本,所以只好选择源代码编译安装了,下载地址:http://www.codeblocks.org/downloads

  1. bunzip2 codeblocks-8.02-src.tar.bz2
  2. tar xvf codeblocks-8.02-src.tar
  3. cd codeblocks-8.02
  4. ./configure --prefix=/opt/codeblocks8.02

提示错误如下:

  1. checking for wx-config... no
  2. configure: error:
  3.                 wxWidgets must be installed on your system.
  4.  
  5.                 Please check that wx-config is in path, the directory
  6.                 where wxWidgets libraries are installed (returned by
  7.                 'wx-config --libs' or 'wx-config --static --libs' command)
  8.                 is in LD_LIBRARY_PATH or equivalent variable and
  9.                 wxWindows version is 2.8.0 or above.

解决方法,下载http://prdownloads.sourceforge.net/wxwindows/wxGTK-2.8.10.tar.gz,然后编译安装。

  1. tar zxvf wxGTK-2.8.10.tar.gz
  2. cd wxGTK-2.8.10
  3. ./configure --prefix=/usr

提示错误如下:

  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.

解决方法:

  1. yum install gtk2-devel

再次

  1. ./configure --prefix=/usr

完成后提示信息如下:

  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

继续

  1. make
  2. make install

最后成功编译安装的提示信息是如下:

  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.

我们继续回去编译安装codeblocks

  1. ./configure --prefix=/opt/codeblocks8.02
  2. make
  3. make install

现在启动codeblocks开始我们的C++编程之旅了。

Post a Comment