Skip to content

Improving documentation on using ./configure #99

@MarcoConsiglio

Description

@MarcoConsiglio

Problem description
While using ./configure command i stumbled on a problem reported in stdout

checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/home/vagrant/code/php-sweph':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

What made me puzzled was
configure: error: cannot run C compiled programs.

Solution
Luckily I solved the problem quickly and easily thanks to this stackoverflow answer.

I searched for the compiler location with which gcc.
/usr/bin/gcc

So I set the following environment variables

export PATH=/usr/bin/gcc:$PATH
export LD_LIBRARY_PATH=/usr/bin/gcc:$LD_LIBRARY_PATH

I searched in the config.log file what the CPU architecture was (because it is a virtual machine not configured by me), found this information in uname -m = x86_64.

Finally run the ./configure command with these options
./configure --prefix=/usr/bin/gcc --host=x86_64

The succesful output was

checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for x86_64-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for x86_64-cc... no
checking for x86_64-gcc... no
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether cc accepts -g... yes
checking for cc option to enable C11 features... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking for system library directory... lib
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-none
checking target system type... x86_64-pc-none
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php/20230831 -I/usr/include/php/20230831/main -I/usr/include/php/20230831/TSRM -I/usr/include/php/20230831/Zend -I/usr/include/php/20230831/ext -I/usr/include/php/20230831/ext/date/lib
checking for PHP extension directory... /usr/lib/php/20230831
checking for PHP installed headers prefix... /usr/include/php/20230831
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... gawk
checking for libswe support... yes, shared
php_swephp: 
Building libswe.a
cc       -c -O2 -Wall -fPIC    swedate.c     
cc       -c -O2 -Wall -fPIC    swehouse.c     
cc       -c -O2 -Wall -fPIC    swejpl.c     
cc       -c -O2 -Wall -fPIC    swemmoon.c     
cc       -c -O2 -Wall -fPIC    swemplan.c     
cc       -c -O2 -Wall -fPIC    sweph.c     
cc       -c -O2 -Wall -fPIC    swephlib.c     
cc       -c -O2 -Wall -fPIC    swecl.c     
cc       -c -O2 -Wall -fPIC    swehel.c     
ar r libswe.a   swedate.o swehouse.o swejpl.o swemmoon.o swemplan.o sweph.o swephlib.o swecl.o swehel.o
ar: creating libswe.a
libswe.a found in sweph/src
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... no
checking for x86_64-dumpbin... no
checking for x86_64-link... no
checking for dumpbin... no
checking for link... link -dump
checking the name lister (nm) interface... BSD nm
checking whether ln -s works... no, using cp -pR
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-none format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for x86_64-objdump... no
checking for objdump... objdump
checking how to recognize dependent libraries... unknown
checking for x86_64-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for x86_64-ar... no
checking for ar... ar
checking for archiver @FILE support... @
checking for x86_64-strip... no
checking for strip... strip
checking for x86_64-ranlib... no
checking for ranlib... ranlib
checking for gawk... (cached) gawk
checking command to parse nm output from cc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for x86_64-mt... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... no
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... no
checking whether to build shared libraries... no
checking whether to build static libraries... yes
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands

Consideration
It can be useful to have a few more lines in the documentation for those, like me, who are approaching the compilation of a PHP extension for the first time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions