• problem with inotify.h

    From zeneca@3:770/3 to All on Fri Jul 8 16:10:22 2022
    I am trying to compile a small prog with inotify but compilation fail:

    Inotify.c:19:8: warning: implicit declaration of function ‘inotify_init’ [-Wimplicit-function-declaration]
    fd = inotify_init();
    ^~~~~~~~~~~~
    Inotify.c:27:8: warning: implicit declaration of function ‘inotify_add_watch’ [-Wimplicit-function-declaration]
    wd = inotify_add_watch( fd, "/sys/bus/w1/devices/28-000003f1a254/temperature", IN_MODIFY | IN_DELETE );
    ..
    ..

    Any idea??
    Many thanks

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Deloptes@3:770/3 to zeneca on Fri Jul 8 18:05:40 2022
    zeneca wrote:

    I am trying to compile a small prog with inotify but compilation fail:

    Inotify.c:19:8: warning: implicit declaration of function ‘inotify_init’ [-Wimplicit-function-declaration]
    fd = inotify_init();
    ^~~~~~~~~~~~
    Inotify.c:27:8: warning: implicit declaration of function ‘inotify_add_watch’ [-Wimplicit-function-declaration]
    wd = inotify_add_watch( fd, "/sys/bus/w1/devices/28-000003f1a254/temperature", IN_MODIFY | IN_DELETE
    ); ..
    ..

    Any idea??
    Many thanks

    how are you calling the compiler. You should be using -I (for the includes)
    and -L (for the library path)

    something like

    gcc -I/usr/include -L/usr/lib -l somelib source.c -o output.bin

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Martin Gregorie@3:770/3 to Deloptes on Fri Jul 8 16:37:27 2022
    On Fri, 08 Jul 2022 18:05:40 +0200, Deloptes wrote:

    zeneca wrote:

    I am trying to compile a small prog with inotify but compilation fail:

    Inotify.c:19:8: warning: implicit declaration of function
    ‘q’
    [-Wimplicit-function-declaration]
    fd = inotify_init();
    ^~~~~~~~~~~~
    Inotify.c:27:8: warning: implicit declaration of function
    ‘inotify_add_watch’ [-Wimplicit-function-declaration]
    wd = inotify_add_watch( fd,
    "/sys/bus/w1/devices/28-000003f1a254/temperature", IN_MODIFY |
    IN_DELETE ); ..
    ..

    Any idea??
    Many thanks

    how are you calling the compiler. You should be using -I (for the
    includes)
    and -L (for the library path)

    something like

    gcc -I/usr/include -L/usr/lib -l somelib source.c -o output.bin

    Looks like your source should have the following among the other includes:

    #include <sys/inotify.h>

    Have you run "man inotify" and read its descriptionof the inotify APIs?








    --

    Martin | martin at
    Gregorie | gregorie dot org

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From zeneca@3:770/3 to All on Sat Jul 9 09:25:07 2022
    Le 8/07/22 à 18:37, Martin Gregorie a écrit :
    On Fri, 08 Jul 2022 18:05:40 +0200, Deloptes wrote:

    zeneca wrote:

    I am trying to compile a small prog with inotify but compilation fail:

    Inotify.c:19:8: warning: implicit declaration of function
    ‘q’
    [-Wimplicit-function-declaration]
    fd = inotify_init();
    ^~~~~~~~~~~~
    Inotify.c:27:8: warning: implicit declaration of function
    ‘inotify_add_watch’ [-Wimplicit-function-declaration]
    wd = inotify_add_watch( fd,
    "/sys/bus/w1/devices/28-000003f1a254/temperature", IN_MODIFY |
    IN_DELETE ); ..
    ..

    Any idea??
    Many thanks

    how are you calling the compiler. You should be using -I (for the
    includes)
    and -L (for the library path)

    something like

    gcc -I/usr/include -L/usr/lib -l somelib source.c -o output.bin

    Looks like your source should have the following among the other includes:

    #include <sys/inotify.h>

    Have you run "man inotify" and read its descriptionof the inotify APIs?






    #include <linux/inotify.h>

    There are some differences betwen inotify.h pn raspberry and inotify.h
    on Centos 7.9, some ref to extern inotify_init and other are missing on raspberry. The man page doen't give more interresting info for compiling.

    My Makefile contains:
    OPTION=-I/usr/include/mysql -L/usr/lib64/mysql -L/usr/mysql/lib
    -lmysqlclient -lpthread -lz -lm -lrt -lssl -lcrypto -ldl -lrt -std=gnu99

    xosta: Osta.c config.h nokia_routine.c 5110_routines.h charGenerator.h
    if [ -f gpit ]; then $(RM) xosta;fi
    $(CC) $(OPTION) -lwiringPi Osta.c nokia_routine.c -o xosta


    Thanks

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Richard Kettlewell@3:770/3 to zeneca on Sat Jul 9 09:18:29 2022
    zeneca <pasIci@ailleur.fr> writes:
    Le 8/07/22 à 18:37, Martin Gregorie a écrit :
    On Fri, 08 Jul 2022 18:05:40 +0200, Deloptes wrote:
    zeneca wrote:

    I am trying to compile a small prog with inotify but compilation fail: >>>>
    Inotify.c:19:8: warning: implicit declaration of function
    ‘q’
    [-Wimplicit-function-declaration]
    fd = inotify_init();
    ^~~~~~~~~~~~
    Inotify.c:27:8: warning: implicit declaration of function
    ‘inotify_add_watch’ [-Wimplicit-function-declaration]
    wd = inotify_add_watch( fd,
    "/sys/bus/w1/devices/28-000003f1a254/temperature", IN_MODIFY |
    IN_DELETE ); ..
    ..

    Any idea??
    Many thanks

    how are you calling the compiler. You should be using -I (for the
    includes)
    and -L (for the library path)

    something like

    gcc -I/usr/include -L/usr/lib -l somelib source.c -o output.bin

    This is a bad guess for two reasons:

    * GCC already searches in the right places, there is no need to specify
    extra -I or -L options for system headers and libraries.
    * The error isn’t about a #include file or library not being found.
    Adding -I or -L options will not make any difference.

    Looks like your source should have the following among the other
    includes:
    #include <sys/inotify.h>
    Have you run "man inotify" and read its descriptionof the inotify
    APIs?

    #include <linux/inotify.h>

    That will not work. As the man page says, it should be <sys/inotify.h>.

    --
    https://www.greenend.org.uk/rjk/

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From The Natural Philosopher@3:770/3 to Richard Kettlewell on Sat Jul 9 09:57:05 2022
    On 09/07/2022 09:18, Richard Kettlewell wrote:
    * The error isn’t about a #include file or library not being found.
    Adding -I or -L options will not make any difference.

    Indeed. It is usually about an include file not being specified *at
    all*. So calls to external functions are undefined as to type, so
    assumed to be 'int'


    --
    “It is not the truth of Marxism that explains the willingness of intellectuals to believe it, but the power that it confers on
    intellectuals, in their attempts to control the world. And since...it is
    futile to reason someone out of a thing that he was not reasoned into,
    we can conclude that Marxism owes its remarkable power to survive every criticism to the fact that it is not a truth-directed but a
    power-directed system of thought.”
    Sir Roger Scruton

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From zeneca@3:770/3 to All on Sat Jul 9 11:10:49 2022
    Le 9/07/22 à 10:18, Richard Kettlewell a écrit :
    zeneca <pasIci@ailleur.fr> writes:
    Le 8/07/22 à 18:37, Martin Gregorie a écrit :
    On Fri, 08 Jul 2022 18:05:40 +0200, Deloptes wrote:
    zeneca wrote:

    I am trying to compile a small prog with inotify but compilation fail: >>>>>
    Inotify.c:19:8: warning: implicit declaration of function
    ‘q’
    [-Wimplicit-function-declaration]
    fd = inotify_init();
    ^~~~~~~~~~~~
    Inotify.c:27:8: warning: implicit declaration of function
    ‘inotify_add_watch’ [-Wimplicit-function-declaration]
    wd = inotify_add_watch( fd,
    "/sys/bus/w1/devices/28-000003f1a254/temperature", IN_MODIFY |
    IN_DELETE ); ..
    ..

    Any idea??
    Many thanks

    how are you calling the compiler. You should be using -I (for the
    includes)
    and -L (for the library path)

    something like

    gcc -I/usr/include -L/usr/lib -l somelib source.c -o output.bin

    This is a bad guess for two reasons:

    * GCC already searches in the right places, there is no need to specify
    extra -I or -L options for system headers and libraries.
    * The error isn’t about a #include file or library not being found.
    Adding -I or -L options will not make any difference.

    Looks like your source should have the following among the other

    includes:
    #include <sys/inotify.h>
    Have you run "man inotify" and read its descriptionof the inotify
    APIs?

    #include <linux/inotify.h>

    That will not work. As the man page says, it should be <sys/inotify.h>.


    As I said, there is no /usr/include/sys/ directory on Raspberry
    On Centos7.9 there are
    /usr/include/sys/inotify.h AND
    /usr/include/linux/inotify.h


    on Centos7.9 the very same program run with #include <linux/inotify.h>
    but compile fail on raspberry.

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Richard Kettlewell@3:770/3 to zeneca on Sat Jul 9 13:00:08 2022
    zeneca <pasIci@ailleur.fr> writes:
    Le 9/07/22 à 10:18, Richard Kettlewell a écrit :
    That will not work. As the man page says, it should be <sys/inotify.h>.

    As I said, there is no /usr/include/sys/ directory on Raspberry
    On Centos7.9 there are
    /usr/include/sys/inotify.h AND
    /usr/include/linux/inotify.h


    on Centos7.9 the very same program run with #include <linux/inotify.h>
    but compile fail on raspberry.

    You’ve been given the answer. If you don’t like it, that’s your problem.

    --
    https://www.greenend.org.uk/rjk/

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From The Natural Philosopher@3:770/3 to zeneca on Sat Jul 9 13:23:04 2022
    On 09/07/2022 10:10, zeneca wrote:
    Le 9/07/22 à 10:18, Richard Kettlewell a écrit :
    zeneca <pasIci@ailleur.fr> writes:
    Le 8/07/22 à 18:37, Martin Gregorie a écrit :
    On Fri, 08 Jul 2022 18:05:40 +0200, Deloptes wrote:
    zeneca wrote:

    I am trying to compile a small prog with inotify but compilation
    fail:

    Inotify.c:19:8: warning: implicit declaration of function
    ‘q’
    [-Wimplicit-function-declaration]
          fd = inotify_init();
               ^~~~~~~~~~~~
    Inotify.c:27:8: warning: implicit declaration of function
    ‘inotify_add_watch’ [-Wimplicit-function-declaration]
          wd = inotify_add_watch( fd,
    "/sys/bus/w1/devices/28-000003f1a254/temperature", IN_MODIFY |
    IN_DELETE ); ..
    ..

    Any idea??
    Many thanks

    how are you calling the compiler. You should be using -I (for the
    includes)
    and -L (for the library path)

    something like

    gcc -I/usr/include -L/usr/lib -l somelib source.c -o output.bin

    This is a bad guess for two reasons:

    * GCC already searches in the right places, there is no need to specify
       extra -I or -L options for system headers and libraries.
    * The error isn’t about a #include file or library not being found.
       Adding -I or -L options will not make any difference.

    Looks like your source should have the following among the other

    includes:
    #include <sys/inotify.h>
    Have you run "man inotify" and read its descriptionof the inotify
    APIs?

    #include <linux/inotify.h>

    That will not work. As the man page says, it should be <sys/inotify.h>.


    As I said, there is no /usr/include/sys/ directory on Raspberry
    On Centos7.9 there are
    /usr/include/sys/inotify.h  AND
    /usr/include/linux/inotify.h


    on Centos7.9 the very same program run with #include <linux/inotify.h>
    but compile fail on raspberry.

    $find /usr/include -name inotify.h

    /usr/include/linux/inotify.h
    /usr/include/arm-linux-gnueabihf/bits/inotify.h /usr/include/arm-linux-gnueabihf/sys/inotify.h

    On my pi these are 3 different file lengths
    $ ls -l /usr/include/linux/inotify.h
    -rw-r--r-- 1 root root 2914 Mar 31 2018 /usr/include/linux/inotify.h
    $ ls -l /usr/include/arm-linux-gnueabihf/bits/inotify.h
    -rw-r--r-- 1 root root 1079 Feb 6 2019 /usr/include/arm-linux-gnueabihf/bits/inotify.h
    $ ls -l /usr/include/arm-linux-gnueabihf/sys/inotify.h
    -rw-r--r-- 1 root root 3837 Feb 6 2019 /usr/include/arm-linux-gnueabihf/sys/inotify.h


    This suggests that (a) there is an implicit preload of the include path
    /usr/include/arm-linux-gnueabihf/

    and (b) that if <sys/inotify.h> works that is in fact the correct file

    Or (c) that richard and the man page are wrong.


    --
    “Ideas are inherently conservative. They yield not to the attack of
    other ideas but to the massive onslaught of circumstance"

    - John K Galbraith

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Jim Jackson@3:770/3 to Richard Kettlewell on Sat Jul 9 14:32:04 2022
    On 2022-07-09, Richard Kettlewell <invalid@invalid.invalid> wrote:
    zeneca <pasIci@ailleur.fr> writes:
    Le 9/07/22 ?? 10:18, Richard Kettlewell a ??crit??:
    That will not work. As the man page says, it should be <sys/inotify.h>.

    As I said, there is no /usr/include/sys/ directory on Raspberry
    On Centos7.9 there are
    /usr/include/sys/inotify.h AND
    /usr/include/linux/inotify.h


    on Centos7.9 the very same program run with #include <linux/inotify.h>
    but compile fail on raspberry.

    You???ve been given the answer. If you don???t like it, that???s your problem.


    Not very helpfull.

    I think maybe the inotify webpage is wrong on debian based systems.

    On an Intel Debian abased system I have ...

    # cd /usr/include/
    # find . -name inotify.h
    ./linux/inotify.h
    ./x86_64-linux-gnu/sys/inotify.h
    ./x86_64-linux-gnu/bits/inotify.h

    and on a raspberry pi ...

    # cd /usr/include/
    # find . -name inotify.h
    ./arm-linux-gnueabihf/sys/inotify.h
    ./linux/inotify.h

    # find . -name inotify.h -exec grep inotify_init {} /dev/null \; ./arm-linux-gnueabihf/sys/inotify.h:/* Flags for the parameter of inotify_init1. */
    ./arm-linux-gnueabihf/sys/inotify.h:extern int inotify_init (void) __THROW; ./arm-linux-gnueabihf/sys/inotify.h:extern int inotify_init1 (int __flags) __THROW;


    I believe that the arch. specific sys includes are default. So you
    should only need ...

    #include <inotify.h>

    HTH
    Jim

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Richard Kettlewell@3:770/3 to Jim Jackson on Sun Jul 10 12:07:13 2022
    Jim Jackson <jj@franjam.org.uk> writes:
    On 2022-07-09, Richard Kettlewell <invalid@invalid.invalid> wrote:
    zeneca <pasIci@ailleur.fr> writes:
    Le 9/07/22 ?? 10:18, Richard Kettlewell a ??crit??:
    That will not work. As the man page says, it should be <sys/inotify.h>. >>>
    As I said, there is no /usr/include/sys/ directory on Raspberry
    On Centos7.9 there are
    /usr/include/sys/inotify.h AND
    /usr/include/linux/inotify.h


    on Centos7.9 the very same program run with #include <linux/inotify.h>
    but compile fail on raspberry.

    You’ve been given the answer. If you don’t like it, that’s your problem.

    Not very helpfull.

    If people don’t like being giventhe right answer then they cannot be
    helped.

    I think maybe the inotify webpage is wrong on debian based systems.

    It is not wrong.

    On an Intel Debian abased system I have ...

    # cd /usr/include/
    # find . -name inotify.h
    ./linux/inotify.h
    ./x86_64-linux-gnu/sys/inotify.h
    ./x86_64-linux-gnu/bits/inotify.h

    and on a raspberry pi ...

    # cd /usr/include/
    # find . -name inotify.h
    ./arm-linux-gnueabihf/sys/inotify.h
    ./linux/inotify.h

    # find . -name inotify.h -exec grep inotify_init {} /dev/null \; ./arm-linux-gnueabihf/sys/inotify.h:/* Flags for the parameter of inotify_init1. */
    ./arm-linux-gnueabihf/sys/inotify.h:extern int inotify_init (void) __THROW; ./arm-linux-gnueabihf/sys/inotify.h:extern int inotify_init1 (int __flags) __THROW;


    I believe that the arch. specific sys includes are default. So you
    should only need ...

    #include <inotify.h>

    That will also not work. I guess you didn’t bother to try it.

    --
    https://www.greenend.org.uk/rjk/

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Tauno Voipio@3:770/3 to zeneca on Sun Jul 10 19:35:58 2022
    On 8.7.22 17.10, zeneca wrote:
    I am trying to compile a small prog with inotify but compilation fail:

    Inotify.c:19:8: warning: implicit declaration of function ‘inotify_init’ [-Wimplicit-function-declaration]
       fd = inotify_init();
            ^~~~~~~~~~~~
    Inotify.c:27:8: warning: implicit declaration of function ‘inotify_add_watch’ [-Wimplicit-function-declaration]
       wd = inotify_add_watch( fd, "/sys/bus/w1/devices/28-000003f1a254/temperature", IN_MODIFY | IN_DELETE ); ..
    ..

    Any idea??
    Many thanks

    I made a minimal example program with inotify() and compiled
    it on my Pi3 (running Raspbian 10) without any complaints.
    Please do not run the executable, it dies not do anything sensible.

    --- clip clip ---

    #include <sys/inotify.h>
    #include <stdlib.h>

    int main(void)
    {
    int fd, fd1, wd;

    fd = inotify_init();
    fd1 = inotify_init1(IN_NONBLOCK);
    wd = inotify_add_watch(fd, "nosuchfile", IN_OPEN | IN_CLOSE);

    return EXIT_SUCCESS;
    }

    --- clip clip ---

    If you are compiling on another computer than the target Raspberry,
    please make sure that the compiler does not use the header files or
    dynamic library files of the host computer.

    --

    -TV

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)