Skip to content

Instantly share code, notes, and snippets.

@SemenMartynov
Created July 24, 2024 15:30
Show Gist options
  • Save SemenMartynov/2dd0b72e58882a3eb226c6a3ad7b2d53 to your computer and use it in GitHub Desktop.
Save SemenMartynov/2dd0b72e58882a3eb226c6a3ad7b2d53 to your computer and use it in GitHub Desktop.
How to fix `implicit declaration of function ‘file_query’ [-Wimplicit-function-declaration]` for the old boost 1.58.0 and modern gcc

I use modern gcc

smart@thinkpad$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.1.1 20240720 (GCC) 

Let's try to build the old boost 1.58.0

smart@thinkpad$ ./bootstrap.sh
Building Boost.Build engine with toolset gcc... 
Failed to build Boost.Build build engine
Consult 'bootstrap.log' for more details

This does not work due to changes in the default language standard.

smart@thinkpad$ cat ./bootstrap.log 
###
### Using 'gcc' toolset.
###
rm -rf bootstrap
mkdir bootstrap
gcc -o bootstrap/jam0 command.c compile.c constants.c debug.c execcmd.c frames.c function.c glob.c hash.c hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c object.c option.c output.c parse.c pathsys.c regexp.c rules.c scan.c search.c subst.c timestamp.c variable.c modules.c strings.c filesys.c builtins.c class.c cwd.c native.c md5.c w32_getreg.c modules/set.c modules/path.c modules/regex.c modules/property-set.c modules/sequence.c modules/order.c execunix.c fileunix.c pathunix.c
modules/path.c: In function ‘path_exists’:
modules/path.c:16:12: error: implicit declaration of function ‘file_query’ [-Wimplicit-function-declaration]
   16 |     return file_query( list_front( lol_get( frame->args, 0 ) ) ) ?
      |            ^~~~~~~~~~

Let's fix it

smart@thinkpad$ sed -i '133s/=\(.*\)/="gcc -Wno-implicit-function-declaration"/' tools/build/src/engine/build.sh
smart@thinkpad$ sed -i '637s/^\(.\{13\}\)/\1 -Wno-implicit-function-declaration/' tools/build/src/engine/build.jam

Now we good

Building Boost.Build engine with toolset gcc... tools/build/src/engine/bin.linuxx86_64/b2
Unicode/ICU support for Boost.Regex?... /usr
Generating Boost.Build configuration in project-config.jam...

Bootstrapping is done. To build, run:

    ./b2
    
To adjust configuration, edit 'project-config.jam'.
Further information:

   - Command line help:
     ./b2 --help
     
   - Getting started guide: 
     http://www.boost.org/more/getting_started/unix-variants.html
     
   - Boost.Build documentation:
     http://www.boost.org/build/doc/html/index.html
@SemenMartynov
Copy link
Author

For the boost 1.65.1:

sed -i '152s/=\(.*\)/="gcc -Wno-implicit-function-declaration"/' tools/build/src/engine/build.sh
sed -i '688s/^\(.\{13\}\)/\1 -Wno-implicit-function-declaration/' tools/build/src/engine/build.jam

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment