使用Qt的qmake管理boost::filesystem代码时出现LNK2019问题
来源:互联网 发布:软件行业工资 编辑:程序博客网 时间:2024/05/16 05:52
使用QT管理包含有BOOST的代码会出现种种问题,下面的代码使用qmake创建的vcproj编译通过了
string dir_name = sec_log_namespace::logfile_name; boost::filesystem::path logFilePath(dir_name); boost::filesystem::path logFileDir = logFilePath.parent_path(); if (!boost::filesystem::exists(logFileDir)) { boost::filesystem::create_directory(logFileDir); }
但是链接时出错:
1>sec_log.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl boost::filesystem::path_traits::convert(char const *,char const *,class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > &,class std::codecvt<unsigned short,char,int> const &)" (__imp_?convert@path_traits@filesystem@boost@@YAXPBD0AAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@ABV?$codecvt@GDH@5@@Z) referenced in function "void __cdecl boost::filesystem::path_traits::convert(char const *,char const *,class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > &)" (?convert@path_traits@filesystem@boost@@YAXPBD0AAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>sec_log.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class std::codecvt<unsigned short,char,int> const & __cdecl boost::filesystem::path::codecvt(void)" (__imp_?codecvt@path@filesystem@boost@@SAABV?$codecvt@GDH@std@@XZ) referenced in function "void __cdecl boost::filesystem::path_traits::convert(char const *,char const *,class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > &)" (?convert@path_traits@filesystem@boost@@YAXPBD0AAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
把上面代码放到单独创建的vc工程中,发现没有问题,能编译,能链接。于是怀疑是编译环境问题,比较cl的command line,发现有个-Zc:wchar_t的选项。查了stackflow发现也是字符类型的问题,于是测试
打开vs中的Project->Properites,选择Configuration Properties->C/C++->Language->Treat wchar_t as Build-in type改成Yes。OK,链接成功。
然后改pro文件,加上下面一段:
win32:contains(QMAKE_CC, cl){ QMAKE_CXXFLAGS += -Zc:wchar_t }
- 使用Qt的qmake管理boost::filesystem代码时出现LNK2019问题
- QTCreator + MSVC10编译器 使用boost::filesystem 时 error LNK2019: codecvt ... 问题的解决
- QTCreator + MSVC10编译器 使用boost::filesystem 时 error LNK2019: codecvt ... 问题的解决
- [转]QTCreator + MSVC10编译器 使用boost::filesystem 时 error LNK2019: codecvt ... 问题的解决
- boost库filesystem使用问题
- 装qt的时候出现QT version is not properly installed, please run make install qmake使用不了问题
- boost之filesystem的使用
- Boost::filesystem的使用笔记
- boost的filesystem使用示例
- 构建qt项目时出现的qmake错误
- QT 中qmake 的使用
- QT error LNK2019 的问题
- Qt Creator 添加arm版本的qmake时的问题
- boost filesystem 的字符编码问题
- 使用boost.filesystem使用时编译错误
- boost中filesystem库的使用
- boost filesystem 使用
- boost使用出现问题
- Ruby自定义rake任务
- iOS 开发 webView返回上一页
- linux 内核启动流程(涉及到根文件系统的问题)
- iOS开发 提示框UIAlertController的略微封装
- NodeJS基本知识
- 使用Qt的qmake管理boost::filesystem代码时出现LNK2019问题
- 8张图理解Java
- 使用 JWT 让你的 RESTful API 更安全
- Ubuntu 删除两个文件夹下相同文件名的文件(内容也完全相同)
- Convert Sorted List to Binary Search Tree LeetCode
- 拦截用户登录切面分析
- tableHeaderView的Masonry
- STL 的各个版本
- 编译glew