Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6865337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:01:53+00:00 2026-05-27T03:01:53+00:00

I am using PHP on Windows machin. I also use Dev C++. I can

  • 0

I am using PHP on Windows machin. I also use Dev C++. I can perfectly compile .cpp file on CMD using this command:

g++ hello.cpp -O3 -o hello.exe

Now what I am trying to do is running the same command using php system() function, so it looks like this:

system(“g++ c:\wamp\www\grader\hello.cpp -O3 -o C:\wamp\www\grader\hello.exe”);

but it doesn’t compile. I am lost, please tell me what am I missing?

I also looked up at this question and thats exactly what I need, but I couldnt find a usefull solution for my case there:

Php script to compile c++ file and run the executable file with input file

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:01:54+00:00Added an answer on May 27, 2026 at 3:01 am

    Two things:

    1. You are using double quotes and are not escaping the \ inside the path.
    2. You are not using a full path to g++.

    The first one is important as \ followed by something has a special meaning in such a string (you might know \n as new line), the second one is relevant since the PHP environment might have a different search path.

    A solution might be

    system("c:\\path\\to\\g++ c:\\wamp\\www\\grader\\hello.cpp -O3 -o C:\\wamp\\www\\grader\\hello.exe");
    

    Alternatively you can use single quotes, intead of double quotes, they use diffeent,less strict escaping rules

    system('c:\path\to\g++ c:\wamp\www\grader\hello.cpp -O3 -o C:\wamp\www\grader\hello.exe');
    

    or use / instead of \, which is supported by windows, too.

    system("c:/path/to/g++ c:/wamp/www/grader/hello.cpp -O3 -o C:/wamp/www/grader/hello.exe");
    

    What you do is your choice, while many might consider the first one as ugly, and the last one as bad style on Windows 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I install APC on Windows? I am using PHP 5.3, Windows 7
in windows (using apache as server), my file path directory will be C:\xampp\htdocs\mysvn\PhpDocumentor\phpdoc.php. But
How can I get the current Windows time in a PHP script? Using time()
While I was trying to uplaod file using php on windows machine its working
I need to access an Excel file on a Windows Share using PHP but
I'm trying to setup an Apache/PHP/Postgresql server locally on my machine. I'm using Windows
I have HTML tidy extension on my home computer using PHP 5.2.11 (Windows -
We have an issue using the PEAR libraries on Windows from PHP . Pear
On Windows using WAMPserver (Apache, MySQL, PHP) I have the following: //test.php if (!defined('LC_MESSAGES'))
I'm using EasyPHP (my OS = Windows XP) and I've written a little php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.