我尝试了从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的:
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();
}
感谢任何帮助。
答案 0 :(得分:1)
在config.hpp中添加#define NANA_UNICODE,然后重新编译库和示例