gpt4 book ai didi

c++ - Visual Studio Community 2017 链接器问题 - MariaDB

转载 作者:行者123 更新时间:2023-11-30 05:07:14 24 4
gpt4 key购买 nike

这是我第一次尝试在 Visual Studio 中处理数据库编程(特别是 MariaDB),但运气不佳。看起来我没有正确配置外部链接,但是我盯着我的设置看,却没有看到错误。对于更有经验的编码人员来说,这可能是显而易见的,但我只见树木不见森林。

我已经尝试使用各自的库在 x86 和 64 位中进行编译。我只包括了下面的 x86 设置,但它们是相同的 APART 从指向“程序文件”而不是“程序文件 x86”

目前我的代码非常简单:

#include "stdafx.h"
#include <mysql.h>

int main()
{
MYSQL* temp;
temp = mysql_init(NULL);

return 0;
}

但是当我尝试编译时,我得到了以下输出。

1>------ Build started: Project: test, Configuration: Debug Win32 ------
1>test.cpp
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>mariadbclient.lib(mariadb_lib.obj) : error LNK2019: unresolved external symbol __imp__ntohs@4 referenced in function _mysql_once_init
1>mariadbclient.lib(mariadb_lib.obj) : error LNK2019: unresolved external symbol __imp__getservbyname@8 referenced in function _mysql_once_init
1>mariadbclient.lib(mariadb_lib.obj) : error LNK2019: unresolved external symbol __imp__PathRemoveExtensionA@4 referenced in function _mysql_optionsv
1>mariadbclient.lib(mariadb_lib.obj) : error LNK2019: unresolved external symbol __imp__PathStripPathA@4 referenced in function _mysql_optionsv
1>mariadbclient.lib(ma_init.obj) : error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function _my_win_init
1>mariadbclient.lib(ma_init.obj) : error LNK2019: unresolved external symbol __imp__WSACleanup@0 referenced in function _ma_end
1>mariadbclient.lib(ma_pvio.obj) : error LNK2019: unresolved external symbol __imp__WSAGetLastError@0 referenced in function _ma_pvio_read_async
1>mariadbclient.lib(mariadb_async.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
1>mariadbclient.lib(pvio_socket.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
1>mariadbclient.lib(ma_default.obj) : error LNK2019: unresolved external symbol __imp__PathRemoveFileSpecA@4 referenced in function _get_default_configuration_dirs
1>mariadbclient.lib(mariadb_async.obj) : error LNK2019: unresolved external symbol __imp__connect@12 referenced in function _my_connect_async
1>mariadbclient.lib(pvio_socket.obj) : error LNK2001: unresolved external symbol __imp__connect@12
1>mariadbclient.lib(mariadb_async.obj) : error LNK2019: unresolved external symbol __imp__getsockopt@20 referenced in function _my_connect_async
1>mariadbclient.lib(pvio_socket.obj) : error LNK2001: unresolved external symbol __imp__getsockopt@20
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol ___WSAFDIsSet@8 referenced in function _pvio_socket_wait_io_or_timeout
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__bind@12 referenced in function _pvio_socket_connect
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__closesocket@4 referenced in function _pvio_socket_connect
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__ioctlsocket@12 referenced in function _pvio_socket_blocking
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__recv@16 referenced in function _pvio_socket_async_read
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__select@20 referenced in function _pvio_socket_wait_io_or_timeout
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__send@16 referenced in function _pvio_socket_async_write
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__setsockopt@20 referenced in function _pvio_socket_fast_send
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__shutdown@8 referenced in function _pvio_socket_close
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__socket@12 referenced in function _pvio_socket_connect
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__WSASetLastError@4 referenced in function _pvio_socket_wait_io_or_timeout
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__getaddrinfo@16 referenced in function _pvio_socket_connect
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__freeaddrinfo@4 referenced in function _pvio_socket_connect
1>mariadbclient.lib(ma_schannel.obj) : error LNK2019: unresolved external symbol __imp__CryptAcquireContextA@20 referenced in function _ma_schannel_load_private_key
1>mariadbclient.lib(ma_schannel.obj) : error LNK2019: unresolved external symbol __imp__CryptReleaseContext@8 referenced in function _ma_schannel_load_private_key
1>mariadbclient.lib(ma_schannel.obj) : error LNK2019: unresolved external symbol __imp__CryptDestroyKey@4 referenced in function _ma_schannel_load_private_key
1>mariadbclient.lib(ma_schannel.obj) : error LNK2019: unresolved external symbol __imp__CryptImportKey@24 referenced in function _ma_schannel_load_private_key
1>d:\nikuya\documents\visual studio 2017\Projects\test\Debug\test.exe : fatal error LNK1120: 27 unresolved externals
1>Done building project "test.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我的设置如下 -

VC++ Directories -> Include Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\include\mysql
VC++ Directories -> Include Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\include\mysql\include
VC++ Directories -> Library Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\lib
VC++ Directories -> Library Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\lib\plugin
C++ Directories -> Addition Include Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\include\mysql
C++ Directories -> Addition Include Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\include
Linker -> General -> Addition Library Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\lib\plugin
Linker -> General -> Addition Library Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\lib
Linker -> Additional Dependancies -> mariadbclient.lib
Linker -> Additional Dependancies -> libmariadb.lib

如有任何帮助,我们将不胜感激,请询问是否需要任何进一步的信息。

注意:出于绝望,我也尝试过包含 windows.h,但没有成功。

最佳答案

这里的重点是:1>LINK:警告 LNK4098:默认库“LIBCMT”与其他库的使用冲突;使用/NODEFAULTLIB:library

您正在尝试使用与多线程 C 运行时库 libcmt 不兼容的库。

很可能您在某处使用不同的开关(通常是/MD 或/MT)进行编译,以用于构建 mariadb 库。

更多信息请看这里: https://msdn.microsoft.com/en-us/library/aa267384(v=vs.60).aspx

关于c++ - Visual Studio Community 2017 链接器问题 - MariaDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47564213/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com