gorge_alan_sw
Posts: 50
Joined: Tue Nov 27, 2012 12:54 pm

bug in raspbian -- error: 'AT_SYMLINK_NOFOLLOW' undeclared

Wed May 15, 2013 5:28 am

Hi,

I am using Raspbian distribution, for RPi.

I am compiling a package on Raspbian. Where i use to get the following error.
error: 'AT_SYMLINK_NOFOLLOW' undeclared

this constant is defined in following file :---
http://lxr.free-electrons.com/source/in ... cntl.h#L44

Is there some bug with Raspbian :?:

Code: Select all

[ 37%] Building C object Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/archive_read_disk_posix.c.o
/home/ignite/rpi_package_sb2/cmake-2.8.10.2/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c: In function 'tree_current_lstat':
/home/ignite/rpi_package_sb2/cmake-2.8.10.2/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c:2139:7: error: 'AT_SYMLINK_NOFOLLOW' undeclared (first use in this function)
/home/ignite/rpi_package_sb2/cmake-2.8.10.2/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c:2139:7: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/archive_read_disk_posix.c.o] Error 1
make[1]: *** [Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/all] Error 2
make: *** [all] Error 2

Please suggest.

//Allan

User avatar
jojopi
Posts: 3354
Joined: Tue Oct 11, 2011 8:38 pm

Re: bug in raspbian -- error: 'AT_SYMLINK_NOFOLLOW' undeclar

Thu May 16, 2013 1:22 am

Cannot reproduce. cmake-2.8.10.2 compiles correctly out of the box for me on Raspbian. You have not indicated whether you configured cmake unusually or if it was compiling as part of some other package. Without knowing exactly what you downloaded and what you typed, it is hard to speculate whether your results were unexpected.

You should be able to rule out any problem with the header files in your image with a simple test program:

Code: Select all

#include <stdio.h>
#include <fcntl.h>

int main()
{
  printf("%d\n", AT_SYMLINK_NOFOLLOW);
  return 0;
}
If you are not familiar with troubleshooting compile errors then using the binary package manager, apt-get, is recommended. cmake at least is in the Raspbian repositories, and installing it is much faster than compiling from source.

gorge_alan_sw
Posts: 50
Joined: Tue Nov 27, 2012 12:54 pm

Re: bug in raspbian -- error: 'AT_SYMLINK_NOFOLLOW' undeclar

Thu May 16, 2013 8:34 am

Thanks for replying :--
Cannot reproduce. cmake-2.8.10.2 compiles correctly out of the box for me on Raspbian.
I have only configured ./configure --prefix=/usr & then make.

I compiled following program :----

Code: Select all

#define _ATFILE_SOURCE
#include <sys/stat.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
    printf("%d\n", AT_SYMLINK_NOFOLLOW);
    return 0;
}
Error i got :------

Code: Select all

$ gcc -c fcnt_file.c
fcnt_file.c: In function 'main':
fcnt_file.c:6:20: error: 'AT_SYMLINK_NOFOLLOW' undeclared (first use in this function)
fcnt_file.c:6:20: note: each undeclared identifier is reported only once for each function it appears in
ignite@ignite:~/rpi_package_sb2/test/4$ gedit /var/local/rpi/rfs_raspbian/home/pi/.bashrc
ignite@ignite:~/rpi_package_sb2/test/4$


/usr/include/fcntl.h ----------> contains file ---> # include <bits/stat.h>
stat.h ----> file is in following location -----> /usr/include/arm-linux-gnueabihf/bits/stat.h

stat.h file contains this Macro ----> AT_SYMLINK_NOFOLLOW

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4257
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: bug in raspbian -- error: 'AT_SYMLINK_NOFOLLOW' undeclar

Thu May 16, 2013 9:09 am

If the macro is in bits/stat.h, why did you include sys/stat.h ?

User avatar
jojopi
Posts: 3354
Joined: Tue Oct 11, 2011 8:38 pm

Re: bug in raspbian -- error: 'AT_SYMLINK_NOFOLLOW' undeclar

Thu May 16, 2013 9:11 am

Both "man 2 fstatat" and POSIX say that the AT_* macros are defined in <fcntl.h>.

gorge_alan_sw
Posts: 50
Joined: Tue Nov 27, 2012 12:54 pm

Re: bug in raspbian -- error: 'AT_SYMLINK_NOFOLLOW' undeclar

Thu May 16, 2013 10:31 am

Both "man 2 fstatat" and POSIX say that the AT_* macros are defined in <fcntl.h>.
But if you will see RPI wheezy image it is like what i have mentioned .

/usr/include/fcntl.h ----------> contains file ---> # include <bits/stat.h>
stat.h ----> file is in following location -----> /usr/include/arm-linux-gnueabihf/bits/stat.h
stat.h file contains this Macro ----> AT_SYMLINK_NOFOLLOW

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: bug in raspbian -- error: 'AT_SYMLINK_NOFOLLOW' undeclar

Thu May 16, 2013 10:54 am

