programing

Visual Studio Community 2017 링커 문제 - MariaDB

bestprogram 2023. 10. 4. 22:13

Visual Studio Community 2017 링커 문제 - MariaDB

Visual Studio에서 DB의 프로그래밍(특히 MariaDB)을 망치는 것은 처음이며 운이 좋지 않습니다.제가 외부 링크를 잘못 설정한 것 같은데 제 설정을 보고 있는데 오류가 안 보이네요.아마 경험이 많은 코더들에게는 분명할 것입니다만, 나무 때문에 숲이 보이지 않습니다.

저는 x86과 64bit 둘다 각각의 라이브러리로 컴파일을 시도해 보았습니다.아래에 x86 설정만 포함시켰는데 "프로그램 파일 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

어떤 도움이라도 주시면 감사하겠습니다. 더 필요한 정보가 있으면 문의해 주시기 바랍니다.

참고: 절박한 심정으로 window.h도 포함해 보았지만 주사위는 없었습니다.

여기서 핵심은 다음과 같습니다.1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library

다중 스레드 크런 타임 라이브러리인 libcmt와 호환되지 않는 라이브러리를 사용하려고 합니다.

mariadbli를 구축하는 데 사용된 스위치(종종 /MD 또는 /MT)를 어딘가에서 컴파일하고 있을 가능성이 높습니다.

자세한 정보는 여기를 참조하십시오. https://msdn.microsoft.com/en-us/library/aa267384(v=vs.60).aspx

언급URL : https://stackoverflow.com/questions/47564213/visual-studio-community-2017-linker-problems-mariadb