[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
undefined reference to errno
Hello all,
I'm attempting to do some work with the sysctl interface from a module. I am
able to correctly build my module using make modules but I get the "undefined
reference to errno" when I attempt the make modules_install step.
Some trawling on the net has revealed that this started happening with various
source trees using older conventions e.g. from
http://www.compusys.co.uk/Compusys/HPC/Cluster+Admin+Tips/Compilation+errors+with+GCC+Version+3.2+and+Open+PBS+version+2.3.16.htm
-------------------------------------------------------
"Since version 2.9 of the GCC compiler the compiler has become a lot stricter
over declaring external references.
Undefined reference to ‘errno’
In most cases this is not a problem, but only when the programming of a library
has become slightly lax. Once common error is to use the phrase:
extern int errno;
in c code rather than the correct method of:
#include <errno.h>
This can be seen in a few of the libraries supplied with Open PBS. To fix this
problem cd to the directory which includes the source code and type the
following command:
grep -rs “extern int errno” *
If any files return as having the line, then replace the line with the correct
version as shown above, using your favourite text editor."
-------------------------------------------------------
When I run this against my development tree, the only place errno is defined is
in include/linux/unistd.h I notice on the lxr site that this is currently valid
code.
For some background, my module is a networking component and I need to fetch
some /proc info. Since I am in the kernel I can't use the userspace sysctl lib
and have to:
#include <linux/sysctl.h>
#include <linux/unistd.h>
and use the syscall1 macro. This part of the code seems fine. In order to test
it, I tried a small userspace program which generated the same "unreferenced
errno" error until I did the following :
#include <linux/errno.h>
Now the userspace example works but it doesn't fix the module.
WTF is going on here? I don't know enough about this to fix it but I'd be
grateful for any pointers even if its to a site or book worth reading about
this because I know my ignorance of compiling and linking isn't helping me
here. I have taken a look at Johnson & Troans "Linux Application Development"
and Rubini's "Understanding the Linux Kernel" but there is very little
discussion of the linking phase of a kernel build.
There are so many returns for this on google that it must have tripped up a few
people - just none of the solutions match my problem.
Any help gratefully received,
cam
__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/