Boost(1.69.0) windows入门(译)

<head> <title>缩进2字符</title> <style type="text/css"> .yindent, .yblock{ padding: 1em 1em 0 1em; margin-right:0; } .yindent{ margin:0.7em 2em; border:medium outset; } .yblock{ margin:0em 2em 0.7em; padding:0; } .yhelper{ margin-left: 1em; border: medium outset; padding: 1em; background-color: #ffffee; width: 40%; float: right; } </style> </head>

Boost windows入门

基于版本1.69.0

[toc]

1. 获得Boost源代码

获取Boost副本最好的方法是下载boost_1_69_0.7zboost_1_69_0.zip并解压缩以安装完整的Boost发行版。

2. Boost源代码组织 The Boost Distribution

这是Boost目录结构草图:

1boost_1_69_0 \ ........................ “boost根目录” 2 index.htm ................ 这是www.boost.org的副本 3 boost \ ......................... 所有Boost 头文件 4 lib \ .......................... 预编译库二进制文件 5 libs\ ................. 测试,.cpps,docs等,通过库 6 index.html ..................... 库文档从这里开始 7 algorithm\ 8 any \ 9 array \ 10 ...更多库... 11 status\ .........................Boost-wide测试套件 12 tools\ ........... 实用工具,例如Boost.Build,quickbook,bcp 13 more \ ................................. 政策文件等 14 doc \ ........................ 所有Boost库文档的子集
<div class="yhelper yindent"> <b>标题组织</b><br>

Boost库头的组织并不完全统一,但大多数库遵循以下几种模式: <br>

  • 一些较旧的库和大多数非常小的库将所有公共头文件直接放入 boost\<br>

  • 大多数库的公共头文件都位于boost\的子目录中,以库命名。例如,您将在中找到Python库的def.hpp标头<br>

.    boost\python\def.hpp.<br>

  • 有些库在boost\中有一个“聚合头”,即#include所有库的其他头文件。例如,Boost.Python的聚合头是<br>

.    boost\python.hpp.<br>

  • 大多数库将私有头放在名为 detail\aux_\ 的子目录中。不要指望在这些目录中找到任何可以使用的东西。<br>
</div>

重要的是要注意以下几点:

  1. boost根目录(boost root directory)(通常是C:\Program Files\boost\boost_1_69_0)有时在boost文档和邮件列表中也称为$BOOST_ROOT

  2. 要在Boost中编译任何内容,您需要在include目录中包含boost\子目录。 在Microsoft Visual Studio中设置include路径的具体步骤将在本文档的后面部分中介绍; 如果您使用其他IDE,请参阅产品文档以获取相关说明。

  3. 由于所有Boost头文件都具有.hpp扩展名,并且位于boost根目录下的boost\子目录中,因此你的Boost #include指令将如下所示:

    #include <boost/whatever.hpp>

#include "boost/whatever.hpp"

取决于您对使用尖括号的偏好包括。即使是Windows用户也可以(并且出于可移植性的原因,可能)在#include指令中使用正斜杠(forward slashes); 你的编译器不关心。

  1. 不要被doc\子目录分散注意力; 它只包含Boost文档的子集。如果要查看完整的文件,从 libs\index.html 开始。

3. 仅用头文件的库 Header-Only Libraries

许多人想要知道的第一件事是,“我如何构建Boost?”好消息是,通常没有什么可构建的。

<div class="yindent"> <b>什么都没有建立?</b> <br><br>

大多数Boost库只是头文件:它们完全由包含模板和内联函数的头文件组成,并且在链接时不需要单独编译的库二进制文件或特殊处理。

</div>

必须单独构建的Boost库是:

  • Boost.Chrono
  • Boost.Context
  • Boost.Filesystem
  • Boost.GraphParallel
  • Boost.IOStreams
  • Boost.Locale
  • Boost.Log (see build documentation)
  • Boost.MPI
  • Boost.ProgramOptions
  • Boost.Python (see the Boost.Python build documentation before building and installing it)
  • Boost.Regex
  • Boost.Serialization
  • Boost.Signals
  • Boost.System
  • Boost.Thread
  • Boost.Timer
  • Boost.Wave

一些库具有可选的单独编译的二进制文件:

  • Boost.DateTime有一个二进制组件,只有在使用其to_string/from_string或序列化功能时才需要,或者如果你的目标是Visual C ++ 6.xBorland
  • Boost.Graph 有一个二进制组件,只有在你打算解析GraphViz文件时才需要它。
  • Boost.Math具有TR1和C99 cmath函数的二进制组件。
  • Boost.Random有一个二进制组件,只有在你使用random_device时才需要它。
  • Boost.Test可用于“仅标题”或“单独编译”模式,但建议单独编译以供严肃使用。
  • Boost.Exception为32位_MSC_VER == 1310_MSC_VER == 1400提供了exception_ptr的非侵入式实现,这需要单独编译的二进制文件。这是由#define BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR启用的。

4. 使用Boost构建一个简单的程序 Build a Simple Program Using Boost

为了简单起见,我们首先使用仅限标头的库。以下程序从标准输入读取整数序列,使用Boost.Lambda将每个数字乘以3,并将它们写入标准输出:

1#include <boost/lambda/lambda.hpp> 2#include <iostream> 3#include <iterator> 4#include <algorithm> 5 6int main() 7{ 8 using namespace boost::lambda; 9 typedef std::istream_iterator<int> in; 10 11 std::for_each( 12 in(std::cin), in(), std::cout << (_1 * 3) << " " ); 13}

将该程序的文本复制到名为example.cpp的文件中。

<div class="yindent"> <b>注意</b><br><br>

要构建本指南中的示例,您可以使用Visual Studio等集成开发环境(IDE),也可以从命令提示符发出命令。由于每个IDE和编译器都有不同的选项,而微软是迄今为止Windows上的主要编译器,我们只为Visual Studio 2005和.NET 2003 IDE以及它们各自的命令提示符编译器提供了具体指示(使用命令提示符稍微简单一点)。如果您使用的是其他编译器或IDE,则可以相对轻松地将这些指令调整到您的环境中。

</div>

4.1 使用Visual Studio IDE构建

<div class="yhelper yindent"> <b>命令提示符基础知识</b><br><br>

在Windows中,通过在命令提示符窗口中键入其名称(后跟可选参数)并按Return(或Enter)键来调用命令行工具。<br>

若要打开通用命令提示符,请单击“开始”菜单按钮,单击“运行”,键入“cmd”,然后单击“确定”<br>

所有命令都在文件系统中当前目录的上下文中执行。要设置当前目录,请键入:<br>

. cd /d path\to\some\directory<br>

然后返回。例如,<br>

. cd /d E:\dev\VS2017\boost_1_69_0<br>

通过在除最后一行之外的所有行的末尾键入插入符号(^),可以在多行中继续执行长命令。本文的一些示例使用该技术来节省水平空间。

</div>
  • 从Visual Studio 2017的“文件”菜单中,选择“新建” > “项目”...

  • 在生成的“新建项目”对话框的左侧窗格中,选择“已安装” > “Visual C++” > “Windows桌面”。

  • 在右侧窗格中,选择 Win32控制台应用程序

  • 在名称字段中,输入example_boost

  • 右键单击“解决方案资源管理器”窗格中的example_boost,然后从弹出的菜单中选择“属性”

  • 在 “配置属性” > “C/C++” > “常规” > “其他包含目录” 中,输入Boost根目录的路径

    E:\dev\VS2017\boost_1_69_0
    
  • 在“配置属性” > “C/C++” > “预编译标题”中,将“使用预编译标题(/Yu)”更改为“不使用预编译标题”。

  • 使用上面的示例代码替换IDE生成的example.cpp的内容。

  • 从Build菜单中,选择Build Solution。

要测试您的应用程序,请按F5键并在结果窗口中键入以下内容,然后按Return键:

    1 2 3

然后按住控制键并按“Z”,然后按Return键。

4.2 从命令提示符构建 Or, Build From the Command Prompt

从计算机的“开始”菜单中,如果您是Visual Studio 2017用户,请选择

.  Visual Studio 2017 > 适用于 VS 2017 的 x64 本机工具命令提示

为Visual Studio编译器调出一个特殊的命令提示符窗口。在该窗口中,将当前目录设置为适合创建一些临时文件的位置,然后键入以下命令,后跟Return键:

cl /EHsc /I E:\dev\VS2017\boost_1_69_0 D:\Users\yaoyu\source\repos\example_boost\example_boost\example_boost.cpp

要测试结果,请键入:

echo 1 2 3 | example_boost

4.3 错误和警告 Errors and Warnings

如果您看到源自Boost头文件的编译器警告,请不要惊慌。我们试图消除它们,但这样做并不总是实用的。错误是另一回事。如果您在本教程中看到编译错误,请检查以确保您已正确复制示例程序并且已正确识别Boost根目录

5 准备使用Boost Library Binary

如果要使用任何单独编译的Boost库,则需要获取库二进制文件。

5.1 使用源代码简单构建

如果您希望使用Visual C++从源代码构建,可以使用本节中描述的简单构建过程。打开命令提示符并将当前目录更改为Boost根目录(Boost root directory)。然后,键入以下命令:

1bootstrap 2.\b2

第一个命令准备Boost.Build系统以供使用。第二个命令调用Boost.Build来构建单独编译的Boost库。有关允许的选项列表,请参阅Boost.Build文档。

5.2 从源构建二进制文件

如果您使用的是早期版本的Visual C++或其他供应商的编译器,则需要使用Boost.Build来创建自己的二进制文件。

5.2.1 安装Boost.Build

Boost.Build是一个基于文本的系统,用于开发,测试和安装软件。首先,您需要构建并安装它。步骤如下:

  1. 转到目录tools\build\
  2. 运行bootstrap.bat
  3. 运行b2 install --prefix=PREFIX, 其中PREFIX是您希望安装Boost.Build的目录
  4. PREFIX\bin添加到PATH环境变量中。

5.2.2 确定工具集 Identify Your Toolset

首先,在下表中找到与编译器对应的工具集(Boost.Build文档中始终提供最新列表)。

<div class="yindent"> <b>注意</b><br>

如果您之前为了构建b2而选择了一个工具集,那么您应该假设它不起作用,而是从下表中新选择。

</div> <table border="1" class="docutils"> <colgroup> <col width="12%"> <col width="22%"> <col width="66%"> </colgroup> <thead valign="bottom"> <tr><th class="head">Toolset Name</th> <th class="head">Vendor</th> <th class="head">Notes</th> </tr> </thead> <tbody valign="top"> <tr><td><tt class="docutils literal">acc</tt></td> <td>Hewlett Packard</td> <td>Only very recent versions are known to work well with Boost</td> </tr> <tr><td><tt class="docutils literal">borland</tt></td> <td>Borland</td> <td>&nbsp;</td> </tr> <tr><td><tt class="docutils literal">como</tt></td> <td>Comeau Computing</td> <td>Using this toolset may require <a class="reference external" href="../../tools/build/index.html">configuring</a> another toolset to act as its backend.</td> </tr> <tr><td><tt class="docutils literal">darwin</tt></td> <td>Apple Computer</td> <td>Apple's version of the GCC toolchain with support for Darwin and MacOS X features such as frameworks.</td> </tr> <tr><td><tt class="docutils literal">gcc</tt></td> <td>The Gnu Project</td> <td>Includes support for Cygwin and MinGW compilers.</td> </tr> <tr><td><tt class="docutils literal">hp\_cxx</tt></td> <td>Hewlett Packard</td> <td>Targeted at the Tru64 operating system.</td> </tr> <tr><td><tt class="docutils literal">intel</tt></td> <td>Intel</td> <td>&nbsp;</td> </tr> <tr><td><tt class="docutils literal">msvc</tt></td> <td>Microsoft</td> <td>&nbsp;</td> </tr> <tr><td><tt class="docutils literal">sun</tt></td> <td>Oracle</td> <td>Only very recent versions are known to work well with Boost. Note that the Oracle/Sun compiler has a large number of options which effect binary compatibility: it is vital that the libraries are built with the same options that your appliction will use. In particular be aware that the default standard library may not work well with Boost, <em>unless you are building for C++11</em>. The particular compiler options you need can be injected with the b2 command line options <tt class="docutils literal"><span class="pre">cxxflags=\`\`and</span> \`\`linkflags=</tt>. For example to build with the Apache standard library in C++03 mode use <tt class="docutils literal">b2 <span class="pre">cxxflags=-library=stdcxx4</span> <span class="pre">linkflags=-library=stdcxx4</span></tt>.</td> </tr> <tr><td><tt class="docutils literal">vacpp</tt></td> <td>IBM</td> <td>The VisualAge C++ compiler.</td> </tr> </tbody> </table>

如果安装了特定编译器的多个版本,则可以将版本号附加到工具集名称,后面加一个连字符,例如intel-9.0或borland-5.4.3。在Windows上,即使您只安装了一个版本(除非您使用的是具有特殊版本检测代码的msvc或gcc工具集),否则auto-linking会失败。

5.2.3 选择构建目录 Select a Build Directory

Boost.Build会将构建时生成的所有中间文件放入**构建目录(build directory)**中。如果您的Boost根目录是可写的,则此步骤不是必需的:默认情况下,Boost.Build将在您当前的工作目录中为此创建bin.v2/子目录。

5.2.4 调用b2 Invoke b2

将当前目录更改为Boost根目录, 并按如下方式调用b2:

b2 --build-dir=build-directory toolset=toolset-name --build-type=complete stage

有关这些和其他调用选项的完整说明,请参阅Boost.Build文档

例如,您的会话可能如下所示:

1C:\WINDOWS> cd /d C:\Program Files\boost\boost_1_69_0 2C:\Program Files\boost\boost_1_69_0> b2 ^ 3More? --build-dir="C:\Documents and Settings\dave\build-boost" ^ 4More? --build-type=complete msvc stage

请务必阅读关于^, More?和该行中的引号(“)的说明

选项 --build-type=complete 会让Boost.Build构建所有支持的库版本。有关如何仅构建特定版本的说明,请在Boost.Build邮件列表中查询。

构建特殊阶段(stage)目标将Boost库二进制文件放在Boost树的stage\lib\子目录中。要使用其他目录,请将--stagedir=directory选项传递给b2。

<div class="yindent"> <b>注意</b><br>

b2区分大小写; 重要的是,上面以<b>粗体</b>显示的所有部件都是完全小写的。

</div>

有关在调用b2时可以传递的其他选项的说明 ,请键入:

b2 --help

特别是,为了限制建设所花费的时间,您可能会对以下内容感兴趣:

  • 使用--show-libraries查看库名列表
  • 使用--with-library-name--without-library-name选项选择要构建(或不构建)的库
  • 通过向命令行添加releasedebug来选择特定的构建版本。
<div class="yindent"> <b>注意</b><br>

Boost.Build可以产生大量的输出,这可以很容易地错过问题。如果要确保一切顺利,可以通过在命令行中附加 > build.log 2>&1 将输出重定向到文件中。

</div>

5.3 预期的构建输出 Expected Build Output

在构建Boost库的过程中,您可以期望在控制台上看到一些消息。这些可能包括

  • 关于Boost库配置的注意事项 - 例如,Regex库在没有Unicode支持的情况下生成有关ICU的消息,如果没有安装Python,可以跳过Python库而不会出现错误(但需要注意)。

  • 来自构建工具的消息,用于报告已构建或跳过的目标数。如果这些数字对你没有任何意义,不要感到惊讶; 每个库有很多目标。

  • 构建描述工具正在做什么的动作消息,如下所示:

    toolset-name.c++ long/path/to/file/being/built
    
  • 编译器警告。

5.4 在构建错误的情况下 In Case of Build Errors

在构建Boost时看到的唯一错误消息(如果有的话)应该与IOStreams库对zip和bzip2格式的支持有关。如果需要这些特性,请安装libz和libbz2的相关开发包。构建Boost库时的其他错误也值得关注。

如果它看起来像编译系统无法找到你的编译器和/或连接器,考虑设置一个user-config.jam文件。如果这不是您的问题或user-config.jam文件不工作,请解决有关将编译器的Boost配置到Boost.Build邮件列表的问题。

6 将您的程序链接到Boost Library

为了演示与Boost二进制库的链接,我们将使用以下简单程序从电子邮件中提取主题行。它使用Boost.Regex库,它具有单独编译的二进制组件。

1#include <boost/regex.hpp> 2#include <iostream> 3#include <string> 4 5int main() 6{ 7 std::string line; 8 boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" ); 9 10 while (std::cin) 11 { 12 std::getline(std::cin, line); 13 boost::smatch matches; 14 if (boost::regex_match(line, matches, pat)) 15 std::cout << matches[2] << std::endl; 16 } 17}

链接有两个主要挑战:

  • 工具配置,例如, 选择命令行选项或IDE构建设置。
  • 在所有构建版本中识别库二进制文件,其编译配置与项目的其余部分兼容。
<div class="yindent"> <b>自动链接</b><br>

大多数Windows编译器和链接器都具有所谓的“自动链接支持”(auto-linking support),这消除了第二个挑战。Boost头文件中的特殊代码检测您的编译器选项,并使用该信息将正确库的名称编码到目标文件中; 链接器从您告诉它搜索的目录中选择具有该名称的库。<br>

GCC工具链(Cygwin和MinGW)是值得注意的例外; GCC用户应参考 linking instructions for Unix variant OSes ,以获取相应的命令行选项。

</div>

6.1 从Visual Studio IDE中链接

从我们之前创建的仅头文件example项目开始:

  1. 右键单击“解决方案资源管理器”窗格中的example,然后从弹出的菜单中选择“属性”
  2. 配置属性 > 链接器 > 附加库目录中,输入Boost二进制文件的路径,例如E:\dev\VS2017\boost_1_69_0\lib64-msvc-14.1
  3. 从Build菜单中,选择Build Solution。

6.2 从命令提示符链接

例如,假设您的Boost二进制文件位于E:\dev\VS2017\boost_1_69_0\lib64-msvc-14.1中,我们可以通过简单地将下面的粗体文本添加到我们之前使用的命令行,从Visual C++命令行编译和链接上述程序。:

1cl /EHsc /I E:\dev\VS2017\boost_1_69_0 example_boost.cpp ^ 2 /link /LIBPATH:E:\dev\VS2017\boost_1_69_0\lib64-msvc-14.1

6.3 库命名 Library Naming

<div class="yindent"> <b>自动链接</b><br>

如果像Visual C++一样,您的编译器支持自动链接,您可以跳到下一步。

</div>

为了配置正确的二进制文件,您需要知道Boost二进制文件是如何命名的。每个库文件名由一组共同的元素序列组成,这些元素描述了它的构建方式。例如,libboost_regex-vc71-mt-d-x86-1_34.lib可以分解为以下元素:

lib

<div class="yblock"> 前缀(Prefix):除Microsoft Windows外,每个Boost库名称都以此字符串开头。在Windows上,只有普通的静态库(ordinary static libraries)使用lib前缀; 导入库和DLL没有。 </div>

boost_regex

<div class="yblock"> 库名(Library name):所有boost库文件名都以boost\_开头。 </div>

-vc71

<div class="yblock"> 工具集标记(Toolset tag):标识用于构建二进制文件的工具集和版本。 </div>

-mt

<div class="yblock"> 线程标记(Threading tag):表示库是在启用多线程(multithreading)支持的情况下构建的。没有多线程支持而构建的库可以通过去掉 -mt 来识别。 </div>

-d

<div class="yblock"> ABI标记:对影响库与其他编译代码的互操作性的细节进行编码。对于每个此类功能,标记中都会添加一个字母: <table border="1" class="docutils"> <colgroup> <col width="5%"> <col width="75%"> <col width="20%"> </colgroup> <thead valign="bottom"> <tr><th class="head">Key</th> <th class="head">Use this library when:</th> <th class="head">Boost.Build option</th> </tr> </thead> <tbody valign="top"> <tr><td><tt class="docutils literal">s</tt></td> <td>linking statically to the C++ standard library and compiler runtime support libraries.</td> <td>runtime-link=static</td> </tr> <tr><td><tt class="docutils literal">g</tt></td> <td>using debug versions of the standard and runtime support libraries.</td> <td>runtime-debugging=on</td> </tr> <tr><td><tt class="docutils literal">y</tt></td> <td>using a special <a class="reference external" href="../../libs/python/doc/html/building/python\_debugging\_builds.html">debug build of Python</a>.</td> <td>python-debugging=on</td> </tr> <tr><td><tt class="docutils literal">d</tt></td> <td>building a debug version of your code.<a class="footnote-reference" href="#debug-abi" id="id24"><sup>6</sup></a></td> <td>variant=debug</td> </tr> <tr><td><tt class="docutils literal">p</tt></td> <td>using the STLPort standard library rather than the default one supplied with your compiler.</td> <td>stdlib=stlport</td> </tr> </tbody> </table>

例如,如果构建代码的调试版本以用于静态运行时库和STLPort标准库的调试版本,则标记将为:-sgdp。如果以上都不适用,则省略ABI标记。

</div>

-x86

<div class="yblock"> 体系结构和地址模式标记(Architecture and address model tag):在第一个字母中,对体系结构进行如下编码: <table border="1" class="docutils"> <colgroup> <col width="11%"> <col width="41%"> <col width="48%"> </colgroup> <thead valign="bottom"> <tr><th class="head">Key</th> <th class="head">Architecture</th> <th class="head">Boost.Build option</th> </tr> </thead> <tbody valign="top"> <tr><td><tt class="docutils literal">x</tt></td> <td>x86-32, x86-64</td> <td>architecture=x86</td> </tr> <tr><td><tt class="docutils literal">a</tt></td> <td>ARM</td> <td>architecture=arm</td> </tr> <tr><td><tt class="docutils literal">i</tt></td> <td>IA-64</td> <td>architecture=ia64</td> </tr> <tr><td><tt class="docutils literal">s</tt></td> <td>Sparc</td> <td>architecture=sparc</td> </tr> <tr><td><tt class="docutils literal">m</tt></td> <td>MIPS/SGI</td> <td>architecture=mips\*</td> </tr> <tr><td><tt class="docutils literal">p</tt></td> <td>RS/6000 &amp; PowerPC</td> <td>architecture=power</td> </tr> </tbody> </table>

字母后面的两位数字对地址模型进行编码,如下所示:

<table border="1" class="docutils"> <colgroup> <col width="13%"> <col width="40%"> <col width="47%"> </colgroup> <thead valign="bottom"> <tr><th class="head">Key</th> <th class="head">Address model</th> <th class="head">Boost.Build option</th> </tr> </thead> <tbody valign="top"> <tr><td><tt class="docutils literal">32</tt></td> <td>32 bit</td> <td>address-model=32</td> </tr> <tr><td><tt class="docutils literal">64</tt></td> <td>64 bit</td> <td>address-model=64</td> </tr> </tbody> </table> </div>

-1_34

<div class="yblock"> 版本标签(Version tag):完整的Boost版本号,点号由下划线替换。例如,版本1.31.1将标记为“-1\_31\_1”。 </div>

.lib

<div class="yblock"> 扩展名(Extension):根据操作系统的惯例确定。在大多数unix风格的平台上,扩展名分别为 .a 和 .so,分别用于静态库(归档)和共享库。在Windows上,.dll表示共享库,.lib表示静态库或导入库。在unix变体上的工具集支持的情况下,添加完整版本扩展(例如“.so.1.34”),并且还将创建指向没有尾随版本号的库文件的符号链接。 </div>

6.4 测试 Test Your Program

为了测试我们的主题提取,我们将过滤以下文本文件。将其从浏览器中复制并保存为jayne.txt

1To: George Shmidlap 2From: Rita Marlowe 3Subject: Will Success Spoil Rock Hunter? 4--- 5See subject.

现在,在命令提示符窗口中,键入:

1path\to\compiled\example < path\to\jayne.txt 2D:\Users\yaoyu\source\repos\example_boost\example_boost>example_boost.exe < jayne.txt

程序应输出电子邮件主题, “Will Success Spoil Rock Hunter?”

7 结论和进一步的资源 Conclusion and Further Resources

最后介绍了Boost并将其与您的程序集成。当你开始认真地使用Boost时,肯定会有一些你希望我们覆盖的额外点。有一天,我们可能会在“入门系列”中找到“第2册”来解决这些问题。在此之前,我们建议您继续使用以下资源。如果您无法找到所需内容,或者我们可以采取任何措施使此文档更加清晰,请将其发布到Boost用户的邮件列表中。

<div class="yindent"> <b>向前 Onward</b><br><br>

祝好运并玩得开心点! Good luck, and have fun!

<p align="right">— the Boost Developers</p> </div>
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )

Boost(1.69.0) windows入门(译) - HelloWorld