无法使用gcc链接流代码

我在编译以下代码时遇到问题:
// writing on a text file
#include <iostream>
#include <fstream>
using namespace std;

int main () {
  ofstream myfile ("example.txt");
  if (myfile.is_open())
  {
    myfile << "This is a line.n";
    myfile << "This is another line.n";
    myfile.close();
  }
  else cout << "Unable to open file";
  return 0;
}
编译:
g++ -c -O2 -Wall -Wno-unused -fexceptions  -I. -I../../../stub -D_REENTRANT -D_THREAD_SAFE  -I.  -o t.o ./test.cc

g++ -o t -O2 -Wall -Wno-unused -fexceptions -Wl,-brtl -Wl,-blibpath:/lib:/usr/lib t.o -lpthreads
编译提供了一些警告:
ld: 0711-224 WARNING: Duplicate symbol: .__divdi3
ld: 0711-224 WARNING: Duplicate symbol: .__moddi3
ld: 0711-224 WARNING: Duplicate symbol: .__udivdi3
ld: 0711-224 WARNING: Duplicate symbol: .__umoddi3
ld: 0711-224 WARNING: Duplicate symbol: .__udivmoddi4
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
生成的二进制文件似乎执行OK:
$ ./t
$ echo $?
0
输出文件已创建但是空了!?! 对于问题可能是什么,我会非常感激。     
已邀请:
Libpath设置不正确,导致问题。应该是正确的设置 LIBPATH = /选择/免费软件/ LIB / GCC / PowerPC的IBM-aix6.1.0.0 / 4.2.0 /     

要回复问题请先登录注册