【问题标题】:MySQL Connect/C++ 64 bit build errorMySQL Connect/C++ 64 位构建错误
【发布时间】:2013-01-19 04:44:19
【问题描述】:

我正在使用 Netbeans 和 MacoSX 并安装了 64 位连接器。在构建时出现以下错误:

/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
/usr/bin/make  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/inventory
mkdir -p build/Debug/GNU-MacOSX
rm -f build/Debug/GNU-MacOSX/addproduct.o.d
g++    -c -g -Iinclude -Iinclude -MMD -MP -MF build/Debug/GNU-MacOSX/addproduct.o.d -o build/Debug/GNU-MacOSX/addproduct.o addproduct.cpp
                 from addproduct.cpp:10:
In file included from include/mysql_connection.h:30,
include/cppconn/connection.h:31:29: warning: boost/variant.hpp: No such file or directory
In file included from addproduct.cpp:10:
include/mysql_connection.h:31:32: warning: boost/shared_ptr.hpp: No such file or directory
                 from addproduct.cpp:10:
In file included from include/mysql_connection.h:30,
include/cppconn/connection.h:41: error: 'boost' has not been declared
include/cppconn/connection.h:41: error: expected initializer before '<' token
include/cppconn/connection.h:43: error: 'ConnectPropertyVal' was not declared in this scope
include/cppconn/connection.h:43: error: template argument 2 is invalid
include/cppconn/connection.h:43: error: template argument 4 is invalid
include/cppconn/connection.h:43: error: invalid type in declaration before ';' token
In file included from addproduct.cpp:10:
include/mysql_connection.h:75: error: 'ConnectPropertyVal' is not a member of 'sql'
include/mysql_connection.h:75: error: 'ConnectPropertyVal' is not a member of 'sql'
include/mysql_connection.h:75: error: template argument 2 is invalid
include/mysql_connection.h:75: error: template argument 4 is invalid
include/mysql_connection.h:157: error: 'ConnectPropertyVal' is not a member of 'sql'
include/mysql_connection.h:157: error: 'ConnectPropertyVal' is not a member of 'sql'
include/mysql_connection.h:157: error: template argument 2 is invalid
include/mysql_connection.h:157: error: template argument 4 is invalid
include/mysql_connection.h:160: error: 'boost' has not been declared
include/mysql_connection.h:160: error: ISO C++ forbids declaration of 'shared_ptr' with no type
include/mysql_connection.h:160: error: expected ';' before '<' token
make[2]: *** [build/Debug/GNU-MacOSX/addproduct.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 538ms)

在 Netbeans 中,我只链接 libmysqlcppconn.dylib

我缺少哪些文件? 为什么要求 BOOST?我需要安装哪些 Boost Lib?

【问题讨论】:

    标签: c++ mysql netbeans mysql-connector


    【解决方案1】:

    mysql_connection.h 包含 #include &lt;boost/shared_ptr.hpp&gt;,您可以使用最新版本的 boost 或修改下面的行 mysql_connection.h 以使用 std::shared_ptr 代替:

    更新

    #include <boost/shared_ptr.hpp>
    boost::shared_ptr< NativeAPI::NativeConnectionWrapper > proxy;
    

    #include <memory>
    std::shared_ptr< NativeAPI::NativeConnectionWrapper > proxy;
    

    【讨论】:

    • 在线 std::shared_ptr proxy; 上面写着:Unable to resolve identifier shared_ptr
    • 如果您的编译器不是最新版本,可能需要#include &lt;tr1/memory&gt;std::tr1::shared_ptr
    • 让我告诉你 Boost 是通过 Macport 安装的,但 NOT 链接在 NETbeans 项目中。我无法找到所需的 Lib
    • 我不知道Netbeans,不过就是加了-I包含路径和-L链接路径
    • 你说得对。我正在尝试包含安装 Boost 的路径。但是我很好奇为什么它没有加载本机内存头文件?
    【解决方案2】:

    您是否阅读过标题为“21.4.2. Installing MySQL Connector/C++ from Source”的文档?仔细阅读整个页面,然后寻找特定于 MacOSX 的链接...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-12
      • 2012-12-27
      相关资源
      最近更新 更多