我花了整个周末去尝试解决这个问题,现在只剩最后一步了。我的目标是让Visual Studio 2010和Qt 4.7.3能够共同工作。
我从源代码安装了Qt,并指定以下配置进行构建:
configure.exe -debug-and-release -opensource -platform win32-msvc2010 -no-webkit -no-phonon -no-phonon-backend -no-script -no-scripttools -no-qt3support -no-multimedia -no-ltcg
配置完成后,我运行了nmake,没有出现任何问题。
在我的Visual Studio 2010解决方案中,有两个项目。如下图所示,它抱怨无法链接Qt库。在“常规”属性中:
AssetIO最初是使用Qt IDE构建的,并且我使用Visual Studio中的Qt插件导入了该项目。编译AssetIO项目可以完美地工作。但是,编译Short项目会导致以下链接器错误:
单击Short项目,选择属性。我将AssetIO添加为引用。在“配置属性”,“VC++目录”中单击,“包含目录”下添加以下目录:
这是我为项目拥有的库文件:
与其再发布更多截图,AssetIO项目的包含目录为: C:\qt_source\4.7.3\include AssetIO项目的库目录为: C:\qt_source\4.7.3\bin
这是我试图让其工作的简单源代码(我的简单测试项目)。
我从源代码安装了Qt,并指定以下配置进行构建:
configure.exe -debug-and-release -opensource -platform win32-msvc2010 -no-webkit -no-phonon -no-phonon-backend -no-script -no-scripttools -no-qt3support -no-multimedia -no-ltcg
配置完成后,我运行了nmake,没有出现任何问题。
在我的Visual Studio 2010解决方案中,有两个项目。如下图所示,它抱怨无法链接Qt库。在“常规”属性中:
AssetIO最初是使用Qt IDE构建的,并且我使用Visual Studio中的Qt插件导入了该项目。编译AssetIO项目可以完美地工作。但是,编译Short项目会导致以下链接器错误:
单击Short项目,选择属性。我将AssetIO添加为引用。在“配置属性”,“VC++目录”中单击,“包含目录”下添加以下目录:
这是我为项目拥有的库文件:
与其再发布更多截图,AssetIO项目的包含目录为: C:\qt_source\4.7.3\include AssetIO项目的库目录为: C:\qt_source\4.7.3\bin
这是我试图让其工作的简单源代码(我的简单测试项目)。
main.cpp
int main(int argc, char* argv[])
{
AssetIO::LevelLoader a;
a.dostuff();
return 0;
}
LevelLoader.h
#ifndef LEVELLOADER_HPP
#define LEVELLOADER_HPP
namespace AssetIO
{
class LevelLoader {
public:
explicit LevelLoader();
~LevelLoader();
void dostuff();
};
}
#endif // LEVELLOADER_HPP
LevelLoader.cpp
#include "LevelLoader.hpp"
#include <QDomDocument>
#include <QFile>
#include <QDebug>
#include <QString>
using namespace AssetIO;
enum ComponentType { Drawable = 0, Position };
// This will definitely be changed, to return a full-blown component. Passing the tagname directly to the
// component factory.
ComponentType ConvertToComponentType(QString tagName)
{
if(tagName.toLower() == "Drawable") {
return Drawable;
}
else if(tagName.toLower() == "Position") {
return Position;
}
else {
// LOG
exit(EXIT_FAILURE);
}
}
LevelLoader::LevelLoader()
{
}
LevelLoader::~LevelLoader()
{
}
void LevelLoader::dostuff()
{
QDomDocument doc("la");
QFile file("../../../Resources/input.sto");
if(!file.open(QIODevice::ReadOnly)) {
// TODO: log this, something
exit(EXIT_FAILURE);
}
if( !doc.setContent(&file)) {
// TODO: log
file.close();
}
// we close the file now the doc has control (i think)
file.close();
// Read the root element
QDomElement root = doc.documentElement();
if(root.tagName() != "Root") {
// TODO: log
exit(EXIT_FAILURE);
}
// Read the Header Info
QDomNode headerNode = root.firstChild();
QDomElement e = headerNode.toElement();
if(e.tagName().toLower() != "HeaderInfo") {
// LOG
}
QDomNodeList componentNode = headerNode.childNodes();
int s = componentNode.count();
QString componentTag(componentNode.at(0).toElement().tagName());
QDomNamedNodeMap a = componentNode.at(0).attributes();
}
我无法弄清楚我做错了什么。有没有人有任何想法?我已经到处寻找解决方案。