小编Pri*_*rya的帖子

提升日志以打印源代码文件名和行号

我正在使用Boost(1.55.0)登录我的C++应用程序.我已经能够生成这种格式的日志

[2014-Jul-15 10:47:26.137959]: <debug>  A regular message
Run Code Online (Sandbox Code Playgroud)

我希望能够在生成日志的位置添加源文件名和行号.

[2014-Jul-15 10:47:26.137959]: <debug> [filename:line_no] A regular message
Run Code Online (Sandbox Code Playgroud)

例:

[2014-Jul-15 10:47:26.137959]: <debug> [helloworld.cpp : 12] A regular message
Run Code Online (Sandbox Code Playgroud)

源代码:

#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sinks/text_file_backend.hpp>
#include <boost/log/utility/setup/file.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/sources/record_ostream.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/support/date_time.hpp>
#include <boost/log/attributes/attribute.hpp>
#include <boost/log/attributes/attribute_cast.hpp>
#include <boost/log/attributes/attribute_value.hpp>
#include <boost/make_shared.hpp>
#include <boost/property_tree/ptree.hpp>

namespace logging = boost::log;
namespace src = boost::log::sources;
namespace sinks = boost::log::sinks;
namespace keywords = boost::log::keywords;

void init()
{
    logging::add_file_log
    (
        keywords::file_name = "sample_%N.log", …
Run Code Online (Sandbox Code Playgroud)

c++ boost boost-logging boost-log

14
推荐指数
3
解决办法
8094
查看次数

find_package()没有检测到Windows Cmake上的提升

我正在使用Windows系统.我想使用CMake来使用Boost库.我在C:\ boost_1_55_0 \上安装了boost.这是我的CMakeLists.txt文件

set(Boost_USE_STATIC_LIBS        ON)
set(Boost_USE_MULTITHREADED      ON)
set(Boost_USE_STATIC_RUNTIME    OFF)
find_package(Boost 1.55.0 COMPONENTS thread)

if(Boost_FOUND)
    include_directories(${Boost_INCLUDE_DIRS}) 
    LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
    add_executable (linking_with_boost main.cc sqr.cc)
    target_link_libraries(linking_with_boost ${Boost_LIBRARIES})
else()
    message(STATUS "Fail  asdasd!")
endif()
Run Code Online (Sandbox Code Playgroud)

我得到了 - 不能找到Boost输出:

$ cmake ../
-- Could NOT find Boost
-- Fail  asdasd!
-- Configuring done
-- Generating done
-- Build files have been written to: D:/ubuntu_share/programming/C++/practice/cm
ake/linking_with_boost/build_win
Run Code Online (Sandbox Code Playgroud)

boost cmake visual-studio-2010

13
推荐指数
4
解决办法
2万
查看次数

在std :: string中存储unicode UTF-8字符串

回应中的讨论

C++中的跨平台字符串(和Unicode)

如何以跨平台友好的方式处理C/C++中的Unicode字符串?

我正在尝试将UTF-8字符串分配给环境中的std::string变量Visual Studio 2010

std::string msg = "?????";

但是,当我查看字符串视图调试器时,我只看到"?????" 我将文件保存为Unicode(带签名的UTF-8),我使用字符集"使用unicode字符集"

"महसुस"是一种尼泊尔语言,它包含5个字符,占用15个字节.但是visual studio调试器将msg大小显示为5

我的问题是:

如何使用std :: string只存储utf-8而不需要操作它

c++ windows unicode utf-8 stdstring

12
推荐指数
2
解决办法
2万
查看次数

无法下载应用程序,此时无法安装应用程序

我在为iPad应用程序安装OTA时遇到问题.我上周更新了我的企业证书.我创建了新的dev/dist证书和配置文件.Xcode组织者显示正确的过期日期.当我尝试从链接安装应用程序时,它下载了一半并向我显示错误"无法下载应用程序,此时无法安装".我之前做过OTA安装超过50次.我重新检查了一切.这不是无效链接或选择错误的配置文件的问题.任何帮助将不胜感激.我检查了设备日志,它说:

May  1 13:15:32 unknown installd[2455] <Error>: entitlement 'keychain-access-groups' has value not permitted by a provisioning profile
May  1 13:15:32 unknown installd[2455] <Error>: entitlement 'application-identifier' has value not permitted by a provisioning profile
May  1 13:15:32 unknown installd[2455] <Error>: 00381000 verify_signer_identity: Could not copy validate signature: -402620394
May  1 13:15:32 unknown installd[2455] <Error>: 00381000 preflight_application_install: Could not verify executable at /var/tmp/install_staging.8zrx0B/foo_extracted/Payload/Hra.app
Run Code Online (Sandbox Code Playgroud)

enterprise ota ios provisioning-profile

7
推荐指数
2
解决办法
1万
查看次数

Valgrind在Mac OSX 10.8上显示空程序的内存泄漏

Valgrind使用brew安装.

#include <stdio.h>
#include <stdlib.h>
int main()
{
    return 0;
}

gcc -g -o hello hello.c

valgrind --tool=memcheck --leak-check=yes ./hello
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

c macos valgrind memory-leaks

7
推荐指数
1
解决办法
2446
查看次数

错误LNK1104:无法打开文件'libboost_thread-vc100-mt-gd-1_55.lib'

我正在尝试将boost线程的共享库链接到我的应用程序中.

系统:Windows8

IDE:Visual Studio 2010

我使用以下方法构建boost库:

b2 --with-thread --build-type=complete link=shared
Run Code Online (Sandbox Code Playgroud)

我可以看到

boost_thread-vc100-mt-gd-1_55.dll
boost_thread-vc100-mt-gd-1_55.lib
Run Code Online (Sandbox Code Playgroud)

和stage/lib目录中的其他文件

我在链接器选项中添加了"附加库目录和输入"的路径:

其他图书馆馆藏: C:/boost_1_55_0_dyn/stage/lib

输入: C:\boost_1_55_0_dyn\stage\lib\boost_thread-vc100-mt-gd-1_55.lib

我不知道为什么在地球上Visual Studio正在寻找libboost_thread-vc100-mt-gd-1_55.lib.我没有在属性或任何地方的任何地方提到libboost_thread-vc100-mt-gd-1_55.lib.我甚至搜索项目中的所有文件和文件夹,libboost_thread-vc100-mt-gd-1_55.lib在任何地方都没有提到.

boost linker-errors dynamic-linking visual-studio-2010 boost-build

6
推荐指数
1
解决办法
1万
查看次数

在windows上使用zlib编译boost

有没有关于如何在 Windows 上使用 zlib 编译 boost 的好教程。\n我查看了 boost 参考,但它很模糊并且不够。\n我确实下载了 zlib dll 和源代码并在 Visual Studio 中进行了参考。\n我的链接有错误

\n\n
gzip_decompressor();\n
Run Code Online (Sandbox Code Playgroud)\n\n

完整代码:

\n\n
using namespace boost::iostreams;\nusing namespace std;\nstd::ifstream file("hello.gz", std::ios_base::in | std::ios_base::binary);\nfiltering_streambuf < input > in;\nin.push(gzip_decompressor());\nin.push(file);\nboost::iostreams::copy(in, std::cout);\n
Run Code Online (Sandbox Code Playgroud)\n\n

我收到这个错误,

\n\n
\n

错误 11 错误 LNK2019:无法解析的外部符号“_declspec(dllimport) public: __thiscall\n boost::iostreams::detail::gzip_header::~gzip_header(void)”\n (__imp??1gzip_header@detail@iostreams@boost@ @QAE@XZ) 在函数“public: __thiscall\n boost::iostreams::basic_gzip_decompressor\n \\>::~basic_gzip_decompressor >(void)”中引用 (??1?$basic_gzip_decompressor@V?$allocator@ D@std@@@iostreams@boost@@QAE@XZ)\n \xe2\x80\x93

\n
\n

c++ boost zlib boost-iostreams

3
推荐指数
1
解决办法
5269
查看次数