dqvzfp6468 2011-04-03 17:56
浏览 39

C ++输出没有在PHP中显示

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)
");

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);

}
  • 写回答

1条回答 默认 最新

  • duanjuda5789 2011-04-03 23:04
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b