如何为 Linux 驱动程序准备 QTCreator内核开发
我在Linux上尝试了一些IDE来用C语言开发驱动程序。QtCreator最适合我。 我需要 IDE 只是为了智能(代码完成、点击跳转到函数等)以加快编码速度。
有没有人配置 QTCreator 来满足这样的需求。 例如,我必须做什么才能获得结构的智能?
问候 驼主。
i tried a few IDEs on linux to develop driver in C. QtCreator suits best for me.
I need the IDE just for the intellisence (codecompletion, jump to functions on click.. etc.) for quicker coding.
Has anyone configured QTCreator for such needs.
E.g. what do i have to do to get intellisence for a struct?
regards
camelord.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
更好的解决方案是使用“Import Existing Project”导入linux源。
添加 ARCH 所需的所有文件。
创建后,编辑 .includes 文件并删除列出的所有包含目录。
然后添加linux使用的几个就可以了。
现在编辑.config,这是最好的部分。
添加如下内容。
#include 引入了您最想要的所有 autoconf 内容。
执行 make V=1 以查看内核构建使用的标准定义。
此外,如果您使用交叉编译器,请像往常一样在“构建和运行”编译器选项卡中进行设置。
A better solution is to import the linux source with "Import Existing Project".
Add all the files your ARCH requires.
Once created edit the .includes file and remove all the include dirs listed.
Then just add the few that linux uses.
Now edit .config, this is the best bit.
Add something like the following.
It's the #include that brings in all of the autoconf stuff you mostly want.
Do a make V=1 to see the standard defines that the Kernel build uses.
Also if you're using a cross compiler, set up as usual in "Build & Run" Compilers tab.
我有同样的问题。
我找到了一个解决方案,如何在Ubuntu上准备Qt Creator进行linux Kernel开发。
准备包含路径:
sudo apt-get install linux-headers-$(uname -r)
配置您的 *.pro 文件:
<前><代码>模板 = 应用程序
配置+=控制台
配置-=app_bundle
配置-= qt
ARCH=arm64
SRC_PROJECT_PATH = /home/user/my_LKM_project
LINUX_HEADERS_PATH = /usr/src/linux-headers-$$system(uname -r)
SOURCES += $$system(find -L $$SRC_PROJECT_PATH -type f -name "*.c" -o -name "*.S" )
HEADERS += $$system(find -L $$SRC_PROJECT_PATH -type f -name "*.h" )
OTHER_FILES += $$system(find -L $$SRC_PROJECT_PATH -type f -not -name "*.h" -not -name "*.c" -not -name "*.S" )
INCLUDEPATH += $$system(find -L $$SRC_PROJECT_PATH -type d)
INCLUDEPATH += $$system(find -L $$LINUX_HEADERS_PATH/include -type d)
INCLUDEPATH += $$system(find -L $$LINUX_HEADERS_PATH/arch/$$ARCH/include -type d)
构建:
您还可以设置构建脚本。
I have the same problem.
I found a solution, how to prepare Qt Creator to the linux Kernel development in the Ubuntu.
Prepare include paths:
sudo apt-get install linux-headers-$(uname -r)
Configuring your *.pro file:
Building:
Also you can set your build script.
我在此处找到了答案。要完成此任务,您需要添加
到用于构建内核模块的所有 .pro 文件。
I found answer here. To acomplish this you need to add
to all .pro files that are used for building kernel modules.
我不被允许发表评论,所以我会在 RedEyed 的答案中添加评论。我必须转义引号,否则我会从 find 命令收到错误消息:
I'm not allowed to comment, so I'll add a comment here to RedEyed's answer. I had to escape the quotes, otherwise I got an error message from the find command:
另一种选择是:
make KBUILD_VERBOSE=1 | tee build.log
prepare_kernel_project.py
(脚本采用build.log
并解析上一步中用于构建的文件/选项,然后创建 QtCreator 项目):文件->打开文件或项目 -> linux/linux.creator
PS 来源
Another option is to:
make KBUILD_VERBOSE=1 | tee build.log
prepare_kernel_project.py
from this repo (the script takesbuild.log
and parses files/options used for building in the previous step, and then creates QtCreator project):File -> Open File or Project -> linux/linux.creator
P.S. Source