0

I'm sending an HTTP request to my web server and its task is to compile a file exploiting the system() function. I'm trying to compile this code:

system("gcc -o testFile testFile.c")

However, I receive this error:

error trying to exec 'cc1': execvp: No such file or directory

I'm not that expert in both linux and C. Anybody can help to fix this issue?

I tried the solution available and it did not work

Timmy
  • 107
  • 4
  • 18
  • 1
    That sounds like a broken gcc install. – melpomene Dec 09 '16 at 15:19
  • @Timmy Look up in the documentation for your linux distro on how to install and remove packages, then remove the existing gcc package(s), and install it again. – nos Dec 09 '16 at 15:21
  • 1
    @Timmy: what is the 'solution available' that you tried and did not work? Can you compile programs without going through the web server? If you can compile from a terminal window but not from the web server, it is probably an environment issue — maybe the setting of `$PATH`, or maybe something else. Normally though, if you can find `gcc` to run it, then it can find its backend tools; they are in a specified location. If you can't compile form the terminal window (same or similar error), it is time to reinstall. – Jonathan Leffler Dec 09 '16 at 18:26
  • on the terminal window, the command works fine. When I send the request and want it to compile the same command it did not work. – Timmy Dec 10 '16 at 03:28

1 Answers1

1

this is how I managed to solve this problem:

system("export  PATH=$PATH; gcc -o  testFile    testFile.c")
Timmy
  • 107
  • 4
  • 18