- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我有一个主内核模块,其他内核模块与之通信。我已经构建了这样的模块(概念上):
main module/
|
\drivers/
|
|\driver1
|\driver2
\driver3
因为这些是内核模块,我需要像这样编译它们:
make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) modules
但是,由于可以从以前的目录调用驱动程序的 Makefile,因此我需要在调用其他 make(linux 的 make)之前执行 $(shell pwd)
。所以 Makefile 现在看起来像这样:
CURRENT_DIR := $(shell pwd)
.PHONY: all
all:
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(CURRENT_DIR) modules
目前一切正常,运行良好。问题是这样的:我有一个驱动程序需要包含的文件,所以我必须提供要生成的包含路径。我第一次尝试
EXTRA_CFLAGS += -I../..
并立即理解为什么它不起作用(相对路径是/lib/module/... 而不是当前目录)。所以我将其更改为:
MAIN_MODULE_HOME := $(CURRENT_DIR)/../..
EXTRA_CFLAGS += -I$(MAIN_MODULE_HOME)
奇怪的是,这不起作用!如果我写
EXTRA_CFLAGS += -Ipath/I/get/from/pwd/../..
手动编译!有人可以解释我做错了什么吗?在调用 make 之前,我 echo
ed $(CURRENT_DIR)
和 $(MAIN_MODULE_HOME)
并且变量是有意义的。
我知道 EXTRA_CFLAGS
不会立即求值,但是因为 CURRENT_DIR
和 MAIN_MODULE_HOME
是用 :=
声明的我不明白事情怎么会变得一团糟。
(如果有人能更好地表达问题标题,请这样做!)
最佳答案
你应该像这样传递 EXTRA_CFLAGS:
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(CURRENT_DIR) \
EXTRA_CFLAGS="$(EXTRA_CFLAGS)" modules
更新:
driver1/Makefile 的内容被读取两次:第一次 - 当您在 driver1 目录中运行 make
时,第二次 - 由 Kbuild 系统读取。
首先,CURRENT_DIR := $(shell pwd)
被评估为类似于 /home/users/.../main module/drivers/driver1
的内容。其次,Kbuild 将 CURRENT_DIR := $(shell pwd)
评估为类似于 /usr/src/linux-headers-2.6.32-33-generic/
LDD3, ch2, p24 中描述的情况
诀窍是按如下方式编写您的 makefile:
# If KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
ifneq ($(KERNELRELEASE),)
obj-m := hello.o
# Otherwise we were called directly from the command
# line; invoke the kernel build system.
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
#endif
关于linux - Makefile 变量替换显然没有完成,即使 := is used in declaration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8745301/
我有一个模板类 展览.h: template class ExpOf{ ... } 我在整个代码中反复使用,例如T = double [和其他类ExpOf应该一无所知]。 所以我认为一次性编译它是个
如果你有一个名为“Rock”的类,你会做类似的事情:- int main() { Rock; } 为什么会出现“声明未声明任何内容”错误? 它不应该只是调用默认构造函数并在那一刻创建对象吗?
这是一个非常业余的问题,我确信这将是一个非常简单的答案,但我似乎无法弄清楚问题所在。我有一个带有相应 .cpp 文件的头文件,但出于某种原因,每当我尝试使用 g++ 进行编译时,我都会收到错误消息:
我正在使用 MinGW 将我的 Linux 项目转换为在 Windows 上编译。它在 Linux 上编译和运行都很好,但是当我尝试用 MinGW 编译它时,它会出现以下错误消息: camera.h:
我收到“decleration does not declare anything [-fpermissive] 错误”;这是我的代码; #ifndef CAMERA_H #define CAMERA
我正在编写一些 cython 代码,但遇到了一个奇怪的问题。当我尝试将对象作为结构直接从 python 传递到 C 时,cython 生成的代码很好,但 gcc 不喜欢代码输出并给我以下错误:erro
typedef struct BO2Offsets { struct Prestige { u32 offset = 0x000000; char da
我不明白 C++ 中的某些东西,gcc 不喜欢我如何进行。 我做到了: if (!fModeMdi) MyFirstClass* main = (MyFirstClas
在 switch-case 语句中,declaration-with-initialization 是无效的,但允许 declaration-and-then-assignment。如以下代码片段所示
我在我的界面文件中收到一条奇怪的警告。 这也出现在我为此声明属性的那一行。 谁能帮帮我? 最佳答案 在您的项目中的某处,您有一个 #define 将 xOffset 定义为空(除了注释)。像这样: #
declare +x 下面做了什么? (特定于 Bash。)我理解 declare -x,但不理解 declare +x: function the_func { declare +x MY_VA
由于我是 Symfony 的新手,我尝试使用 Doctrine 创建实体关系。我收到错误 “[bundle/entity/file_location”中的属性“report”已经声明,但在我尝试更新架
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 2年前关闭。 Imp
这是给我错误的代码: TAdvSmoothDockItems = class(TCollection) private FOwner: TAdvSmoothDock; FOnChange: T
我对 python 很陌生,我尝试制作一个简单的 GUI 程序。但是,我遇到了一个“问题”,确切地说是一个警告,上面写着:“m”未在全局范围内定义(Python(变量未定义全局))。 我知道如果你想在
当我用 GCC 编译程序时,它会显示“警告:声明未声明任何内容 [-fpermissive]”。 有问题的代码如下: typedef int BOOL; 如何清除警告? 最佳答案 您可以尝试以下操作。
我正在编写一个包含键值对集合的重要类,在编译期间我收到一个我无法弄清楚的非常奇怪的错误。在一个与这里的函数非常相似的函数中,但由于所需代码的复杂性而没有上下文,我收到错误: TValue& opera
这个问题很简单。为了进一步阐明,下面代码中的 Foo1 和 Foo2 在它们的声明方式方面到底有什么区别(例如,使用 class Foo1 { 。 .. }; 而另一个使用 typedef class
我正在开发 Web 项目,并且在从 Oracle 数据库迁移到 mysql 数据库时遇到一些问题。我想用这段代码创建函数: DROP FUNCTION IF EXISTS F_MANIFEST_GAB
是否有一个标志可以传递给 gcc 以禁用此警告?我知道它的作用,但这对我的程序来说无关紧要。 编辑:我只想禁用警告,保持代码不变。编译以下代码会生成警告: struct post{ unsigne
我是一名优秀的程序员,十分优秀!