- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试在 AIX Box 上编写一个简单的 C++ 程序。程序如下:
# include <iostream>
# include <fstream>
using namespace std ;
int main()
{
ofstream of ;
of.open("license.txt") ;
of<<"hello"<<endl ;
of.close() ;
}
我的 LDFLAGS 设置如下:
-maix64 -L/disk3/TOOLS/GCCTools/gcc-4.5.1/lib/ppc64 \
-L/disk3/TOOLS/GCCTools/gcc-4.5.1/lib/gcc/powerpc-ibm-aix6.1.0.0/4.5.1/ppc64 \
-L/disk3/TOOLS/GCCTools/gcc-4.5.1/lib/gcc/powerpc-ibm-aix6.1.0.0/4.5.1 \
-L/disk3/TOOLS/OPENSSL/lib
CFLAGS 是:
-O2 -maix64 -I/disk3/TOOLS/OPENSSL/include -D_ALL_SOURCE -D_XOPEN_SOURCE \
-D_XOPEN_SOURCE_EXTENDED -DSS_64BIT_SERVER -D_POSIX_SOURCE -D__64BIT__ \
-I/disk3/TOOLS/OPENSSL/include -I/usr/include \
-I/disk3/TOOLS/GCCTools/gcc-4.5.1/lib/gcc/powerpc-ibm-aix6.1.0.0/4.5.1/include
程序编译正常。但是当我尝试运行相同的程序时,程序会出现段错误。我用 gdb 运行了同样的程序,当我使用 ofstream 时发现了以下问题:
Program received signal SIGSEGV, Segmentation fault.
0x09000000036107c4 in std::locale::operator=(std::locale const&) (this=
findvar.c:706: internal-error: value_from_register: Value not stored anywhere!
知道为什么会这样吗?任何帮助表示赞赏:)
注意:fstream 本身可以工作...
最佳答案
我遇到了同样的错误。重现错误的关键点是:1 在共享库中使用 std::stream(例如 std::ofstream);2 使用share库中的pthread函数(如pthread_self);3 使用“-O2”优化代码。然后显示“Segmentation fault (core dumped)”。
AIX 提供了 2 个版本(64 位)的 libstdc++.a。 (参见 http://www.perzl.org/aix/index.php?n=Main.GCCBinariesVersionNeutral)64 位编译,非线程安全 (<prefix>/ppc64
)64 位编译,线程安全 (<prefix>/pthread/ppc64)
我的解决方案是:将 LIBPATH 更改为使用 "<prefix>/pthread/ppc64"
版本。例如将 LIBPATH 设置为“/opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/4.6.1/pthread/ppc64/”
它在我的机器上运行良好。
关于c++ - 在 AIX 上使用 ofstream,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8924410/
我想在一个函数中打开一个文件,将打开的文件对象返回给 main,并在另一个函数中使用它函数来填充文件。编译器似乎告诉我,我正在尝试访问 iostream 的私有(private)成员。有没有办法做到这
我最近写了一个记录器类。编译这段代码时: std::ofstream *stream = new std::ofstream; stream->open( log_file_name.c_str()
我有以下测试代码,其中有一个参数 fS,它是 ofstream 的容器: #include #include #include #include int
我正在尝试实现一个记录器,它可以注册到多个流,如 ostringstream、ofstream 等。我试图实现这样的功能 void register_stream(std::ostream& a);
我有一个在线程上写入文件的类 class A{ public: void writeToFile(ofstream& outFile, obj &a) { //...
我有以下代码 void _log_message(const char* fmt, ...) { va_list arg; ofstream logfile; cout << "Open Lo
我刚刚开始阅读如何打开和编辑文件。使用 ifstream 时,如果文件不存在,则不会创建它。 引用下面的代码,条件 (!outfile) 何时为假,就好像文件不存在一样,构造函数将简单地创建它,因此总
#include #define LOGFATAL(msg) log(0, msg) std::ofstream *logst = NULL; void log(int sev, char *msg
我在使用 ofstream 时遇到问题一次将两个不同的输出写入两个不同的文件。程序编译运行正常,并向p1output.txt写入数据,但是当我打开p2output.txt时,除了第一行内容外是空白的:
我有一个“资源模块”类来管理我的应用程序的所有资源,它主要从一个包含所有内容的文件“RESOURCES.DAT”中读取。 从文件中请求新数据的所有对象都通过 ResourceModule,因此我可以管
我遇到流问题,程序无法打开我要写入的文件。最小完整可变代码如下: #include #include using namespace std; int main(){ string roo
我已经研究了好几个小时了,我只知道答案很简单。似乎无论我做什么我都无法打开文件。这是一个多类程序,所以在标题中我有 #include #include class A{ string path
所以我想写一个可以像这样使用的缩进输出类: Debug f; f.open("test.txt"); f }' and '') ofs #include using namespace std;
大家好... 抱歉我的英语不好,但是会说西类牙语... 这周,为了这个proyect的学习和工作,我想创建一个软件来制作文件(.us)... 示例 char name[50]; //Or string
我不想在 main() 中构造 ofstream。这是我所做的,但它没有编译: #include using namespace std; class test { private: ofs
谁能告诉我这是怎么回事? #include #include #include #include #include class writeManager { std::vector
我有一个 C++ 类,它将其数据写出到二进制 std::ofstream。该类将数据存储为 boost:shared_array 但我已经消除了这个问题。问题出在 ofstream 上对 write(
在我的程序中,我的 dataout: void outfile 没有写入文件,任何人都可以找出原因吗? using namespace std; #include #include #include
我想在文件上写点东西。但它只是没有像它必须假设的那样编写。 void main() { int accno; char name[20]; float deposit;
我遇到了一个奇怪的问题。我有两个函数,它们都有一个通过引用传递的 ofstream。但是,当我调用第二个函数时,正在打印第一个函数的一部分。 这是第一个函数: void GamePlay::dealD
我是一名优秀的程序员,十分优秀!