Home > Blockchain >  cannot find the nanosleep function when cross compile configure
cannot find the nanosleep function when cross compile configure

Time:05-25

I use toolchain from here, then extract to gcc11_arm_armv7_none_gnueabihf,

below is command:

export ASFLAGS='-march=armv7-a -fPIC -fstack-protector -Wall -fno-omit-frame-pointer --sysroot=gcc11_arm_armv7_none_gnueabihf/arm-none-linux-gnueabihf/libc -no-canonical-prefixes  -Wno-builtin-macro-redefined -D__DATE__=redacted -D__TIMESTAMP__=redacted -D__TIME__=redacted -g3'
export CFLAGS='-march=armv7-a -fPIC -fstack-protector -Wall -fno-omit-frame-pointer --sysroot=gcc11_arm_armv7_none_gnueabihf/arm-none-linux-gnueabihf/libc -std=c99 -no-canonical-prefixes  -Wno-builtin-macro-redefined -D__DATE__=redacted -D__TIMESTAMP__=redacted -D__TIME__=redacted -g3'
export CXXFLAGS='-march=armv7-a -fPIC -fstack-protector -Wall -fno-omit-frame-pointer --sysroot=gcc11_arm_armv7_none_gnueabihf/arm-none-linux-gnueabihf/libc -std=c  11 -no-canonical-prefixes  -Wno-builtin-macro-redefined -D__DATE__=redacted -D__TIMESTAMP__=redacted -D__TIME__=redacted -g3'
export LDFLAGS='-lstdc   -Wl,-z,relro,-z,now -pass-exit-codes -lm -Wall --sysroot=gcc11_arm_armv7_none_gnueabihf/arm-none-linux-gnueabihf/libc -lpthread'

export AR=gcc11_arm_armv7_none_gnueabihf/bin/arm-none-linux-gnueabihf-gcc-ar
export CC=gcc11_arm_armv7_none_gnueabihf/bin/arm-none-linux-gnueabihf-gcc
export CXX=gcc11_arm_armv7_none_gnueabihf/bin/arm-none-linux-gnueabihf-gcc
export LD=gcc11_arm_armv7_none_gnueabihf/bin/arm-none-linux-gnueabihf-ld
./configure
......
......
checking if nanosleep requires any libraries... configure: error: cannot find the nanosleep function

I can find nanosleep function in gcc11_arm_armv7_none_gnueabihf/arm-none-linux-gnueabihf/libc/usr/include/time.h, but it's a extern declaration, do I need pass something to compiler to let it know where to find nanosleep definition?

CodePudding user response:

nanosleep requires _POSIX_C_SOURCE >= 199309L feature macro as specified by man nanosleep.

Try adding #define _POSIX_C_SOURCE 199309L before #include <time.h>.

  • Related