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 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序