Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails with devices.c:(.text+0x520): undefined reference to major'` #4

Open
paulmenzel opened this issue Dec 8, 2020 · 0 comments

Comments

@paulmenzel
Copy link

Under Debian sid/unstable with gcc (Debian 10.2.1-1) 10.2.1 20201207, make fails with error below,

$ ./autogen.sh
$ ./configure
$ LANG=C make -j4
make  all-am
make[1]: Entering directory '/home/joey/src/tiny-initramfs'
  CC       tiny_initramfs-tiny_initramfs.o
  CC       tiny_initramfs-io.o
  CC       tiny_initramfs-fstab.o
  CC       tiny_initramfs-mount.o
  CC       tiny_initramfs-log.o
  CC       tiny_initramfs-devices.o
  CC       tiny_initramfs-util.o
devices.c: In function 'scan_devices':
devices.c:290:15: warning: implicit declaration of function 'major' [-Wimplicit-function-declaration]
  290 |           if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) {
      |               ^~~~~
devices.c:290:33: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
  290 |           if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) {
      |                                 ^~
devices.c:290:43: warning: implicit declaration of function 'minor' [-Wimplicit-function-declaration]
  290 |           if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) {
      |                                           ^~~~~
devices.c:290:61: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
  290 |           if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) {
      |                                                             ^~
  CCLD     tiny_initramfs
/usr/bin/ld: tiny_initramfs-devices.o: in function `scan_devices':
devices.c:(.text+0x520): undefined reference to `major'
/usr/bin/ld: devices.c:(.text+0x539): undefined reference to `minor'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:398: tiny_initramfs] Error 1
make[1]: Leaving directory '/home/joey/src/tiny-initramfs'
make: *** [Makefile:301: all] Error 2
paulmenzel added a commit to paulmenzel/tiny-initramfs that referenced this issue Dec 9, 2020
Building the source on Debian sid/unstable with libc6 2.31-5 and UUID support
(default) results in the build failure below.

      CC       tiny_initramfs-devices.o
      CC       tiny_initramfs-util.o
    devices.c: In function 'scan_devices':
    devices.c:290:15: warning: implicit declaration of function 'major' [-Wimplicit-function-declaration]
      290 |           if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) {
          |               ^~~~~
    devices.c:290:33: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
      290 |           if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) {
          |                                 ^~
    devices.c:290:43: warning: implicit declaration of function 'minor' [-Wimplicit-function-declaration]
      290 |           if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) {
          |                                           ^~~~~
    devices.c:290:61: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
      290 |           if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) {
          |                                                             ^~
      CCLD     tiny_initramfs
    /usr/bin/ld: tiny_initramfs-devices.o: in function `scan_devices':
    devices.c:(.text+0x520): undefined reference to `major'
    /usr/bin/ld: devices.c:(.text+0x539): undefined reference to `minor'
    collect2: error: ld returned 1 exit status
    make[1]: *** [Makefile:398: tiny_initramfs] Error 1

Explicitly include the header `sys/sysmacros.h`, where `major()` and `minor()`
are defined.

Resolves: chris-se#4
paulmenzel added a commit to paulmenzel/tiny-initramfs that referenced this issue Dec 9, 2020
Building the source on Debian sid/unstable with libc6 2.31-5 and UUID support
(default) results in the build failure below.

      CC       tiny_initramfs-devices.o
      CC       tiny_initramfs-util.o
    devices.c: In function 'scan_devices':
    devices.c:290:15: warning: implicit declaration of function 'major' [-Wimplicit-function-declaration]
      290 |           if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) {
          |               ^~~~~
    devices.c:290:33: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
      290 |           if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) {
          |                                 ^~
    devices.c:290:43: warning: implicit declaration of function 'minor' [-Wimplicit-function-declaration]
      290 |           if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) {
          |                                           ^~~~~
    devices.c:290:61: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
      290 |           if (major(st.st_rdev) == maj && minor(st.st_rdev) == min) {
          |                                                             ^~
      CCLD     tiny_initramfs
    /usr/bin/ld: tiny_initramfs-devices.o: in function `scan_devices':
    devices.c:(.text+0x520): undefined reference to `major'
    /usr/bin/ld: devices.c:(.text+0x539): undefined reference to `minor'
    collect2: error: ld returned 1 exit status
    make[1]: *** [Makefile:398: tiny_initramfs] Error 1

Explicitly include the header `sys/sysmacros.h`, where `major()` and `minor()`
are defined.

Resolves: chris-se#4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant