在编译Qt的demo程序时,有时会遇到一个错误提示,无法找到demo_shared.lib。遇到这个链接错误,说明当前编译的QtDemo程序依赖demo_shared.lib这个lib。Qt在编写这些Demo时把部分公用的代码写到了shared项目中,需要先构建该项目生成所需的lib文件。
在构建shared项目时又遇到无法打开qpixmapdata_p.h头文件的错误提示,跳转到错误位置发现,跳转到的文件名就是qpixmapdata_p.h但是里面只写了条include语句,指向所需的qpixmapdata_p.h文件的位置在"../../../src/gui/image/qpixmapdata_p.h"。在SDK安装目录下搜索无果,而且看到“src”目录,猜测这个文件很有可能在Qt的源码里面。QtSDK里是没有src文件夹的,所幸我下载了Qt的源码,果然在src文件夹里面找到了所需文件,修改之前提到的include语句,这样shared项目构建成功,以后所有需要用到该lib的Demo就能编译使用了。
下面是qpixmapdata_p.h文件内容
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation ([email protected])
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be