title: C++ - Using HunSpell 1.3.2 with Visual Studio 2010
body: <p>My goal is to create a simple Win32 Console application that uses HunSpell to spell-check a word the user has entered.
  I tried to follow <a href="http://www.codeproject.com/Articles/21381/Spell-Checking-Edit-Control-Using-HunSpell" rel="nofollow">this codeproject tutorial</a> which is for Visual Studio 2008 and HunSpell 1.2.1.</p>
  
  <p>I don’t want to use the provided code, since I intend to write my own.
  Furthermore I want to add HunSpell as a dll, not as a static library.</p>
  
  <p>Following are the steps I took:</p>
  
  <ol>
  <li>Created a Win32 console (empty) project with the name myproject.</li>
  <li>Downloaded HunSpell 1.3.2 from SourceForge.org.</li>
  <li>Copied <strong>hunspell-1.3.2\src\hunspell</strong> and <strong>win_api</strong> to <strong>myproject\myproject\HunSpell-Src</strong></li>
  <li>Added and converted project libhunspell <strong>myproject\myproject\HunSpell-Src\win-api\libhunspell.vcproj</strong>
  to the solution.</li>
  <li>Made my debug build use debug_dll and my release build release_dll of libhunspell in the Configuration Manager.</li>
  <li>Rebuilt the libhunspell project, <em>libhunspell.dll</em> is generated in debug_dll and release_dll folders respectively.</li>
  <li>Made my console project depend on libhunspell. (Added reference to libhunspell)</li>
  <li>Copied dictionary files en_US.aff &amp; en_US.dic to <strong>myproject\myproject\HunSpell-Dic</strong> after downloading them from SourceForge.org.</li>
  </ol>
  
  <p>I can’t figure out how/where to add the processor define HSPELLEDIT_DLL that is mentioned in the codeproject tutorial.</p>
  
  <p>Following the steps listed under “To use the functionality from the class library in the console application” on <a href="http://msdn.microsoft.com/en-us/library/ms235636%28v=VS.100%29.aspx" rel="nofollow">MSDN</a> didn’t changed the result.</p>
  
  <p>I want to test it with a program like this:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "HunSpell-Src/win_api/hunspelldll.h"
  
  using namespace std;
  
  void main()
  {
      void *spellObj = hunspell_initialize("HunSpell-Dic\\en_us.aff", "HunSpell-Dic\\en_us.dic");
  
      char str[60];
  
      cin &gt;&gt; str;
  
      int result = hunspell_spell(spellObj, str);
  
      if(result == 0)
          cout &lt;&lt; "Spelling error!";
      else
          cout &lt;&lt; "Correct Spelling!";
  
      hunspell_uninitialize(spellObject);
  }
  </code></pre>
  
  <p>VS produces the following error message if I try to compile it:</p>
  
  <pre><code>myproject\myproject\hunspell-src\win_api\hunspelldll.h(34): fatal error C1083: Cannot open include file: 'hunspell.hxx': No such file or directory
  </code></pre>
  
  <p>Hunspell.hxx is present in myproject\myproject\HunSpell-Src\hunspell. IntelliSense marks the #include "hunspell.hxx" as an error while the tab hasn’t focus with the message “Error: cannot open source file hunspell.hxx”, but after giving  focus  to it the error disappears.</p>
  
  <p>Thank you for your help.</p>