I am trying to run C++ on an XAMPP server using the exec() function in PHP. I am importing a C++ json library. When I run the C++ code from terminal it works perfectly, but when I run it in PHP I get no output. As soon as I add any code from the json library, I no longer get any output.
PHP:
<?php
exec("./cPlusPlus", $output);
echo $output;
?>
C++ compiled with g++ -std=c++11:
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <json>
using namespace std;
using json = nlohmann::json;
int main(int argc, char *argsv[])
{
// If I remove this line, then I get the correct output
// If I keep this line, I get no output
json data = {"json stuff"};
cout << "This is returned to PHP.";
return 0;
}
It seems like the problem has to do with the fact that I am using a library. Do I need to do something special in order to run libraries with the PHP exec() function?