Centos下C++程序中添加的标准模板库(map、string、iostream等)均提示找不到

编译C++程序,提示如下错误:

In file included from /usr/include/c++/4.8.2/x86_64-redhat-linux/bits/os_defines.h:39:0,
                 from /usr/include/c++/4.8.2/x86_64-redhat-linux/bits/c++config.h:2097,
                 from /usr/include/c++/4.8.2/bits/stl_algobase.h:59,
                 from /usr/include/c++/4.8.2/bits/stl_tree.h:61,
                 from /usr/include/c++/4.8.2/map:60,
                 from include/share.h:18,
                 from main.cpp:14:
/usr/local/include/wx-3.0/wx/features.h:80:29: 错误:missing binary operator before token "("
     (wxCHECK_VISUALC_VERSION(8) && !defined(__WXWINCE__))
                             ^
/usr/local/include/wx-3.0/wx/features.h:117:24: 错误:missing binary operator before token "("
 #if wxCHECK_GCC_VERSION(3, 2) || wxCHECK_VISUALC_VERSION(7) \
                        ^
In file included from /usr/include/c++/4.8.2/x86_64-redhat-linux/bits/c++config.h:2097:0,
                 from /usr/include/c++/4.8.2/bits/stl_algobase.h:59,
                 from /usr/include/c++/4.8.2/bits/stl_tree.h:61,
                 from /usr/include/c++/4.8.2/map:60,
                 from include/share.h:18,
                 from main.cpp:14:
/usr/include/c++/4.8.2/x86_64-redhat-linux/bits/os_defines.h:44:19: 错误:missing binary operator before token "("
 #if __GLIBC_PREREQ(2,15) && defined(_GNU_SOURCE)
                   ^
In file included from /usr/include/c++/4.8.2/cwchar:44:0,
                 from /usr/include/c++/4.8.2/bits/postypes.h:40,
                 from /usr/include/c++/4.8.2/bits/char_traits.h:40,
                 from /usr/include/c++/4.8.2/string:40,
                 from /usr/include/c++/4.8.2/stdexcept:39,
                 from /usr/include/c++/4.8.2/array:38,
                 from /usr/include/c++/4.8.2/tuple:39,
                 from /usr/include/c++/4.8.2/bits/stl_map.h:63,
                 from /usr/include/c++/4.8.2/map:61,
                 from include/share.h:18,
                 from main.cpp:14:
/usr/include/wchar.h:74:43: 错误:missing binary operator before token "("
 # if defined __cplusplus && __GNUC_PREREQ (4, 4)
                                           ^
In file included from /usr/include/sched.h:33:0,
                 from /usr/include/pthread.h:23,
                 from /usr/include/c++/4.8.2/x86_64-redhat-linux/bits/gthr-default.h:35,
                 from /usr/include/c++/4.8.2/x86_64-redhat-linux/bits/gthr.h:148,
                 from /usr/include/c++/4.8.2/ext/atomicity.h:35,
                 from /usr/include/c++/4.8.2/bits/basic_string.h:39,
                 from /usr/include/c++/4.8.2/string:52,
                 from /usr/include/c++/4.8.2/stdexcept:39,
                 from /usr/include/c++/4.8.2/array:38,
                 from /usr/include/c++/4.8.2/tuple:39,
                 from /usr/include/c++/4.8.2/bits/stl_map.h:63,
                 from /usr/include/c++/4.8.2/map:61,
                 from include/share.h:18,
                 from main.cpp:14:
/usr/local/include/wx-3.0/wx/time.h:13:25: 致命错误:wx/longlong.h:没有那个文件或目录

#include "wx/longlong.h"

查看了/usr/local/include/wx-3.0/wx/下的文件,均未发现异常。因为未在本工程和IDE的配置中设置该include路径,猜想可能跟环境配置有关,比如 /etc/profile之类。后面想起来,最近修改了 ~/.bashrc,在其中新增了一句配置include的环境变量:

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib:    ## 新增 ##

export CPLUS_INCLUDE_PATH="/usr/local/include/wx-3.0/wx":${CPLUS_INCLUDE_PATH}   ## 新增 ##

于是,删除新增并重启之后,再编译,一切正常。如果想用 "source ~/.bashrc“ 代替重启,亲测无效^_^



你可能感兴趣的:(Centos下C++程序中添加的标准模板库(map、string、iostream等)均提示找不到)