qmake为不同命名空间中具有相同名称的2个类重复符号

发布于 2025-01-02 08:33:51 字数 523 浏览 5 评论 0原文

我有两个同名但位于不同命名空间的类。我无法更改这些类或文件的命名。问题是,qmake 生成的 Makefile 中删除了文件夹信息。因此它创建具有平面文件名的 OBJECTS 目标。

qmake 生成的 Makefile:

SOURCES       = ../quml/src/lang/Type_.cpp \
    ...
    ../quml/src/uml/Type_.cpp \
    ...

OBJECTS       = Type_.o \
    ...
    Type_.o \
    ...

如您所见,在非常不同的文件夹中有 2 个 .cpp 文件。这应该稍后将两个对象文件链接到一个可执行文件中。它确实尝试这样做,但两次使用相同的文件,产生重复的符号并且缺少其他符号,因为 Type_.o 仅从一个 .cpp 文件创建(最后一个获胜)。这基本上意味着我永远不能将不同文件夹中具有相同名称的 2 个源文件应用于同一目标。

有人知道我该如何解决这个问题吗?任何专业/优先技巧或子目录在这里会有帮助吗?

I have 2 classes with the same name but in different namespaces. I can't change the naming of these classes or files. The problem is, qmake generates a Makefile with folder information dropped. So it creates OBJECTS targets with flat file names.

Makefile generated by qmake:

SOURCES       = ../quml/src/lang/Type_.cpp \
    ...
    ../quml/src/uml/Type_.cpp \
    ...

OBJECTS       = Type_.o \
    ...
    Type_.o \
    ...

As you can see, there are 2 .cpp files in very different folders. This is supposed to link both objects files later into one executable. It does try so, but taking twice the same file, producing duplicate symbols and lacking the others, because the Type_.o is created from only one of the .cpp files (last one wins). This basically means I can never have 2 source files with same name in different folders applied to the same target.

Anybody any idea how I can solve this? Would any pro/pri tricks or subdir'ing help here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

戴着白色围巾的女孩 2025-01-09 08:33:51

我找到的针对此问题的最佳解决方案是尝试为每个文件夹创建 .pro(或简单的 Makefile)文件并将它们编译为静态库,或者只是更改它们的名称。

The best of solutions I've found for this issue is try to create .pro (or simple Makefile) files for each folder and compile them as static libraries, or simply change their names.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文