<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Emacs on despatches</title><link>https://icle.es/tags/emacs/</link><description>Recent content in Emacs on despatches</description><generator>Hugo</generator><language>en</language><lastBuildDate>Fri, 20 Jun 2025 09:25:00 +0100</lastBuildDate><atom:link href="https://icle.es/tags/emacs/index.xml" rel="self" type="application/rss+xml"/><item><title>Getting Started: Emacs &amp;amp; C++ (w/ cmake) (On the fly syntax highlighting)</title><link>https://icle.es/2013/02/24/getting-started-emacs-c-w-cmake/</link><pubDate>Sun, 24 Feb 2013 11:54:03 +0000</pubDate><guid>https://icle.es/2013/02/24/getting-started-emacs-c-w-cmake/</guid><description>&lt;p>I am a recent convert to emacs. My vast majority of development is in Java EE
and I have not found an easy way to get the functionality in eclipse into emacs.
So I still use eclipse for this.&lt;/p>
&lt;p>However, I like to tinker with C++ and I wanted to get some of the CDT
functionality into emacs. In truth, I have used very little CDT so my
expectations from emacs will be set differently. Considering that emacs has been
used for C/C++ development for decades, I am hopeful that it will be more
feature-rich than eclipse or any of the other IDE&amp;rsquo;s like Anjuta, Code::Blocks
etc (both I have tried to use).&lt;/p>
&lt;p>First things first. In the world of Java, I am a massive fan of maven which
makes build management so easy and simple. Having used it now for years, it is
easy to forget how much of a learning curve it had to get started.&lt;/p>
&lt;p>Autotools are a massive pain to use and has a very steep learning curve. I have
used it in the past to set up build environments and it works fine. pkg-config
is pretty awesome and in a lot of ways, maven does pale in comparison. i.e.
instead of having maven pull in dependencies, you just use your systems package
manager like apt-get or yum and it installs the libraries for you.&lt;/p></description><content:encoded><![CDATA[<p>I am a recent convert to emacs. My vast majority of development is in Java EE
and I have not found an easy way to get the functionality in eclipse into emacs.
So I still use eclipse for this.</p>
<p>However, I like to tinker with C++ and I wanted to get some of the CDT
functionality into emacs. In truth, I have used very little CDT so my
expectations from emacs will be set differently. Considering that emacs has been
used for C/C++ development for decades, I am hopeful that it will be more
feature-rich than eclipse or any of the other IDE&rsquo;s like Anjuta, Code::Blocks
etc (both I have tried to use).</p>
<p>First things first. In the world of Java, I am a massive fan of maven which
makes build management so easy and simple. Having used it now for years, it is
easy to forget how much of a learning curve it had to get started.</p>
<p>Autotools are a massive pain to use and has a very steep learning curve. I have
used it in the past to set up build environments and it works fine. pkg-config
is pretty awesome and in a lot of ways, maven does pale in comparison. i.e.
instead of having maven pull in dependencies, you just use your systems package
manager like apt-get or yum and it installs the libraries for you.</p>
<p>Long story short, I am using <a href="http://www.cmake.org/" title="CMake">cmake</a> which has
the added advantage of being a little more cross-platform (i.e. supported in
Windows as well as *nix). If you haven&rsquo;t used CMake before, let me tell you -
it&rsquo;s a heck of a lot easier to get used to than Autotools. Just go through their
<a href="http://www.cmake.org/cmake/help/cmake_tutorial.html" title="CMake Tutorial">tutorial</a>
and you should be off.</p>
<p>The next thing I wanted to sort out was on the fly syntax checking. This makes
life a lot easier and means that you can write and correct syntax errors etc
without having to build manually.</p>
<p><a href="http://www.emacswiki.org/emacs/FlyMake">Flymake</a> is what you want to use for
this. The later versions of emacs comes with Flymake so you won&rsquo;t necessary need
to install it to get started. However, flymake doesn&rsquo;t (unfortunately) just work
magically out of the box and requires a little configuration.</p>
<p>After hunting around for a bit, and finally from the
<a href="http://www.emacswiki.org/emacs/FlyMake">EmacsWiki Flymake</a> page, found a couple
of options <a href="https://github.com/redguardtoo/cpputils-cmake">cpputils-make</a> and
<a href="https://github.com/alamaison/emacs-cmake-project">cmake-project</a>. Cmake-project
seemed simpler and I opted for that. I also tried installing cpputils-make and
didn&rsquo;t have any issues with that either.</p>
<p>There is one thing you need to be aware of though - both these tools expect you
to do out-of-source-builds. This essentially requires you to create a build
folder (called bin for cmake-project and build for cpputils-make) and generate
the Makefile etc. in there.</p>
<p>This is the preferred way with CMake anyway so it&rsquo;ll be better to do build in
that way. It&rsquo;ll also  make it easier to have different builds (Debug/Release
etc.)</p>
<p>The easiest way to install either of these is through marmalade. If you don&rsquo;t
already have it installed - it is so easy - just follow the instructions on
their <a href="http://marmalade-repo.org/">homepage</a>. You can then install by running</p>
<p><code>M-x package-install cmake-project</code></p>
<p>OR</p>
<p><code>M-x package-install cpputils-cmake</code></p>
<p>add the following to your .emacs file for cmake project. Instructions for
cpputils-make can be found on
<a href="https://github.com/redguardtoo/cpputils-cmake">their github page</a></p>
<p>[(require &lsquo;cmake-project)]{style=&ldquo;font-family:Consolas, Monaco,
monospace;font-size:12px;line-height:18px;&rdquo;}</p>
<p>Do a full build on your sources first by going to the bin or build directory and
generating the makefiles by using cmake (cmake .. or cmake ../src depending on
how you set up cmake) and then make.</p>
<p>You can then initialise the mode within emacs for cmake:</p>
<p><code>M-x cmake-project-mode</code></p>
<p>You may have to also enable flymake;</p>
<p><code>M-x flymake-mode</code></p>]]></content:encoded></item></channel></rss>