Archive for the ‘C/C++’ Category
Friday, December 11th, 2009
上学的时候编译C++程序使用Microsoft Visual C++,现在转到linux下,自然就不能用那个了,虽然vim + gcc可以搞定一切,但是为了最大程度得提高开发效率,安装一个IDE是必须的。codeblocks是再好不过的选择了。
codeblocks官方没有提供基于centos的发行版本,所以只好选择源代码编译安装了,下载地址:http://www.codeblocks.org/downloads
bunzip2 codeblocks-8.02-src.tar.bz2
tar xvf codeblocks-8.02-src.tar
cd codeblocks-8.02
./configure --prefix=/opt/codeblocks8.02
提示错误如下:
checking for wx-config... no
configure: error:
wxWidgets must be installed on your system.
...
Posted in C/C++, CentOS | No Comments »
Wednesday, December 9th, 2009
参考网络上的资源,总结的一个解决Qt中文支持的方法,还没有仔细深究,暂时记录在这里,当模板使用。
编写一个最简单的Qt程序,参考教材《C++ GUI Qt4编程 第二版》,编译。
#include
#include
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QLabel *label = new QLabel("hello nokia Qt");
label->show();
return a.exec();
}
编译通过,如图:
这还不够,我们要做的程序必须支持中文,改写一下。
#include
#include
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
...
Posted in C/C++, Qt | 1 Comment »
Friday, December 4th, 2009
Nokia推出了Qt 4.6,按照官方说的,代码一次编写,到处编译执行。尤其可以在诺基亚本家的symbian和maemo上运行,这倒是很诱惑人呢!Qt 4.6兼容symbian,还有webkit支持,看来尝试一下是很有必要的,前些日子买了一本C++ Qt Ui的书,这些日子看来又有的忙了... ...
本文测试环境为centOS 5.3 x86_64,其他操作系统安装Qt SDK都没有centOS这么费劲,汗!
首先下载Nokia Qt SDK并安装
下载地址:http://qt.nokia.com/downloads/sdk-linux-x11-64bit-cpp
chmod u+x qt-sdk-linux-x86_64-opensource-2009.05.bin
./qt-sdk-linux-x86_64-opensource-2009.05.bin
安装完毕后创建一个Qt gui项目,随便加个label然后编译看看。
编译报错如下:
No valid Qt version set. Set one in Tools/Options
Error while building project helloworld
When executing build step 'QMake'
Canceled build.
解决方法,依次选择tools->options->Qt4->qt versions,新加一个Qt versions,如图所示:
点击OK,再次编译。
这次编译报错如下:
/home/program/qtsdk-2009.05/qt/lib/libQtGui.so: undefined reference to `FcFreeTypeQueryFace'
collect2: ld returned 1 exit status
make: Leaving directory `/home/project/qt/helloworld/helloworld'
make: *** [helloworld] Error 1
Exited ...
Posted in C/C++, Qt, CentOS | No Comments »