我在Windows8.1上安装了MinGW,以便在C++中编写代码,并且我试图使用崇高文本3运行我的代码。到目前为止,我是成功的,但我不能使用cin
和cout
。我知道我可以用scanf
和printf
代替。但我可能也需要使用cin
和cout
。当我试图构建包含cin
或cout
的cin
代码时,它会给出编译时错误。让我们看看生成这样一个错误的代码:
#include "iostream"
#include "cstdio"
using namespace std;
int main()
{
int n;
std::cin >> n;
std::cout << n;
}
我的机器上出现的错误是:(注意到:我在我的机器上安装了WinGHCi以使用Haskell)
Info: resolving std::cin by linking to __imp___ZSt3cin (auto-import)
Info: resolving std::cout by linking to __imp___ZSt4cout (auto-importc:/program files (x86)/haskell platform/2013.2.0.0/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.)
[Finished in 1.4s]
请帮我找出问题所在。我故意不想用IDE。
注意,一般的建议是使用<iostream>
而不是"iostream"
。在这方面,使用<iostream>
会在编译相同的代码时产生以下错误(用<iostream>
&<cstdio>
替换"iostream"
和"cstdio"
):
Info: resolving std::cin by linking to __imp___ZSt3cin (auto-import)
Info: resolving std::cout by linking to __imp___ZSt4cout (auto-importc:/program files (x86)/haskell platform/2013.2.0.0/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.)
[Finished in 1.8s]
发布于 2014-09-29 14:30:57
这些类型或错误在使用时经常会被抛出:
headers with version x
----------------------
lib with version y
所以,看看这个。
更新
如果您使用的编译器版本为4.6.3,但是您使用的标头为4.6 (出于任何原因),则会出现此类错误。
有用的命令:
which g++ #locate where is your compiler (generally /usr/bin/g++)
g++ --version #get compiler's version
find / -name iostream | grep c++ #find where're your includes
https://stackoverflow.com/questions/26102176
复制相似问题