日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux 编译C++错误整理

發布時間:2025/3/21 linux 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux 编译C++错误整理 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我將windows下的項目修改為linux下時出現問題整理

1、undefined reference to `__gxx_personality_v0'

需要-l libstdc++

2、?makefile::*** 遺漏分隔符

makefile中命令前要有tab,否則會報錯

3、tchar.h:沒有那個文件或目錄

在linux下沒有tchar.h這個文件,可以自己寫一個

#if defined(__BORLANDC__) && !defined(_TCHAR_DEFINED)typedef _TCHAR TCHAR, *PTCHAR;typedef _TCHAR TBYTE, *PTBYTE;#define _TCHAR_DEFINED#endif

4、錯誤:‘abs’在此作用域中尚未聲明

加入#include <stdlib.h>?

5、?錯誤:‘vector’不是一個類型名

需要添加#include <vector>

using namespace std; //或者 using namespace std::vector;

6、對‘std::basic_ifstream<char>::open(std::string&)’的調用沒有匹配的函數

:void std::basic_ifstream<_CharT, _Traits>::open(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::_Ios_Openmode]
? ? ? ?open(const char* __s, ios_base::openmode __mode = ios_base::in)

?no known conversion for argument 1 from ‘std::string {aka std::basic_string<char>}’ to ‘const char*’

從上述報錯來看需要把string類型的轉換到const char*,string類型轉換為const char* 只需在后面添加.c_str()即可。

7、:#warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
?#warning \

? ^

可以忽略此問題,根據提示在后面添加-Wno-deprecated

8、錯誤:‘runtime_error’不是‘std’的成員

<exception>?defines only the base?std::exceptionclass; if you want child classes like?std::runtime_error, you must include the?<stdexcept>?header.

需要添加#include <stdexcept>

9、std::basic_ofstream<_CharT, _Traits>::basic_ofstream(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::_Ios_Openmode]
? ? ? ?basic_ofstream(const char* __s,
? ? ? ?^
/usr/local/include/c++/4.8.1/fstream:640:7: 附注: ?no known conversion for argument 1 from ‘std::string {aka std::basic_string<char>}’ to ‘const char*’
/usr/local/include/c++/4.8.1/fstream:625:7: 附注:std::basic_ofstream<_CharT, _Traits>::basic_ofstream() [with _CharT = char; _Traits = std::char_traits<char>]
? ? ? ?basic_ofstream(): __ostream_type(), _M_filebuf()

與6錯誤一樣,把string類型的轉換到const char*。




總結

以上是生活随笔為你收集整理的linux 编译C++错误整理的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。