gorge_alan_sw wrote:
Both "man 2 fstatat" and POSIX say that the AT_* macros are defined in <fcntl.h>.
But if you will see RPI wheezy image it is like what i have mentioned .

/usr/include/fcntl.h ----------> contains file ---> # include <bits/stat.h>
stat.h ----> file is in following location -----> /usr/include/arm-linux-gnueabihf/bits/stat.h
stat.h file contains this Macro ----> AT_SYMLINK_NOFOLLOW
Here's what I see on Raspian:

Code: Select all

pi@raspberrypi /usr/include $ uname -a
Linux raspberrypi 3.6.11+ #446 PREEMPT Fri May 10 20:17:25 BST 2013 armv6l Ginux
pi@raspberrypi /usr/include $ sudo find . -type f -name "*.h" -exec grep AT_SYMLINK_NOFOLLOW {} \; -print
# define AT_SYMLINK_NOFOLLOW    0x100   /* Do not follow symbolic links.  */
./arm-linux-gnueabihf/bits/fcntl.h
#define AT_SYMLINK_NOFOLLOW     0x100   /* Do not follow symbolic links.  */
./linux/fcntl.h

gorge_alan_sw
Posts: 50
Joined: Tue Nov 27, 2012 12:54 pm

Re: bug in raspbian -- error: 'AT_SYMLINK_NOFOLLOW' undeclar

Thu May 16, 2013 11:54 am

Both the folder are inside /usr :--

Code: Select all

usr/arm-linux-gnueabihf/bits/
usr/linux/
/usr/include is the standard path to search for the include directories.
Does compiler search for directory & subdirectories inside /usr/include also :?:

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: bug in raspbian -- error: 'AT_SYMLINK_NOFOLLOW' undeclar

Thu May 16, 2013 12:36 pm

gorge_alan_sw wrote:Both the folder are inside /usr :--

Code: Select all

usr/arm-linux-gnueabihf/bits/
usr/linux/
/usr/include is the standard path to search for the include directories.
Does compiler search for directory & subdirectories inside /usr/include also :?:
I believe so. See http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html
Add a -v option to your compile flags and you should see the directories being search for #includes.

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4257
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: bug in raspbian -- error: 'AT_SYMLINK_NOFOLLOW' undeclar

Thu May 16, 2013 12:37 pm

gorge_alan_sw wrote:Both the folder are inside /usr :--

Code: Select all

usr/arm-linux-gnueabihf/bits/
usr/linux/
fbutler wrote:/usr/include ... ./arm-linux-gnueabihf/bits/fcntl.h
The files are in /usr/include/arm-linux-gnueabihf/bits/ and /usr/include/linux.

gorge_alan_sw
Posts: 50
Joined: Tue Nov 27, 2012 12:54 pm

Re: bug in raspbian -- error: 'AT_SYMLINK_NOFOLLOW' undeclar

Thu May 16, 2013 1:43 pm

The files are in /usr/include/arm-linux-gnueabihf/bits/ and /usr/include/linux.
yes

i am getting same error ...

My makefile :---

Code: Select all

CXX         = g++
CC          = gcc

OBJS		= fcnt_file.o

CFLAGS_TEMP = -v -I/usr/include/arm-linux-gnueabihf/sys/

all:		fcnt_file


#http://darkautism.blogspot.in/2010/10/undefined-reference-to-compctxfree.html
widget:		fcnt_file.o
		$(CXX)  -o widget widget.o 
#$(LIBRARY_TO_LINK)

widget.o :%.o: %.c
		$(CXX) -c $(CFLAGS_TEMP) $< -o $@

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4257
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: bug in raspbian -- error: 'AT_SYMLINK_NOFOLLOW' undeclar

Thu May 16, 2013 3:20 pm

gorge_alan_sw wrote:

Code: Select all

CFLAGS_TEMP = -v -I/usr/include/arm-linux-gnueabihf/sys/
You are making the same mistake again. The file is in the directory bits, yet you are including the directory sys. Unless you are doing that to include a different file, you are including the wrong directory.

And your makefile has no instructions for making fcnt_file, so it will use the default rules, and none of the rules you have in the file. That probably includes not using the CFLAGS_TEMP macro at all. The last rule looks like you tried to make it generic, but I think it is invalid and you need to remove the "widget.o:" from the beginning.

User avatar
jojopi
Posts: 3354
Joined: Tue Oct 11, 2011 8:38 pm

Re: bug in raspbian -- error: 'AT_SYMLINK_NOFOLLOW' undeclar

Thu May 16, 2013 3:26 pm

gorge_alan_sw wrote:CFLAGS_TEMP = -v -I/usr/include/arm-linux-gnueabihf/sys/
Does the correct version of the test program fail to compile? If so, your image is broken and you need to replace it or reinstall the relevant packages.

Otherwise, you just need to fix the thing that you are actually compiling to include the correct headers.

Either way, you should not need to mess with the include paths, or include, or know about, the underlying headers of your implementation such as bits/*.h. Just include the headers that the documentation tells you to.

Return to “Raspberry Pi OS”