OpenWrt Forum Archive

Topic: undefined reference to `__ctype_b_loc'

The content of this topic has been archived on 30 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I have been trying, so far unsuccessfully, to compile gphoto2.  I have all of the glitches chased down and fixed, and all of the deps compiling and building, except for gphoto2 itself.

The compile fails in the last link with undefined reference to `__ctype_b_loc'.  A bit of googling shows thi sto be a libc/glibc feature (?)...

I am not at all familiar with uClib so I hope someone has run across this before....  The only useful link I can find is this:

http://sourceforge.net/tracker/index.ph … tid=101107

which points to a glibc issue....

Error dump follows...

Thanks for any assistance,

--Yan



/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/bin/mipsel-linux-uclibc-gcc -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/libusb-0.1.12 -Wall -g -o .libs/gphoto2 gphoto2-actions.o gphoto2-foreach.o gphoto2-gp-params.o gphoto2-main.o gphoto2-version.o gphoto2-range.o gphoto2-shell.o  -L/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/libusb-0.1.12/.libs -L/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/libexif-0.6.13/libexif/.libs -L/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/libgphoto2-2.1.99/libgphoto2/.libs -L/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/lib -L/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/lib -lltdl -lpthread -L/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/libexif-0.6.13/libexif/.libs/ /home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/libexif-0.6.13/libexif/.libs/libexif.so -L/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/libgphoto2-2.1.99/libgphoto2/.libs/ -L/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/libgphoto2-2.1.99/libgphoto2_port/libgphoto2_port/.libs/ /home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/libgphoto2-2.1.99/libgphoto2/.libs/libgphoto2.so /home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/libgphoto2-2.1.99/libgphoto2_port/libgphoto2_port/.libs//libgphoto2_port.so -L/usr/ -lpopt -Wl,--rpath -Wl,/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/libexif-0.6.13/ipkg-install/usr/lib -Wl,--rpath -Wl,/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/libgphoto2-2.1.99/ipkg-install/usr/lib
gphoto2-main.o: In function `get_path_for_file':
/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/gphoto2-2.1.99/gphoto2/main.c:589: undefined reference to `__ctype_b_loc'
gphoto2-shell.o: In function `shell_arg_count':
/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/gphoto2-2.1.99/gphoto2/shell.c:140: undefined reference to `__ctype_b_loc'
/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/gphoto2-2.1.99/gphoto2/shell.c:146: undefined reference to `__ctype_b_loc'
gphoto2-shell.o: In function `shell_arg':
/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/gphoto2-2.1.99/gphoto2/shell.c:202: undefined reference to `__ctype_b_loc'
/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/gphoto2-2.1.99/gphoto2/shell.c:215: undefined reference to `__ctype_b_loc'
collect2: ld returned 1 exit status
make[4]: *** [gphoto2] Error 1
make[4]: Leaving directory `/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/gphoto2-2.1.99/gphoto2'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/gphoto2-2.1.99'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/gphoto2-2.1.99'
make[1]: *** [/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/build_mipsel/gphoto2-2.1.99/.built] Error 2
make[1]: Leaving directory `/home/nfs/yan/whiterussian/OpenWrt-SDK-Linux-i686-1/package/200-gphoto2'
make: *** [200-gphoto2-compile] Error 2

OK, I've tracked this down to an issue with the way .h files are included....  It appears that the OpenWrt SDK will include .h files from /usr/include when used with the Makefiles from the BuildingPackagesHowTo, which seems to be causing the problem.....

But using -nostdinc causes all sorts of problems with missing definitions and .h files not found....

Even specifying -I$(STAGING_DIR)/include (and every other dir in the toolchain that includes .h files) doesn't clear that up....

So.... Has anyone successfully used -nostdinc?  If so, what -I options did you have to provide?

At the moment it can't find stdarg.h....  But I'm sure there are others....

I can provide voluminous log files but I am convinced this is something very simple that I just can't get

Thanks,

--Yan

OK got it figured out....

The OpenWrt SDK has two different versions of stddef.h.

./staging_dir_mipsel/lib/gcc/mipsel-linux-uclibc/3.4.4/include/stddef.h
./staging_dir_mipsel/include/linux/stddef.h

The stdef.h in the include/linux dir is apparently non-functional; it appears to be a stub.  The "real" stddef.h is in lib/gcc/mipsel-linux-uclibc/3.4.4/include.

The makefile has to include the dirs in the right order:

CFLAGS="$(TARGET_CFLAGS) -I. -I$(STAGING_DIR)/lib/gcc/mipsel-linux-uclibc/3.4.4/include/ -I$(STAGING_DIR)/include -I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include/linux/ -nostdinc "

and then everything will work.....

I do not know if this is by intent or if this is a bug in the SDK build process.  If it is by intent please let me know and I will make the appropriate entry in the wiki.

--Yan

Actually, if you use the includes in the order I gave, the problem goes away...  With no code needed.  For some reason the toolchain sticks the needed std*.h files into a location that is completely hidden.  There is even a nice README in that lib/gcc/mipsel-linux-uclibc/3.4.4/include/ directory that tells you what those files are for....

Once I test the code I built to make sure it works I will document this in the wiki....

--Yan

Thanks, this is a really good idea.

The discussion might have continued from here.