问题描述
我写这code键读取3个文件,TM是正方形矩阵的大小,LER阵列的行和从最后的值定义的非正方形矩阵的第(LER / 2)* 2
则... code读取文件的一些关系,都是数字,并分配给C [LER]
然后... C [LER]被分配到B [LER / 2] [2]。
这些坐标,每行,在B〔LER / 2] [2]分配给和b
a和b是行和矩阵的列A [商标] [TM]其中添加1
我的code崩溃,我不知道是什么错误。
当我尝试编译它,编译器的gcc -o -g MatSim MatSim.cpp 提示:
/ usr / include目录/ C ++ / 4.6 /的iostream:75:未定义引用'的std :: ::的ios_base ::初始化的init()
/usr/include/c++/4.6/iostream:75:未定义的引用`的std :: ::的ios_base ::初始化〜的init()
collect2:劳工处返回1退出状态
此外,当我尝试编译它,编译器的 F77 -o MatSim MatSim.cpp 提示:
/tmp/cc6ewlkf.o:在功能`__static_initialization_and_destruction_0(INT,INT):
MatSim.cpp :(文字+ 0x17ad4a):未定义引用'的std :: ::的ios_base ::初始化的init()
。MatSim.cpp :(文字+ 0x17ad4f):未定义引用'的std :: ::的ios_base ::初始化〜的init()
collect2:劳工处返回1退出状态
解决方案
主要的问题是一个图书馆的问题,使用编译您的code:
G ++ -g -o MatSim MatSim.cpp -lstdc
还是不能正常工作?安装库:
命令和apt-get安装G ++ - multilib的
您可以通过多种方式解决此问题:
- 使用
G ++
在GCC
代替:G ++ -g -o MatSim MatSim。 CPP
- 添加
-lstdc ++
:的gcc -o -g MatSim MatSim.cpp -lstdc ++
- 替换
<&string.h中GT;
按<串GT;
这是一个连接问题,而不是一个编译器的问题。同样的问题在这个问题涉及 - 它解释这是怎么回事
I write this code to read 3 files, TM is the size of square matrix, LER the No. of rows of an array and from last value define a non-square matrix of (ler/2)*2
Then... the code read a file with some relations, all are numbers and are assign to C[ler].
Then ... C[ler] is assigned to B[ler/2][2].
Those coordinates, per row, in B[ler/2][2] are assign to a and b.
a and b are the row and the column of the matrix A[tm][tm] where to add 1.
My code crashes and I don't see what the error is.
When I try to compile it, the compiler gcc -g -o MatSim MatSim.cpp prompted:
/usr/include/c++/4.6/iostream:75: undefined reference to `std::ios_base::Init::Init()'
/usr/include/c++/4.6/iostream:75: undefined reference to `std::ios_base::Init::~Init()'
collect2: ld returned 1 exit status
Also, when I try to compile it, the compiler f77 -o MatSim MatSim.cpp prompted:
/tmp/cc6ewlkf.o: In function `__static_initialization_and_destruction_0(int, int)':
MatSim.cpp:(.text+0x17ad4a): undefined reference to `std::ios_base::Init::Init()'
MatSim.cpp:(.text+0x17ad4f): undefined reference to `std::ios_base::Init::~Init()'
collect2: ld returned 1 exit status
Solution
The main problem was a library problem, Compile your code using:
g++ -g -o MatSim MatSim.cpp -lstdc
Still not working? Install libraries:
sudo apt-get install g++-multilib
You can resolve this in several ways:
- Use
g++
in stead ofgcc
:g++ -g -o MatSim MatSim.cpp
- Add
-lstdc++
:gcc -g -o MatSim MatSim.cpp -lstdc++
- Replace
<string.h>
by<string>
This is a linker problem, not a compiler issue. The same problem is covered in the question iostream linker error -- it explains what is going on.
这篇关于未定义的引用'的std :: ::的ios_base ::初始化的init()“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!