如何将 qmake 与两个同名的源文件一起使用? [英] How to use qmake with two source files which have the same name?

查看:32
本文介绍了如何将 qmake 与两个同名的源文件一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Qt 项目有两个同名但在不同文件夹中的源文件.专业文件是:

My Qt project have two source files with the same name but in different folder. The pro file is:

SOURCES = A/Test.cpp 
SOURCES += B/Test.cpp

它可以通过 Qt Visual Studio 插件生成 Visual Studio 解决方案文件,但它不起作用,因为生成的目标文件具有相同的名称:Test.obj.这将导致 LNK2001 无法解析的外部符号,因为 Test.obj 之一被覆盖.

It can generate Visual Studio solution file via Qt Visual Studio addon, but it won't work because the generated object file have the same name: Test.obj. That will cause LNK2001 unresolved external symbol because one of Test.obj is overwritten.

如何编写适当的 pro 文件来处理?

How to write proper pro file to deal with that?

推荐答案

您可以尝试将该行添加到您的 .pro 文件中:

You can try adding that line to your .pro file:

CONFIG += object_with_source

但正如选项名称所暗示的那样,.obj 文件不会在源外/影子构建"目录中创建.

But as the option name implies, the .obj files will not be created in the out-of-source / "shadow build" directory.

该选项已被替换为 object_parallel_to_source 在 Qt 5 中,它应该与影子建筑一起使用.

That option has been replaced by object_parallel_to_source in Qt 5, which should work with the shadow building.

这篇关于如何将 qmake 与两个同名的源文件一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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