<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="compilation-problems">
      </a>
      2.8.8 Dealing with Problems Compiling MySQL
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045327231168">
  </a>
  <a class="indexterm" name="idm46045327229712">
  </a>
  <a class="indexterm" name="idm46045327228224">
  </a>
  <a class="indexterm" name="idm46045327227152">
  </a>
  <a class="indexterm" name="idm46045327226080">
  </a>
  <p>
   The solution to many problems involves reconfiguring. If you do
      reconfigure, take note of the following:
  </p>
  <a class="indexterm" name="idm46045327224064">
  </a>
  <a class="indexterm" name="idm46045327222976">
  </a>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      If
      <span class="command">
       <strong>
        CMake
       </strong>
      </span>
      is run after it has previously
          been run, it may use information that was gathered during its
          previous invocation. This information is stored in
      <code class="filename">
       CMakeCache.txt
      </code>
      . When
      <span class="command">
       <strong>
        CMake
       </strong>
      </span>
      starts, it looks for that file and
          reads its contents if it exists, on the assumption that the
          information is still correct. That assumption is invalid when
          you reconfigure.
     </p>
    </li>
    <li class="listitem">
     <p>
      Each time you run
      <span class="command">
       <strong>
        CMake
       </strong>
      </span>
      , you must run
      <span class="command">
       <strong>
        make
       </strong>
      </span>
      again to recompile. However, you may
          want to remove old object files from previous builds first
          because they were compiled using different configuration
          options.
     </p>
    </li>
   </ul>
  </div>
  <p>
   To prevent old object files or configuration information from
      being used, run the following commands before re-running
   <span class="command">
    <strong>
     CMake
    </strong>
   </span>
   :
  </p>
  <p>
   On Unix:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa54170404"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">make</span> clean
<span class="token prompt">$&gt; </span><span class="token command">rm</span> CMakeCache<span class="token punctuation">.</span>txt</code></pre>
  </div>
  <p>
   On Windows:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa38603725"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">devenv</span> MySQL<span class="token punctuation">.</span>sln /clean
<span class="token prompt">$&gt; </span><span class="token command">del</span> CMakeCache<span class="token punctuation">.</span>txt</code></pre>
  </div>
  <p>
   If you build outside of the source tree, remove and recreate your
      build directory before re-running
   <span class="command">
    <strong>
     CMake
    </strong>
   </span>
   . For
      instructions on building outside of the source tree, see
   <a class="ulink" href="/doc/internals/en/cmake.html" target="_top">
    How to Build MySQL
      Server with CMake
   </a>
   .
  </p>
  <p>
   On some systems, warnings may occur due to differences in system
      include files. The following list describes other problems that
      have been found to occur most often when compiling MySQL:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045327205024">
      </a>
      <a class="indexterm" name="idm46045327203952">
      </a>
      <a class="indexterm" name="idm46045327202496">
      </a>
      <a class="indexterm" name="idm46045327201408">
      </a>
      To define which C and C++ compilers to use, you can define the
      <code class="literal">
       CC
      </code>
      and
      <code class="literal">
       CXX
      </code>
      environment
          variables. For example:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa1424336"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">CC</span><span class="token attr-value"><span class="token punctuation">=</span>gcc</span>
