- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
假设您有一个包含两个目标的 makefile
,如下所示:
# targetA
X86CPPTARGET += targetA
targetA,SRCS = FILEA.cpp FILEB.cpp commonFile.cpp
targetA.so,DEPSOL = libUsedByCommon1.cpp
targetA,CPPFLAGS += -Ifakeinclude -std=c++11
# tartargetBgetA
X86CPPTARGET += targetB
targetB,SRCS = FILEC.cpp FILED.cpp commonFile.cpp
targetA.so,DEPSOL = libUsedByCommon2.cpp
targetB,CPPFLAGS += -std=c++11
targetA
和targetB
共享一个文件,即commonFile.cpp
,里面包含了一些#include
d 标题。commonFile.o
仅由 GNU make 创建一次,并在 targetB
的编译期间重复使用。
targetA
中存在的 CPPFLAGS 使编译器使用包含比默认包含目录中的符号更多符号的包含。 libUsedByCommon2
不会导出 fakeinclude
目录中 header 中包含的所有附加符号,并且在链接时,这会导致 undefined reference
。
我目前使用的解决方法是创建一个指向 commonFile.cpp
的符号链接(symbolic link),并在我的 makefile
中仅在一个目标中使用它。
# targetA
X86CPPTARGET += targetA
targetA,SRCS = FILEA.cpp FILEB.cpp commonFile.cpp
targetA.so,DEPSOL = libUsedByCommon1.cpp
targetA,CPPFLAGS += -Ifakeinclude -std=c++11
# tartargetBgetA
X86CPPTARGET += targetB
targetB,SRCS = FILEC.cpp FILED.cpp **commonFile_symbolic_link.cpp**
targetA.so,DEPSOL = libUsedByCommon2.cpp
targetB,CPPFLAGS += -std=c++11
这个问题有更简洁的解决方案吗?当使用不同的包含路径时,有没有办法强制 GNU make 重新编译 commonFile.cpp
?
最佳答案
您可以使用不同的构建命令创建两个依赖于同一个 C 文件的新目标,如下例...
commonFileA.o: commonFile.cpp
$(CC) -o $@ $^ -FlagsA
commonFileB.o: commonFile.cpp
$(CC) -o $@ $^ -FlagsB
然后您可以使用“commonFileA.o”作为依赖项来链接带有那些特定标志等的版本...
关于c++ - 如何强制 GNU make 重新编译在具有不同 FLAGS 的两个目标中使用的相同目标文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53709886/
我从未见过这样初始化的 for 循环,不明白为什么要这样写? 我正在研究如何连接到 .NET 中的 IMAP 服务器,并开始查看名为 ImapX 的库中的代码。 .我在将数据写入 NetworkStr
我正在尝试解析这个标志“dataroot”(字符串类型)。 将此视为演示代码: from absl import flags from absl.flags import FLAGS flags.DE
我想知道调用之间是否有任何区别(或可能的副作用): AtomicBoolean.set(true) 和 AtomicBoolean.compareAndset(false, true) AtomicB
这个问题已经有答案了: Do you prefer "if (var)" or "if (var != 0)"? [closed] (26 个回答) 已关闭 6 年前。 两者之间有性能差异吗 if (
在 TensorFlow 中解析标志的目的是什么?什么是 tf.flags.FLAGS?&此代码语句的作用是什么? FLAGS = tf.flags.FLAGS FLAGS._parse_flags(
面试题:if (flag==0) 和 if (0==flag) 哪个会执行得更快?为什么? 最佳答案 我还没有看到任何正确的答案(并且已经有一些)警告:Nawaz 确实指出了用户定义的陷阱。而且我很遗
在我的一个站点上,我有一个主用户表,其中包含每个用户的唯一用户 ID、电子邮件地址、密码等。 我需要开始跟踪很多与每个用户相关的二进制标志,比如他们是否确认了他们的电子邮件,他们是否发布了消息,他们是
我有以下辅助函数用于使用 argparse 解析参数: def get_cli_arguments(): parser = argparse.ArgumentParser(prog='Xtra
var a = 'toto titi (should be removed) 5'.replace(/\(.*\)|\[.*\]|[^a-zA-Z0-9 ]|tata|tutu|tyty/gi, '!
我是 Golang 的新手,我一直无法使用标志找到解决此问题的方法。 我如何使用标志以便我的程序可以处理这样的调用,其中 -term 标志可能出现可变次数,包括 0 次: ./myprogram -f
我收到以下有关此正则表达式模式的控制台警告:。我看不到如何为该警告创建有效的正则表达式模式。请问,有没有人能解释一下这个错误以及如何解决它?。已尝试查看文档,但看不到如何使其对v标志有效
嗨,这两者有什么区别 在 SQL Server 中set @flag=1 和set @@flag = 1? 谢谢 最佳答案 什么都没有。作为惯例,某些内置函数的名称以双 at 符号 @@ 开头。为了避
是否可以在不覆盖现有标志的情况下使用 java 邮件在 IMAP 邮件消息上设置自定义标志?例如,我需要在已处理消息上设置一个标志“已处理”,而不将其状态更改为 SEEN/DELETED 或没有邮件客
我对以下行为感到困惑。变量标志从 Controller 传递到jsp代码: flag: flag eq 'Y': ${requestScope.flag eq 'Y'} flag == 'Y': $
我正在尝试根据标志值构建一个字符串 return `${super.getDetails()} Electric: ${this.isElectric} ${flag && '|hatchback'}
此外,将它们直接列在相应标签的对面是否为调试和发布设置了它们? 最佳答案 Xcode 帮助提供了相当清晰的定义: Name: Other C Flags Abstract: Space-separat
当我在 android studio 中创建或克隆一个 flutter 项目时,它显示“创建项目时出错设置 VM 标志失败:无法识别的标志:disable-dart-dev” 我使用的是 Androi
我有一些Python argparse命令行处理代码,最初看起来像这样: import argparse ap = argparse.ArgumentParser() ap.add_argument(
我尝试创建一个多线程单例模式类。 标题: class HL{ public: static HL* getInstance(); ......... priva
我在阅读别人的代码时遇到了很多标志, if (condition1) var1 = true else var1 = false 后来, if (var1 == true) /
我是一名优秀的程序员,十分优秀!