g ++无法使用Windows 7上的boost语言环境预编译头进行构建

时间:2016-03-19 14:30:24

标签: c++ boost

我在 Windows 7 上使用 mingw-w64 ,我已经成功编译了提升1.60 ,它的工作正常不幸的是,当我执行以下命令来构建一个简单的测试应用程序时,内联标题:

g++ -W -Wall -std=c++11 test.cpp -o test.exe -L"C:\boost_1_60_0\stage\lib" -I"C:\boost_1_60_0" -lboost_locale-mgw48-mt-d-1_60 -lboost_system-mgw48-mt-d-1_60

编译失败并显示错误:

C:\boost_1_60_0\stage\lib/libboost_locale-mgw48-mt-d-1_60.a(codepage.o): In function `boost::locale::call_iconv(void*, char**, unsigned long long*, char**, unsigned long long*)':
C:\boost_1_60_0/libs/locale/src/encoding/../util/iconv.hpp:50: undefined reference to `iconv'
C:\boost_1_60_0\stage\lib/libboost_locale-mgw48-mt-d-1_60.a(codepage.o): In function `boost::locale::conv::impl::iconverter_base::open(char const*, char const*, boost::locale::conv::method_type)':
C:\boost_1_60_0/libs/locale/src/encoding/iconv_codepage.ipp:46: undefined reference to `iconv_open'
C:\boost_1_60_0\stage\lib/libboost_locale-mgw48-mt-d-1_60.a(codepage.o): In function `boost::locale::conv::impl::iconverter_base::close()':
C:\boost_1_60_0/libs/locale/src/encoding/iconv_codepage.ipp:132: undefined reference to `iconv_close'
collect2.exe: error: ld returned 1 exit status

我正在使用以下代码:

#include <boost/locale.hpp>
#include <iostream>

using namespace boost::locale;

int main()
{
    generator gene;
    std::locale myLocale = gene("en_US.UTF-8");

    std::cout << "name: " << std::use_facet<info>(myLocale).name() << std::endl;
    std::cout << "language: " << std::use_facet<info>(myLocale).language() << std::endl;
    std::cout << "country: " << std::use_facet<info>(myLocale).country() << std::endl;
    std::cout << "variant: " << std::use_facet<info>(myLocale).variant() << std::endl;
    std::cout << "encoding: " << std::use_facet<info>(myLocale).encoding() << std::endl;

    return 0;
}

0 个答案:

没有答案