<span class="token prompt">$&gt; </span><span class="token command">CXX</span><span class="token attr-value"><span class="token punctuation">=</span>g++</span>
<span class="token prompt">$&gt; </span><span class="token command">export</span> CC CXX</code></pre>
     </div>
     <p>
      While this can be done on the command line, as just shown, you
          may prefer to define these values in a build script, in which
          case the
      <span class="command">
       <strong>
        export
       </strong>
      </span>
      command is not needed.
     </p>
     <p>
      To specify your own C and C++ compiler flags, use the
      <a class="link" href="source-configuration-options.html#option_cmake_cmake_c_flags">
       <code class="option">
        CMAKE_C_FLAGS
       </code>
      </a>
      and
      <a class="link" href="source-configuration-options.html#option_cmake_cmake_cxx_flags">
       <code class="option">
        CMAKE_CXX_FLAGS
       </code>
      </a>
      CMake options.
          See
      <a class="xref" href="source-configuration-options.html#cmake-compiler-flags" title="Compiler Flags">
       Compiler Flags
      </a>
      .
     </p>
     <p>
      To see what flags you might need to specify, invoke
      <a class="link" href="mysql-config.html" title="6.7.1 mysql_config — Display Options for Compiling Clients">
       <span class="command">
        <strong>
         mysql_config
        </strong>
       </span>
      </a>
      with the
      <a class="link" href="mysql-config.html#option_mysql_config_cflags">
       <code class="option">
        --cflags
       </code>
      </a>
      and
      <a class="link" href="mysql-config.html#option_mysql_config_cxxflags">
       <code class="option">
        --cxxflags
       </code>
      </a>
      options.
     </p>
    </li>
    <li class="listitem">
     <p>
      To see what commands are executed during the compile stage,
          after using
      <span class="command">
       <strong>
        CMake
       </strong>
      </span>
      to configure MySQL, run
      <span class="command">
       <strong>
        make VERBOSE=1
       </strong>
      </span>
      rather than just
      <span class="command">
       <strong>
        make
       </strong>
      </span>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      If compilation fails, check whether the
      <a class="link" href="source-configuration-options.html#option_cmake_mysql_maintainer_mode">
       <code class="option">
        MYSQL_MAINTAINER_MODE
       </code>
      </a>
      option is
          enabled. This mode causes compiler warnings to become errors,
          so disabling it may enable compilation to proceed.
     </p>
    </li>
    <li class="listitem">
     <p>
      If your compile fails with errors such as any of the
          following, you must upgrade your version of
      <span class="command">
       <strong>
        make
       </strong>
      </span>
      to GNU
      <span class="command">
       <strong>
        make
       </strong>
      </span>
      :
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-simple"><div class="docs-select-all right" id="sa672357"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">make<span class="token operator">:</span> Fatal error in reader<span class="token operator">:</span> Makefile<span class="token punctuation">,</span> line 18<span class="token operator">:</span>
Badly formed macro assignment</code></pre>
     </div>
     <p>
      Or:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa80210457"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">make<span class="token operator">:</span> file `Makefile' line 18<span class="token operator">:</span> Must be a separator <span class="token punctuation">(</span><span class="token operator">:</span></code></pre>
     </div>
     <p>
      Or:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa71403045"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">pthread<span class="token punctuation">.</span>h<span class="token operator">:</span> No such file or directory</code></pre>
     </div>
     <a class="indexterm" name="idm46045327175440">
     </a>
     <a class="indexterm" name="idm46045327174368">
     </a>
     <p>
      Solaris and FreeBSD are known to have troublesome
      <span class="command">
       <strong>
        make
       </strong>
      </span>
      programs.
     </p>
     <p>
      GNU
      <span class="command">
       <strong>
        make
       </strong>
      </span>
      3.75 is known to work.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <code class="filename">
       sql_yacc.cc
      </code>
      file is generated from
      <code class="filename">
       sql_yacc.yy
      </code>
      . Normally, the build process
          does not need to create
      <code class="filename">
       sql_yacc.cc
      </code>
      because MySQL comes with a pregenerated copy. However, if you
          do need to re-create it, you might encounter this error:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa4001456"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">"sql_yacc<span class="token punctuation">.</span>yy"<span class="token punctuation">,</span> line <em class="replaceable">xxx</em> fatal<span class="token operator">:</span> default action causes potential<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
     </div>
     <p>
      This is a sign that your version of
      <span class="command">
       <strong>
        yacc
       </strong>
      </span>
      is
          deficient. You probably need to install a recent version of
      <span class="command">
       <strong>
        bison
       </strong>
      </span>
      (the GNU version of
      <span class="command">
       <strong>
        yacc
       </strong>
      </span>
      ) and use that instead.
     </p>
     <p>
      Versions of
      <span class="command">
       <strong>
        bison
       </strong>
      </span>
      older than 1.75 may
          report this error:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa99799362"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">sql_yacc<span class="token punctuation">.</span>yy<span class="token operator">:</span><span class="token comment" spellcheck="true">#####: fatal error: maximum table size (32767) exceeded</span></code></pre>
     </div>
     <p>
      The maximum table size is not actually exceeded; the error is
          caused by bugs in older versions of
      <span class="command">
       <strong>
        bison
       </strong>
      </span>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   For information about acquiring or updating tools, see the system
      requirements in
   <a class="xref" href="source-installation.html" title="2.8 Installing MySQL from Source">
    Section 2.8, “Installing MySQL from Source”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
