c++ - 使用 gcc 4.8.4/clang3.4 编译 Nana 示例 (nana v1.1.2/1.1.3) 时出错

标签 c++ linux user-interface gcc4.8 nana

我尝试了从 Github 下载的最新的 nana (1.1.2/1.1.3)。该库编译得很好。当我尝试使用 linux(gcc 4.8.4、clang 3.4)编译和链接任何示例程序时,出现以下错误:

enter In file included from /installs/nana/include/nana/gui/wvl.hpp:20:
In file included from /installs/nana/include/nana/gui/widgets/form.hpp:16:
In file included from /installs/nana/include/nana/gui/widgets/widget.hpp:17:
/installs/nana/include/nana/internationalization.hpp:69:7: error: invalid operands to binary expression ('std::wstringstream' (aka 'basic_stringstream<wchar_t>') and 'nana::string' (aka 'basic_string<char>'))
                    ss << nana::string(nana::charset(arg));
                    ~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8 /system_error:186:5: note: candidate function [with _CharT = wchar_t, _Traits = std::char_traits<wchar_t>] not viable: no known conversion from 'nana::string' (aka 'basic_string<char>') to 'const std::error_code' for 2nd argument
operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:108:7: note: candidate function not viable: no known conversion from 'nana::string' (aka 'basic_string<char>') to '__ostream_type &(*)(__ostream_type &)' for 1st argument
  operator<<(__ostream_type& (*__pf)(__ostream_type&))
  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:117:7: note: candidate function not viable: no known conversion from 'nana::string' (aka 'basic_string<char>') to '__ios_type &(*)(__ios_type &)' for 1st argument
  operator<<(__ios_type& (*__pf)(__ios_type&))
  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:127:7: note: candidate function not viable: no known conversion from 'nana::string' (aka 'basic_string<char>') to 'std::ios_base &(*)(std::ios_base &)' for 1st argument
  operator<<(ios_base& (*__pf) (ios_base&))
  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:166:7: note: candidate function not viable: no known conversion from 'nana::string' (aka 'basic_string<char>') to 'long' for 1st argument
  operator<<(long __n)
  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:170:7: note: candidate function not viable: no known conversion from 'nana::string' (aka 'basic_string<char>') to 'unsigned long' for 1st argument
  operator<<(unsigned long __n)
  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:174:7: note: candidate function not viable: no known conversion from 'nana::string' (aka 'basic_string<char>') to 'bool' for 1st argument
  operator<<(bool __n)here

制作:

cmake_minimum_required(VERSION 3.2)
project(nana_ui)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11
    -DSTD_CODECVT_NOT_SUPPORTED")
SET(NANA_BASE "/installs/nana")
include_directories(${NANA_BASE}/include
        /usr/include/freetype2)
link_directories(${NANA_BASE}/lib)

set(SOURCE_FILES main.cpp)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${NANA_BASE}/lib/libnana.a
        X11 pthread rt Xft png asound)

示例 cpp:

#include <nana/gui.hpp>
#include <nana/gui/widgets/label.hpp>

int main()
{
    using namespace nana;
    form fm;
    label lb(fm, fm.size());
    lb.caption(L"Hello, World");
    fm.show();
    exec();
}

感谢任何帮助。

最佳答案

在config.hpp中加入#define NANA_UNICODE,然后重新编译库和例子

关于c++ - 使用 gcc 4.8.4/clang3.4 编译 Nana 示例 (nana v1.1.2/1.1.3) 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33333978/

相关文章:

python - Python 3.6 中的 Tkinter : Grid sticky option not working

c++ - SFML 设置位置()

linux - 目录存在时 mkdir -p 失败

linux - 在 Linux 中比较文本文件并为文件 2 中的元素返回文件 1 中的元素

java - 在 GUI 中显示 Java 控制台

Java GUI,无需任何其他进程

c++ - 如何在 vector 队列或 vector vector 上使用 std::async 进行排序?

c++ - template-id 不匹配任何模板声明

c++ - 使用 C++ 与 Stockfish shell 交互

linux - 系统启动时如何导出变量