<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="https://shaozk.xyz/feed_style.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <tabi:metadata xmlns:tabi="https://github.com/welpo/tabi">
        <tabi:base_url>https:&#x2F;&#x2F;shaozk.xyz</tabi:base_url>
        <tabi:separator>
            •
        </tabi:separator>
        <tabi:about_feeds>This is a web feed, also known as an Atom feed. Subscribe by copying the URL from the address bar into your newsreader. Visit About Feeds to learn more and get started. It&#x27;s free.</tabi:about_feeds>
        <tabi:visit_the_site>Visit website</tabi:visit_the_site>
        <tabi:recent_posts>Recent posts</tabi:recent_posts>
        <tabi:last_updated_on>Updated on $DATE</tabi:last_updated_on>
        <tabi:default_theme></tabi:default_theme>
        <tabi:post_listing_date>date</tabi:post_listing_date>
        <tabi:current_section>bear</tabi:current_section>
    </tabi:metadata><title>shaozk - bear</title>
    <link href="https://shaozk.xyz/tags/bear/atom.xml" rel="self" type="application/atom+xml"/>
    <link href="https://shaozk.xyz/tags/bear/" rel="alternate" type="text/html"/>
    <generator uri="https://www.getzola.org/">Zola</generator><updated>2026-07-12T00:00:00+00:00</updated><id>https://shaozk.xyz/tags/bear/atom.xml</id><entry xml:lang="en">
        <title>使用 Bear 生成 compile_commands.json</title>
        <published>2026-07-12T00:00:00+00:00</published>
        <updated>2026-07-12T00:00:00+00:00</updated>
        <author>
            <name>shaozk</name>
        </author>
        <link rel="alternate" href="https://shaozk.xyz/blog/007-use-bear-for-make/" type="text/html"/>
        <id>https://shaozk.xyz/blog/007-use-bear-for-make/</id>
        
            <content type="html">&lt;p&gt;最近使用 Helix 写 C++ ，为了实现在代码间快速导航，需要在 CMake 构建时额外增加选项 &lt;code&gt;-DCMAKE_EXPORT_COMPILE_COMMANDS=ON&lt;&#x2F;code&gt; 来自动生成 compile_commands.json 文件。&lt;&#x2F;p&gt;
&lt;p&gt;然而有些代码直接用 make 构建的，但 make 没有选项支持生成 compile_commands.json 文件（OS：我也不想给它们一一补上 CMakeLists.txt）。&lt;&#x2F;p&gt;
&lt;p&gt;这个时候，可以使用 bear 工具：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;bear&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; -- make&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;执行完命令就会生成 compile_commands.json 文件，我又可以愉快地使用 Helix 了。&lt;&#x2F;p&gt;
&lt;p&gt;等等如果连 make 都没有该怎么办呢？Bear 早就帮你想到了。&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;bear&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; --&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;your-build-comman&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt;d&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;任何构建命令 bear 工具都支持，你可以直接把构建命令或构建脚本直接传给 bear 。&lt;&#x2F;p&gt;
&lt;h1 id=&quot;can-kao&quot;&gt;参考&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;https:&#x2F;&#x2F;github.com&#x2F;rizsotto&#x2F;Bear&lt;&#x2F;li&gt;
&lt;li&gt;https:&#x2F;&#x2F;zhuanlan.zhihu.com&#x2F;p&#x2F;2003798816588067858&lt;&#x2F;li&gt;
&lt;li&gt;https:&#x2F;&#x2F;www.annya.work&#x2F;bear&#x2F;bear.html&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        </entry>
</feed>
