Visual Studio 2010 Qt链接问题 [英] Visual Studio 2010 Qt Link Problem

查看:47
本文介绍了Visual Studio 2010 Qt链接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了一个周末试图弄清楚这一点,而我处于最后一步.我的目标是:使Visual Studio 2010和Qt 4.7.3一起工作.

I spent the weekend trying to figure this out and I'm on the last step. My goal: to get visual studio 2010 and Qt 4.7.3 to work together.

我从源代码安装了Qt,并指定使用以下配置进行构建:

I installed Qt from source, specifying to build with the following configuration:

configure.exe-调试和发布-开源-平台win32-msvc2010-无Webkit-无声子-无声子后端-无脚本-无脚本工具-无qt3support-无多媒体-no-ltcg

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,没问题.

After configuration, I ran nmake, no problems.

在我的Visual Studio 2010解决方案中,我有两个项目.抱怨它不能链接Qt库.在常用属性"中

In my visual studio 2010 solution, I have two projects. It's complaining that it cannot link the Qt libraries. In the Common properties

AssetIO最初是使用Qt IDE构建的,我使用了Visual Studio中的Qt插件来导入项目.编译项目 AssetIO 工作得很好.但是,编译Short项目会导致以下链接器错误:右键单击Short项目,选择属性.我添加了AssetIO作为参考.单击配置属性,VC ++目录,我添加了以下包含目录:

AssetIO was originally built using the Qt IDE, and I used the Qt addin within visual studio to import the project. Compiling the project AssetIO works perfectly fine. However, compiling the Short project results in the following linker errors: Right click on the Short project, select properties. I added AssetIO as a reference. Clicking on the Configuration properties, VC++ Directories, I have the following Include directories added:

这是我为该项目准备的库文件:而不是发布更多屏幕截图,AssetIO项目的包含目录是:C:\ qt_source \ 4.7.3 \ include

Here are the library files I have for the project: Rather then post more screen-shots, my include directories for the AssetIO project is: C:\qt_source\4.7.3\include

我的AssetIO项目的库目录是:C:\ qt_source \ 4.7.3 \ bin

my library directory for the AssetIO project is: C:\qt_source\4.7.3\bin

这是我要开始工作的项目的简单源代码(我的简单测试项目)

Here is the simple source code of the project I am trying to get working (my simple test project)

main.cpp
int main(int argc, char* argv[])
{
    AssetIO::LevelLoader a;
    a.dostuff();

    return 0;
}

LevelLoader.h

LevelLoader.h

#ifndef LEVELLOADER_HPP
#define LEVELLOADER_HPP

namespace AssetIO
{
    class LevelLoader {
    public:
        explicit LevelLoader();
        ~LevelLoader();

        void dostuff();
    };
}

#endif // LEVELLOADER_HPP

LevelLoader.cpp

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();
}

我无法弄清楚自己在做什么.有人有什么想法吗?我到处都在寻找解决方案.

I cannot figure out what I am doing incorrectly. Does anyone have any ideas? I have looked everywhere for a solution.

推荐答案

您是否忘了为VS链接指定Qt库文件?您可能需要QtCored4.lib,QtGuid4.lib(d用于调试",在发行配置中将其删除),也许还有其他一些.如果给您带来麻烦的项目是.exe应用程序-转到它的属性"->链接器"->命令行",然后添加不带方括号的{Qored4.lib QtGuid4.lib}.

Haven't you forgot to specify Qt lib files for VS to link with? You'll probably need QtCored4.lib, QtGuid4.lib (d is for "debug", remove it in release config), and, maybe, some others. If the project that gives you trouble is .exe application - go to it's Properties->Linker->Command Line and add {Qored4.lib QtGuid4.lib} without the brackets.

P.S.我的建议:首先,在Qt Creator中创建一个项目并进行测试.然后运行qmake -tp vc -r-,您将获得针对VS或任何其他主要平台的完美工作解决方案.此外,Creator有一个不错的编辑器,您可能会喜欢它.

P. S. My recommendation: first, create a project in Qt Creator and test it. Then run qmake -tp vc -r - and you''l get a perfectly working solution for VS or any other major platform. Besides, Creator has a nice editor, you might like it.

这篇关于Visual Studio 2010 Qt链接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