I'm using a Linux 2.6.36 on a embedded system. I try to program something with semaphores. For this I need a function from the jiffies.h library. So good so far. When I include the Lib
either this way
#include <jiffies.h>
or this way
#include <linux/jiffies.h>
works.
But the strange thing is if I go to open declaration (eclipse comand) it opens an new editor window with the library. Does anyone have a clue what to do?
You are probably not building your module correctly. A kernel module Makefile is extremely simple, and should look something like this, in its entirety:
obj-m := mymodule.o
mymodule.ko: mymodule.c mymodule.h
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
The kernel build system will do the rest. For more details, see the chapter on building modules at http://lwn.net/Kernel/LDD3/
Editing:
Now it appears maybe you aren't trying to write a kernel module after all. In that case, you don't want any include files that are part of the kernel source. jiffies.h is not a userland include; it is a part of the kernel, used in writing parts of the kernel. For userland semaphores, try POSIX semaphores. Start with man sem_overview, and/or Google "POSIX semaphore".
One mystery is solved: Eclipse store all file names in a project in a kind of list and when I click on show declaration it search in the list for that name and display the file. So it doesn't say anything about the compiler and the linker if this work. If that is not true please correct me.
Related
This question follows on from Can you tell me what "crus" means in "LDFLAGS = crus $#"?
Since my error message is "aarch64-poky-linux-ld: cannot find crus: No such file or directory",
where can I find documentation on aarch64-poky-linux-ld?
Best regards,
Next questions: How do I link in needed libraries to a new layer in Yocto?
How do I link librt and libpthread to a new layer in Yocto?
All Linux systems I know of use GNU ld as their linker, part of the binutils package, and it has a complete manual. The aarch64-poky-linux- prefix is a target triplet, used to identify which cross-compilation target this particular ld executable is for.
However, all I think it will tell you is that a string which is not part of an option (starting with - or --) will be treated as an input file. So the message just reports that it is trying to use crus as an input file but it doesn't exist. That's not surprising because as was pointed out on your other question, crus appears to be meant as options to the ar program, not for ld at all. They don't make sense in an LDFLAGS variable. So you will need instead to debug whatever makefile or script decided to try to pass those "options" to aarch64-poky-linux-ld in the first place.
I want to build a Qt project using either GCC or an ARM compiler. In either environment I have to link different libraries.
How I can check if the current compiler is Linux's g++ and CROSS_COMPILE is 'arm-cortexa9neont-linux-gnueabi-'?
You can use the Platform Scope built in to QMake to set up the build differently depending on platform.
It's based on the mkspec's shipped with Qt and can be found in
[Where Qt's installed]/mkspecs
So in your case I guess it'll look something like this:
linux-arm-gnueabi {
//ARM stuff here
}
Please note that I have not tested this. I've only read what's in the documentation I have linked to.
If you want to know only type of processor, you can use Q_PROCESSOR_ARM macro.
I am planning to add support for menuconfig in my project. The project is not associated with Linux kernel so, I have to write everything from scratch in menuconfig and Makefile.
How do I add support for menuconfig and create Kconfig and make the makefile read the defines in .config?
Any good tutorial to begin with?
If you are interested on using KBuild/KConfig for your custom applications, you may try the following Github projects. They aim to provide an initial template for projects using KBuild/KConfig and, therefore, supporting menuconfig.
Kbuild skeleton: https://github.com/masahir0y/kbuild_skeleton
Kbuild template: https://github.com/embedded-it/kbuild-template
First you need to copy the folders and files below from linux folder 'scripts' into your own project
basic
kconfig
Kbuild.include
Makefile.build
Makefile.host
Makefile.lib
Sources in folders basic and kconfig need to be built for your processor architecture. How to do it is written in the linux Makefile. You can change some names using next variables
KCONFIG_CONFIG = .config
KCONFIG_AUTOHEADER = application/autoconf.h
KCONFIG_AUTOCONFIG = build/include/config/auto.conf
KCONFIG_TRISTATE = build/include/config/tristate.conf
The following project initially created for ARM MCUs can help you to understand kconfig
https://github.com/mcu/kconfig
I'll assume you are making a driver that is outside of the kernel directory. Information for that can be found here: https://www.kernel.org/doc/Documentation/kbuild/modules.txt.
Outside of that, if you want a userspace file to see the .config variables, you can have it depend on the kernel build, and then include autoconf.h, which is in the include/generated folder for recent versions of the kernel. Userspace does not use kbuild directly.
I was trying to make virtualbox kernel modules builtin, I'm almost completed here, but at the final step, it stopped compiling, because kernel seems to treat all vbox* modules as a single one:
drivers/vboxnetadp/built-in.o: In function `cleanup_module':
(.exit.text+0x0): multiple definition of `cleanup_module'
drivers/vboxdrv/built-in.o:(.exit.text+0x0): first defined here
drivers/vboxnetadp/built-in.o: In function `init_module':
(.init.text+0x0): multiple definition of `init_module'
.. suppressed output ...
make[1]: *** [drivers/built-in.o] Error 1
make: *** [drivers] Error 2
Any thoughts ? Here's how I got that:
I copied all module sources into drivers folder, edit the makefile, put a obj-y += vbox/, and edit all Makefile of vbox modules, change obj-m to obj-y to make them builtin, pretty dirty hack, but worked.
EDIT
Why need to do that ? I need to disable module loading on my machine, so no modules should be present, I've made all modules wrote by myself builtin, only thing left is vbox's ones now
I would say your question rather belongs to Stack Overflow, since it is basically a c-programming-language-question.
The problem you are facing is that you try to compile two (previously separate) programs into one. Both seem to use the same functions - meant within their own context.
My guess is that you will have to rename all these multiple occurrences of init_module or other functions into separate name-spaces (like net_init_module and drv_init_module). Or perhaps there is a way to declare these functions to be "local" - it`s been a while that I programmed in C...
I am writing a Linux kernel module which need to export some header files to userspace.
I am wondering if there is any standard method which use Kernel package to do required sanitation of headers (For example something like "$(MAKE) -C $(KERNELDIR) M=$(PWD) headers_install" if exist).
Should i take care of headers manually?
Any suggestion?
There is no such functionality out of the box because most kernel modules which need something like that come with an extra "devel" package which contains the (cleaned) header files and probably a shared library to talk to the module.
As for cleaning your headers, I suggest to split the header files into a generic part (which you export) and an internal part (which only the kernel module can see). typedef is your friend.
You can do it by adding 'header-y=' to one of the Kbuild under /include/uapi