undefined reference to `inotify_init1'
up vote
1
down vote
favorite
I am trying to integrate latest version 2.80 of dnsmasq application in my project. The platform is Linux 2.6.32.
Compilation with cross compiler arm-none-linux-gnueabi-gcc is giving this error:
inotify.o: In function `inotify_dnsmasq_init':
inotify.c:(.text+0x514): undefined reference to `inotify_init1'
It seems that function inotify_init1() is not supported in this platform.
I'm wondering if I can write this function by myself.
int inotify_init1(int flags)
{
int flags1 = 0;
int inotify_fd = inotify_init();
if ((inotify_fd != -1) && (flags != 0))
{
if((flags1 = fcntl(inotify_fd, F_GETFL)) != -1)
{
fcntl(inotify_fd, F_SETFL, flags1 | flags);
}
}
return inotify_fd;
}
Would the piece of code do the job?
Update:
according to inotify_init man page, inotify_init1() was added to glibc in version 2.9. I am working with glibc version 2.8 only
In an other hand I see that inotify_init1 is present in several files in Kernel:
1) /fs/notify/inotify/inotify_user.c
/* inotify syscalls */
SYSCALL_DEFINE1(inotify_init1, int, flags)
{
...
}
2) /kernel/sys_ni.c
cond_syscall(sys_inotify_init1);
I understand that I am missing something but I don't know if the appropriate library is built or properly linked on the dnsmasq building files.
Thank you for advising.
c linux-kernel embedded-linux dnsmasq
|
show 4 more comments
up vote
1
down vote
favorite
I am trying to integrate latest version 2.80 of dnsmasq application in my project. The platform is Linux 2.6.32.
Compilation with cross compiler arm-none-linux-gnueabi-gcc is giving this error:
inotify.o: In function `inotify_dnsmasq_init':
inotify.c:(.text+0x514): undefined reference to `inotify_init1'
It seems that function inotify_init1() is not supported in this platform.
I'm wondering if I can write this function by myself.
int inotify_init1(int flags)
{
int flags1 = 0;
int inotify_fd = inotify_init();
if ((inotify_fd != -1) && (flags != 0))
{
if((flags1 = fcntl(inotify_fd, F_GETFL)) != -1)
{
fcntl(inotify_fd, F_SETFL, flags1 | flags);
}
}
return inotify_fd;
}
Would the piece of code do the job?
Update:
according to inotify_init man page, inotify_init1() was added to glibc in version 2.9. I am working with glibc version 2.8 only
In an other hand I see that inotify_init1 is present in several files in Kernel:
1) /fs/notify/inotify/inotify_user.c
/* inotify syscalls */
SYSCALL_DEFINE1(inotify_init1, int, flags)
{
...
}
2) /kernel/sys_ni.c
cond_syscall(sys_inotify_init1);
I understand that I am missing something but I don't know if the appropriate library is built or properly linked on the dnsmasq building files.
Thank you for advising.
c linux-kernel embedded-linux dnsmasq
1
Do you link to the corresponding library?
– Yastanub
Nov 8 at 14:14
Isn't it is the same library as inotify_init() ?
– Gaston
Nov 8 at 14:16
i do not know this library but it sounds like you are missing to link thelibwhateveritiscalled.a
to your executable
– Yastanub
Nov 8 at 14:18
As i can read out of inotify_init man page you seem to need to link againstglibc
. I am not sure since i do not work as much with linux and its man pages.
– Yastanub
Nov 8 at 14:21
1
Have you built the library already? There must be some lib file missing or you forget to link it. I can not say for sure since you do not show any code but this is most likely the problem when it comes to undefined reference errors.
– Yastanub
Nov 8 at 14:54
|
show 4 more comments
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am trying to integrate latest version 2.80 of dnsmasq application in my project. The platform is Linux 2.6.32.
Compilation with cross compiler arm-none-linux-gnueabi-gcc is giving this error:
inotify.o: In function `inotify_dnsmasq_init':
inotify.c:(.text+0x514): undefined reference to `inotify_init1'
It seems that function inotify_init1() is not supported in this platform.
I'm wondering if I can write this function by myself.
int inotify_init1(int flags)
{
int flags1 = 0;
int inotify_fd = inotify_init();
if ((inotify_fd != -1) && (flags != 0))
{
if((flags1 = fcntl(inotify_fd, F_GETFL)) != -1)
{
fcntl(inotify_fd, F_SETFL, flags1 | flags);
}
}
return inotify_fd;
}
Would the piece of code do the job?
Update:
according to inotify_init man page, inotify_init1() was added to glibc in version 2.9. I am working with glibc version 2.8 only
In an other hand I see that inotify_init1 is present in several files in Kernel:
1) /fs/notify/inotify/inotify_user.c
/* inotify syscalls */
SYSCALL_DEFINE1(inotify_init1, int, flags)
{
...
}
2) /kernel/sys_ni.c
cond_syscall(sys_inotify_init1);
I understand that I am missing something but I don't know if the appropriate library is built or properly linked on the dnsmasq building files.
Thank you for advising.
c linux-kernel embedded-linux dnsmasq
I am trying to integrate latest version 2.80 of dnsmasq application in my project. The platform is Linux 2.6.32.
Compilation with cross compiler arm-none-linux-gnueabi-gcc is giving this error:
inotify.o: In function `inotify_dnsmasq_init':
inotify.c:(.text+0x514): undefined reference to `inotify_init1'
It seems that function inotify_init1() is not supported in this platform.
I'm wondering if I can write this function by myself.
int inotify_init1(int flags)
{
int flags1 = 0;
int inotify_fd = inotify_init();
if ((inotify_fd != -1) && (flags != 0))
{
if((flags1 = fcntl(inotify_fd, F_GETFL)) != -1)
{
fcntl(inotify_fd, F_SETFL, flags1 | flags);
}
}
return inotify_fd;
}
Would the piece of code do the job?
Update:
according to inotify_init man page, inotify_init1() was added to glibc in version 2.9. I am working with glibc version 2.8 only
In an other hand I see that inotify_init1 is present in several files in Kernel:
1) /fs/notify/inotify/inotify_user.c
/* inotify syscalls */
SYSCALL_DEFINE1(inotify_init1, int, flags)
{
...
}
2) /kernel/sys_ni.c
cond_syscall(sys_inotify_init1);
I understand that I am missing something but I don't know if the appropriate library is built or properly linked on the dnsmasq building files.
Thank you for advising.
c linux-kernel embedded-linux dnsmasq
c linux-kernel embedded-linux dnsmasq
edited Nov 12 at 15:51
asked Nov 8 at 14:08
Gaston
3401625
3401625
1
Do you link to the corresponding library?
– Yastanub
Nov 8 at 14:14
Isn't it is the same library as inotify_init() ?
– Gaston
Nov 8 at 14:16
i do not know this library but it sounds like you are missing to link thelibwhateveritiscalled.a
to your executable
– Yastanub
Nov 8 at 14:18
As i can read out of inotify_init man page you seem to need to link againstglibc
. I am not sure since i do not work as much with linux and its man pages.
– Yastanub
Nov 8 at 14:21
1
Have you built the library already? There must be some lib file missing or you forget to link it. I can not say for sure since you do not show any code but this is most likely the problem when it comes to undefined reference errors.
– Yastanub
Nov 8 at 14:54
|
show 4 more comments
1
Do you link to the corresponding library?
– Yastanub
Nov 8 at 14:14
Isn't it is the same library as inotify_init() ?
– Gaston
Nov 8 at 14:16
i do not know this library but it sounds like you are missing to link thelibwhateveritiscalled.a
to your executable
– Yastanub
Nov 8 at 14:18
As i can read out of inotify_init man page you seem to need to link againstglibc
. I am not sure since i do not work as much with linux and its man pages.
– Yastanub
Nov 8 at 14:21
1
Have you built the library already? There must be some lib file missing or you forget to link it. I can not say for sure since you do not show any code but this is most likely the problem when it comes to undefined reference errors.
– Yastanub
Nov 8 at 14:54
1
1
Do you link to the corresponding library?
– Yastanub
Nov 8 at 14:14
Do you link to the corresponding library?
– Yastanub
Nov 8 at 14:14
Isn't it is the same library as inotify_init() ?
– Gaston
Nov 8 at 14:16
Isn't it is the same library as inotify_init() ?
– Gaston
Nov 8 at 14:16
i do not know this library but it sounds like you are missing to link the
libwhateveritiscalled.a
to your executable– Yastanub
Nov 8 at 14:18
i do not know this library but it sounds like you are missing to link the
libwhateveritiscalled.a
to your executable– Yastanub
Nov 8 at 14:18
As i can read out of inotify_init man page you seem to need to link against
glibc
. I am not sure since i do not work as much with linux and its man pages.– Yastanub
Nov 8 at 14:21
As i can read out of inotify_init man page you seem to need to link against
glibc
. I am not sure since i do not work as much with linux and its man pages.– Yastanub
Nov 8 at 14:21
1
1
Have you built the library already? There must be some lib file missing or you forget to link it. I can not say for sure since you do not show any code but this is most likely the problem when it comes to undefined reference errors.
– Yastanub
Nov 8 at 14:54
Have you built the library already? There must be some lib file missing or you forget to link it. I can not say for sure since you do not show any code but this is most likely the problem when it comes to undefined reference errors.
– Yastanub
Nov 8 at 14:54
|
show 4 more comments
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You function looks ok and should work. I don't know however how your application defines the macros IN_NONBLOCK and IN_CLOEXEC. Looking at kernel srcrs they should be defined the same as O_NONBLOCK and O_CLOEXEC. Also would be nice to add if (flags & ~(IN_CLOEXEC | IN_NONBLOCK)) return -EINVAL;
some checking.
I would add a file inotify.h
to your project / to dnsmasq sources, which I would add to include path:
#ifndef MY_INOTIFY_H_
#define MY_INOTIFY_H_
#include_next <inotify.h>
// from https://github.molgen.mpg.de/git-mirror/glibc/blob/glibc-2.9/sysdeps/unix/sysv/linux/sys/inotify.h#L25
/* Flags for the parameter of inotify_init1. */
enum
{
IN_CLOEXEC = 02000000,
#define IN_CLOEXEC IN_CLOEXEC
IN_NONBLOCK = 04000
#define IN_NONBLOCK IN_NONBLOCK
};
extern int inotify_init1 (int flags) __THROW;
// or just int inotify_init1(int flags); ...
#endif
Along with it your wrapper in a c file added to compilation / linking. The include_next serves as a simple overwrite of the glibc inotify.h.
If you kernel supports inotify_wait1 syscall and I think it does. You can even check if__NR_inotify_wait1 is defined in your unistd.h. You can just:
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
int inotify_init1(int flags) {
return syscall(332, flags);
}
To make a syscall just call a syscall() function.
1
OK, thank you, let me a chance to check all this later.
– Gaston
Nov 13 at 9:05
1
It helps a lot to understand this topic. Thank you.
– Gaston
Nov 13 at 16:16
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You function looks ok and should work. I don't know however how your application defines the macros IN_NONBLOCK and IN_CLOEXEC. Looking at kernel srcrs they should be defined the same as O_NONBLOCK and O_CLOEXEC. Also would be nice to add if (flags & ~(IN_CLOEXEC | IN_NONBLOCK)) return -EINVAL;
some checking.
I would add a file inotify.h
to your project / to dnsmasq sources, which I would add to include path:
#ifndef MY_INOTIFY_H_
#define MY_INOTIFY_H_
#include_next <inotify.h>
// from https://github.molgen.mpg.de/git-mirror/glibc/blob/glibc-2.9/sysdeps/unix/sysv/linux/sys/inotify.h#L25
/* Flags for the parameter of inotify_init1. */
enum
{
IN_CLOEXEC = 02000000,
#define IN_CLOEXEC IN_CLOEXEC
IN_NONBLOCK = 04000
#define IN_NONBLOCK IN_NONBLOCK
};
extern int inotify_init1 (int flags) __THROW;
// or just int inotify_init1(int flags); ...
#endif
Along with it your wrapper in a c file added to compilation / linking. The include_next serves as a simple overwrite of the glibc inotify.h.
If you kernel supports inotify_wait1 syscall and I think it does. You can even check if__NR_inotify_wait1 is defined in your unistd.h. You can just:
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
int inotify_init1(int flags) {
return syscall(332, flags);
}
To make a syscall just call a syscall() function.
1
OK, thank you, let me a chance to check all this later.
– Gaston
Nov 13 at 9:05
1
It helps a lot to understand this topic. Thank you.
– Gaston
Nov 13 at 16:16
add a comment |
up vote
1
down vote
accepted
You function looks ok and should work. I don't know however how your application defines the macros IN_NONBLOCK and IN_CLOEXEC. Looking at kernel srcrs they should be defined the same as O_NONBLOCK and O_CLOEXEC. Also would be nice to add if (flags & ~(IN_CLOEXEC | IN_NONBLOCK)) return -EINVAL;
some checking.
I would add a file inotify.h
to your project / to dnsmasq sources, which I would add to include path:
#ifndef MY_INOTIFY_H_
#define MY_INOTIFY_H_
#include_next <inotify.h>
// from https://github.molgen.mpg.de/git-mirror/glibc/blob/glibc-2.9/sysdeps/unix/sysv/linux/sys/inotify.h#L25
/* Flags for the parameter of inotify_init1. */
enum
{
IN_CLOEXEC = 02000000,
#define IN_CLOEXEC IN_CLOEXEC
IN_NONBLOCK = 04000
#define IN_NONBLOCK IN_NONBLOCK
};
extern int inotify_init1 (int flags) __THROW;
// or just int inotify_init1(int flags); ...
#endif
Along with it your wrapper in a c file added to compilation / linking. The include_next serves as a simple overwrite of the glibc inotify.h.
If you kernel supports inotify_wait1 syscall and I think it does. You can even check if__NR_inotify_wait1 is defined in your unistd.h. You can just:
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
int inotify_init1(int flags) {
return syscall(332, flags);
}
To make a syscall just call a syscall() function.
1
OK, thank you, let me a chance to check all this later.
– Gaston
Nov 13 at 9:05
1
It helps a lot to understand this topic. Thank you.
– Gaston
Nov 13 at 16:16
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You function looks ok and should work. I don't know however how your application defines the macros IN_NONBLOCK and IN_CLOEXEC. Looking at kernel srcrs they should be defined the same as O_NONBLOCK and O_CLOEXEC. Also would be nice to add if (flags & ~(IN_CLOEXEC | IN_NONBLOCK)) return -EINVAL;
some checking.
I would add a file inotify.h
to your project / to dnsmasq sources, which I would add to include path:
#ifndef MY_INOTIFY_H_
#define MY_INOTIFY_H_
#include_next <inotify.h>
// from https://github.molgen.mpg.de/git-mirror/glibc/blob/glibc-2.9/sysdeps/unix/sysv/linux/sys/inotify.h#L25
/* Flags for the parameter of inotify_init1. */
enum
{
IN_CLOEXEC = 02000000,
#define IN_CLOEXEC IN_CLOEXEC
IN_NONBLOCK = 04000
#define IN_NONBLOCK IN_NONBLOCK
};
extern int inotify_init1 (int flags) __THROW;
// or just int inotify_init1(int flags); ...
#endif
Along with it your wrapper in a c file added to compilation / linking. The include_next serves as a simple overwrite of the glibc inotify.h.
If you kernel supports inotify_wait1 syscall and I think it does. You can even check if__NR_inotify_wait1 is defined in your unistd.h. You can just:
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
int inotify_init1(int flags) {
return syscall(332, flags);
}
To make a syscall just call a syscall() function.
You function looks ok and should work. I don't know however how your application defines the macros IN_NONBLOCK and IN_CLOEXEC. Looking at kernel srcrs they should be defined the same as O_NONBLOCK and O_CLOEXEC. Also would be nice to add if (flags & ~(IN_CLOEXEC | IN_NONBLOCK)) return -EINVAL;
some checking.
I would add a file inotify.h
to your project / to dnsmasq sources, which I would add to include path:
#ifndef MY_INOTIFY_H_
#define MY_INOTIFY_H_
#include_next <inotify.h>
// from https://github.molgen.mpg.de/git-mirror/glibc/blob/glibc-2.9/sysdeps/unix/sysv/linux/sys/inotify.h#L25
/* Flags for the parameter of inotify_init1. */
enum
{
IN_CLOEXEC = 02000000,
#define IN_CLOEXEC IN_CLOEXEC
IN_NONBLOCK = 04000
#define IN_NONBLOCK IN_NONBLOCK
};
extern int inotify_init1 (int flags) __THROW;
// or just int inotify_init1(int flags); ...
#endif
Along with it your wrapper in a c file added to compilation / linking. The include_next serves as a simple overwrite of the glibc inotify.h.
If you kernel supports inotify_wait1 syscall and I think it does. You can even check if__NR_inotify_wait1 is defined in your unistd.h. You can just:
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
int inotify_init1(int flags) {
return syscall(332, flags);
}
To make a syscall just call a syscall() function.
edited Nov 13 at 9:33
answered Nov 13 at 8:55
Kamil Cuk
8,0601222
8,0601222
1
OK, thank you, let me a chance to check all this later.
– Gaston
Nov 13 at 9:05
1
It helps a lot to understand this topic. Thank you.
– Gaston
Nov 13 at 16:16
add a comment |
1
OK, thank you, let me a chance to check all this later.
– Gaston
Nov 13 at 9:05
1
It helps a lot to understand this topic. Thank you.
– Gaston
Nov 13 at 16:16
1
1
OK, thank you, let me a chance to check all this later.
– Gaston
Nov 13 at 9:05
OK, thank you, let me a chance to check all this later.
– Gaston
Nov 13 at 9:05
1
1
It helps a lot to understand this topic. Thank you.
– Gaston
Nov 13 at 16:16
It helps a lot to understand this topic. Thank you.
– Gaston
Nov 13 at 16:16
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53209432%2fundefined-reference-to-inotify-init1%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Do you link to the corresponding library?
– Yastanub
Nov 8 at 14:14
Isn't it is the same library as inotify_init() ?
– Gaston
Nov 8 at 14:16
i do not know this library but it sounds like you are missing to link the
libwhateveritiscalled.a
to your executable– Yastanub
Nov 8 at 14:18
As i can read out of inotify_init man page you seem to need to link against
glibc
. I am not sure since i do not work as much with linux and its man pages.– Yastanub
Nov 8 at 14:21
1
Have you built the library already? There must be some lib file missing or you forget to link it. I can not say for sure since you do not show any code but this is most likely the problem when it comes to undefined reference errors.
– Yastanub
Nov 8 at 14:54