i have a small problem, i have a c++ program, but PHP is not showing output, only "blank". I made a small program to test, when I use "printf" and "gcc" to compile, it works fine, but when I compile the same progran using "g++" it fails to show the content in the php page. Any ideas? I can't use "gcc" because my project is in c++
I'm using this version of gcc/g++
g++ (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)
EDIT: I simplified the problem so you can understand what is going on here, thanks for your help. Now i get a missing library error.
I compiled the files using the followings commands:
gcc -o prueba1 prueba.c
g++ -o prueba2 prueba.cpp
So "prueba1" is the one compiled with GCC and "prueba2" is the one compiled with G++
Here is the file test.php
<?php
echo "Executing file compiled with GCC <br />";
echo shell_exec("./prueba1");
echo "<br />";
echo "Executing file compiled with G++ <br />";
echo shell_exec("./prueba2 2>&1");
?>
I get this on the browser:
Executing file compiled with GCC
Hello World (GCC)
Executing file compiled with G++
./prueba2: /opt/lampp/lib/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/libstdc++.so.6)
Here is the prueba.c file:
#include <stdio.h>
int main(int argc, char *argsv[]){
printf("Hello World (GCC)\n");
return(0);
}
Here is the prueba.cpp file:
#include <iostream>
using namespace std;
int main(int argc, char *argsv[]){
cout << "Hello World (G++)" << endl;
return(0);
}
Rename the /opt/lampp/lib/libgcc_s.so.1 to /opt/lampp/lib/libgcc_s.so.1.backup, it seems C++ was trying to access this one instead the one that linux does when running from command line, thanks for the help guys
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With