简体   繁体   English

如何在Qt中将对象文件添加到项目中

[英]How to add object files to a project in Qt

Currently the linker in one project has problems linking to object files generated by source files in another project. 目前,一个项目中的链接器在链接到另一个项目中的源文件生成的目标文件时出现问题。 Is there some way to manually add those object files to Qt? 有没有办法手动将这些目标文件添加到Qt?

尝试在*.pro文件中使用LIBS指令;

LIBS += /path/to/foo.o

Building on ismail's answer, if you have a directory with many object files, you don't have to include each one separately. 基于ismail的答案,如果您有一个包含许多目标文件的目录,则不必单独包含每个目标文件。 You can just write: 你可以写:

LIBS += "../path-to-objs/*.obj"

You can also specify different object files to link against for debug and release builds with: 您还可以指定要链接的不同目标文件,以便进行调试和发布构建:

Release:LIBS += "../path-to-objs/Release/*.obj"
Debug:LIBS += "../path-to-objs/Debug/*.obj"

I include this because my MSVC linker complains when the specified object files don't match the build type (release/debug). 我包含这个是因为当指定的目标文件与构建类型(发布/调试)不匹配时,我的MSVC链接器会抱怨。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM