title: mysql c++ connector error: linker command failed with exit code 1
body: <p>The error is:</p>
  
  <pre><code>Undefined symbols for architecture x86_64:
    "_mysql_init", referenced from:
        _main in dao-8fe5b4.o
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  
  <p>when I tried to compile the cpp file using the following command.</p>
  
  <pre><code>g++ -o test_install   -I/usr/local/include -I/usr/local/include/cppconn -L/usr/local/lib dao.cc
  </code></pre>
  
  <p>The dao.cc file is:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdio&gt;
  #include &lt;mysql/mysql.h&gt;
  
  using namespace std;
  
  int
  main() {
      MYSQL mysql;
      mysql_init(&amp;mysql);
      return 0;
  }
  </code></pre>
  
  <p>When I do not call mysql_init function, there is no error. So the "include" procedure is correct.</p>
  
  <p>The header files are in /usr/local/inclulde and /usr/local/cppconn, and in /usr/local/lib, the lib files are:</p>
  
  <pre><code>libmysqlclient.18.dylib        libmysqlcppconn-static.a
  libmysqlclient.a               libmysqlcppconn.7.1.1.6.dylib
  libmysqlclient.dylib           libmysqlcppconn.7.dylib
  libmysqlclient_r.18.dylib      libmysqlcppconn.dylib
  libmysqlclient_r.a             libmysqld.a
  libmysqlclient_r.dylib         libmysqlservices.a
  </code></pre>
  
  <p>But why it can not link to the functions?</p>