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

4
  • 1
    That sounds like a broken gcc install. Commented Dec 9, 2016 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. Commented Dec 9, 2016 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. Commented Dec 9, 2016 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. Commented Dec 10, 2016 at 3:28

1 Answer 1

1

this is how I managed to solve this problem:

system("export PATH=$PATH; gcc -o testFile testFile.c") 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.