1
我在编译引发异常的简单C++程序时遇到了这个奇怪的问题。AIX 1.7上的C++编译问题
main.cc:
#include <stdio.h>
double mean(double a, double b)
{
if((a + b) == 0)
{
throw "Exception:: Numerator is Zero";
}
return (a+b)/2;`
}
calc.cc:
#include <stdio.h>
double mean(double a, double b)
{
if((a + b) == 0)
{
throw "Exception:: Numerator is Zero";
}
return (a+b)/2;
}
当我编译如下:
Execute the following commands : Step 2.1 => gcc -maix64 -fpic -c calc.cc Step 2.2 => gcc -maix64 -shared -o libcalc.so calc.o -lstdc++ Step 2.3 => gcc -maix64 main.cc libcalc.so -lstdc++
并运行程序,程序有以下崩溃错误:
terminate called after throwing an instance of 'char const*' IOT/Abort trap (core dumped)
但不是步骤2.3,如果我们用下面的命令如预期一切正常:
gcc -maix64 main.cc libcalc.so -lstdc++ -lgcc_s
可否请你在解决这个帮助...
你能检查你的文章吗?你的calc和main是一样的。 – 2011-12-26 05:25:05
你的意思是AIX 7.1吗? AIX 1.7如果存在的话,已经过时了几十年。 – 2011-12-26 05:55:49
它是1.7(对于错字抱歉)' – 2011-12-26 05:58:08