【发布时间】:2011-08-29 14:50:18
【问题描述】:
我花了一个周末试图解决这个问题,我已经走到了最后一步。我的目标:让 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 -没有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();
}
我无法弄清楚我做错了什么。有没有人有任何想法?我到处寻找解决方案。
【问题讨论】:
标签: c++ visual-studio-2010 qt linker