-3

Suddenly, "make" has stopped working: did not generate *.so php extension;

gcc has stopped working: did not find header files;

Visual studio code started showing problems: headers missing.

I have reinstalled: glibc, libc6-dev, build-essentials, gcc-multilib, and g++-multilib.

I have reinstalled Visual Studio Code for Linux Mint.

I have added the paths to configuration.json of Visual Studio ( settings-> search for c_cpp_confiuration.json or similar, or under settings-> c/c++ extensions ->configuration file )

{ 
"window.zoomLevel": -3, 
"workbench.colorTheme": "Visual Studio Light - C++", 
"editor.minimap.enabled": false, 
"files.autoSave": "afterDelay", 
"C_Cpp.default.browse.path": [], 
"C_Cpp.default.compilerPath": "", 
"C_Cpp.default.customConfigurationVariables": {}, 
"C_Cpp.default.defines": [], 
"C_Cpp.default.includePath": [ "/usr/lib/gcc/x86_64-linux-gnu/9/include", "/usr/include", "usr/local/include", "/usr/include/php/20190902", "/usr/include/php/20190902/main", "/usr/include/php/20190902/Zend", "/usr/include/php/20190902/TSRM", "${workspaceRoot}", "$(VC_IncludePath)", "$(UniversalCRT_IncludePath)" ]
}

I have added the environmental variable C_INCLUDE_PATH to

#/etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/drb/lampstack-7.4.11-0/.symfony/bin:/drb/lampstack-7.4.11-0/php/bin:";
C_INCLUDE_PATH="/usr/lib/gcc/x86_64-linux-gnu/9/include:/usr/include:usr/local/include:/usr/include/php/20190902:/usr/include/php/20190902/main:/usr/include/php/20190902/Zend:/usr/include/php/20190902/TSRM:"

I have rebooted the computer.

Visual Studio does not show problems. But make does not work ( does not show any errors, but does not produce php-extension.lo and *.la), sudo make install does not work ( does not show any errors, but does not produce php-extension.so ) and gcc can not find header files.

made a simple shell script to set C_INCLUDE_PATH from project folder

#env.sh
#!/bin/bash

C_INCLUDE_PATH="/usr/lib/gcc/x86_64-linux-gnu/9/include:/usr/include:usr/local/include:/usr/include/php/20190902:/usr/include/php/20190902/main:/usr/include/php/20190902/Zend:/usr/include/php/20190902/TSRM:"
export C_INCLUDE_PATH

CPATH="/usr/lib/gcc/x86_64-linux-gnu/9/include:/usr/include:usr/local/include:/usr/include/php/20190902:/usr/include/php/20190902/main:/usr/include/php/20190902/Zend:/usr/include/php/20190902/TSRM:"
export CPATH

echo "set C_INCLUDE_PATH to"
printenv C_INCLUDE_PATH

but make does not work and gcc does not find headers.

Trying to set from command line $ gcc -I "usr/include/php/201990902:/usr/include/php/20190902/main" tsub76.c

gives the same fatal error that header does not exist. Checking folder, the header exists as /usr/include/php/20190902/main/php.h

Where are the configuration files of gcc and make located to to set include path for headers ?

