将 g++ 编译器的输出重定向到文件?
Redirect the output of g++ compiler to a file?
我在编译 C++ 程序时看到以下消息。
test.cpp: In function ‘int main()’:
test.cpp:950: error: no match for ‘operator<<’ in ‘std::cout << d->Derived::print()’
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:108: note: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>& (*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:117: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
我在想是否可以将所有这些消息重定向到一个文件并且在控制台上看不到任何内容。我尝试通过
重定向 stderr 消息
g++ test.cpp 2> xx
但这似乎不起作用。我仍然在控制台上看到所有内容,但在文件中什么也看不到。
对于 csh
类型的 shell,执行:
g++ test.cpp >& xx
我在编译 C++ 程序时看到以下消息。
test.cpp: In function ‘int main()’:
test.cpp:950: error: no match for ‘operator<<’ in ‘std::cout << d->Derived::print()’
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:108: note: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>& (*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:117: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
我在想是否可以将所有这些消息重定向到一个文件并且在控制台上看不到任何内容。我尝试通过
重定向 stderr 消息g++ test.cpp 2> xx
但这似乎不起作用。我仍然在控制台上看到所有内容,但在文件中什么也看不到。
对于 csh
类型的 shell,执行:
g++ test.cpp >& xx