Gintare Statkute
  • 677
  • 2
  • 8
  • 18
  • 2
    the PATH variable is ment to lookup binaries/scripts not sources – hetepeperfan Apr 29 '21 at 09:29
  • Where is located the file keeping information about included header paths ? – Gintare Statkute Apr 29 '21 at 16:15
  • Did you **read the documentation of [GCC](http://gcc.gnu.org/) and of [GNU make](https://www.gnu.org/software/make/)** - both are online! You could use the [GNU emacs](https://www.gnu.org/software/emacs/) editor, and download then study for inspiration the source code of GNU make and of [GNU bash](https://www.gnu.org/software/bash/) – Basile Starynkevitch Apr 29 '21 at 16:18
  • You could also (after having read documentation) download the source code, compile and use [remake](http://bashdb.sourceforge.net/remake/) if that is allowed to you. But **GNU make works as documented** and since it is free software, you are allowed to download it, study its source code, and improve it – Basile Starynkevitch Apr 29 '21 at 16:22
  • I don't know much Visual Studio Code, but I do recommend reading [its documentation](https://code.visualstudio.com/docs) before using it. You could also read [*Advanced Linux Programming*](https://mentorembedded.github.io/advancedlinuxprogramming/) and [syscalls(2)](https://man7.org/linux/man-pages/man2/syscalls.2.html) – Basile Starynkevitch Apr 29 '21 at 16:24
  • I was using Visual Studio, gcc and make the last 3 months daily. It has stopped working yesterday, was showing problems about headers. Adding paths to settings.json has helped to remove Visual Studio problems, but gcc and make does not work. I am wandering where is the configuration file of these tools (gcc and make), that i could set the paths ? – Gintare Statkute Apr 29 '21 at 17:10
  • You should expect `gcc` and `make` to behave deterministically. And both being open source, you are allowed to download their source code, study it, and improve it. Both software are documented, and their documentation states how to configure them. **Did you read the documentation?** If not, why? You could also use [strace(1)](https://man7.org/linux/man-pages/man1/strace.1.html) to understand better what `make` and `gcc` are doing – Basile Starynkevitch Apr 29 '21 at 17:26
  • Your claim "make does not work" has no precise meaning without some [mre] and your question does not have any. Your question needs to have some C code (with a `main`). On all my Linux computers (3 at home, one at office), `make` works as documented! – Basile Starynkevitch Apr 29 '21 at 17:29
  • Indeed [GNU make](https://www.gnu.org/software/make/) could be buggy (and not behaving as documented), but since it is [free software](https://www.gnu.org/philosophy/free-sw.en.html) **you are allowed to download and improve `make`** and you could use `remake` to debug your `Makefile`-s. [GCC](http://gcc.gnu.org/) is also free software, behaving as documented, and you are allowed to improve it. See https://linuxfromscratch.org/ – Basile Starynkevitch Apr 29 '21 at 17:32
  • Dear Basile, I do not agree, with the words "Your claim 'make does not work' has no precise meaning without some minimal reproducible example. ". Any basic programmer can understand what it means that gcc does not find headers, or make does not produce *.so extension. – Gintare Statkute Apr 29 '21 at 17:41
  • I contributed to GCC ten years ago. I am programming since 1974. And your question still lacks a good [mre] with a C code containing a `main` function. At last `gcc -I "usr/include/php/201990902:/usr/include/php/20190902/main"` is documented to not do what you want. – Basile Starynkevitch Apr 29 '21 at 17:41
  • The headers are those documented, and since [GCC](http://gcc.gnu.org/) is free software, you can download its [source code](https://gcc.gnu.org/releases.html) and improve it – Basile Starynkevitch Apr 29 '21 at 17:44
  • Regarding shared objects like `php-extension.so` read Drepper's paper [*How to write shared libraries*](https://www.ukuug.org/events/linux2002/papers/pdf/dsohowto.pdf). Notice that [PHP](https://www.php.net/) is a *documented* and *open source* software, and you are allowed to download its source code, study that source code, read its documentation, then improve it too! See also [execve(2)](https://man7.org/linux/man-pages/man2/execve.2.html) – Basile Starynkevitch Apr 29 '21 at 17:54
  • Dear Basile, thank you for your time. `gcc` can not find none of any headers. `make` does not show any errors, but does not produce *.so extension. I do not want to show the code. I am reducing the code and checking if it is the code-errors or the `gcc` and `make`. Nevertheless, what is the name of gcc and make configuration files, which keep information about `headers include paths`? – Gintare Statkute Apr 29 '21 at 18:18

1 Answers1

0

The reason is a some error in php extension code, like error in variable name, like 72 instead of 76 in zend_function_entry tsub72_functions[] = {... instead of zend_function_entry tsub76_functions[] = {... ( not sure in which places, and how many occurrences )

A simple_file.c including any of headers is working.

gcc  simple_file.c -lm -g

Does not work only the extension.c, which i can not show, it is not public. But, if somebody know the file name where it is set the make and gcc configuration variables setting headers include paths, could you please write me.

Gintare Statkute
  • 677
  • 2
  • 8
  • 18
  • I don't know php, however when compiling a python extension you must link against the python library and provide an include path. On linux you can generally obtain these flags with `pkg-config --libs ` and `pkg-config --cflags ` respectively. Python provides great guidlines about compiling extensions, perhaps php does so too. – hetepeperfan Apr 30 '21 at 08:02