gpt4 book ai didi

c - 链接到在 Cygwin 上使用 mingw 构建的库

转载 作者:行者123 更新时间:2023-11-30 14:27:44 25 4
gpt4 key购买 nike

我在 Cygwin 上使用 mingw 构建了 libmysqlclient,因此我得到了“.a”文件,但是当我尝试链接该文件时,它失败了。我的编译器是 mingw,在 GNU/Linux 上,我的目标是 Windows。

这是链接程序的命令行(由automake生成):

i586-mingw32msvc-g++ -s -O1 -Wall -Wclobbered -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wsign-compare -Wtype-limits -Wuninitialized -mwindows -o .libs/valoisscan.exe App.o ConfigManager.o DialogConfig.o DialogRCDStart.o DialogAbout.o findFile.o MainFrame.o PanelScan.o PanelSearch.o MyException.o strWxStdConv.o libsqlendive.o PanelBase.o rc.o -mthreads -Wl,--subsystem -Wl,windows -mwindows  -L/usr/i586-mingw32msvc//lib /usr/i586-mingw32msvc//lib/libwx_mswu_richtext-2.8.a /usr/i586-mingw32msvc//lib/libwx_mswu_aui-2.8.a /usr/i586-mingw32msvc//lib/libwx_mswu_xrc-2.8.a /usr/i586-mingw32msvc//lib/libwx_mswu_qa-2.8.a /usr/i586-mingw32msvc//lib/libwx_mswu_html-2.8.a /usr/i586-mingw32msvc//lib/libwx_mswu_adv-2.8.a /usr/i586-mingw32msvc//lib/libwx_mswu_core-2.8.a /usr/i586-mingw32msvc//lib/libwx_baseu_xml-2.8.a /usr/i586-mingw32msvc//lib/libwx_baseu_net-2.8.a /usr/i586-mingw32msvc//lib/libwx_baseu-2.8.a -lwxregexu-2.8 -lwxexpat-2.8 -lwxtiff-2.8 -lwxjpeg-2.8 -lwxpng-2.8 -lwxzlib-2.8 -lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32 ticpp/.libs/libticpp.a mysqlwrapped/.libs/libmysqlwrapped.a -lmysqlclient -lstdc++ -mthreads

以下是链接器错误:

mysqlwrapped/.libs/libmysqlwrapped.a(Query.o):Query.cpp:(.text+0x12b): undefined reference to `_mysql_ping@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Query.o):Query.cpp:(.text+0x17b): undefined reference to `_mysql_errno@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Query.o):Query.cpp:(.text+0x1d5): undefined reference to `_mysql_error@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Query.o):Query.cpp:(.text+0x2f0): undefined reference to `_mysql_num_rows@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Query.o):Query.cpp:(.text+0x31e): undefined reference to `_mysql_insert_id@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Query.o):Query.cpp:(.text+0x349): undefined reference to `_mysql_fetch_row@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Query.o):Query.cpp:(.text+0x3bd): undefined reference to `_mysql_query@8'
mysqlwrapped/.libs/libmysqlwrapped.a(Query.o):Query.cpp:(.text+0x5da): undefined reference to `_mysql_free_result@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Query.o):Query.cpp:(.text+0xb8c): undefined reference to `_mysql_free_result@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Query.o):Query.cpp:(.text+0xd9c): undefined reference to `_mysql_free_result@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Query.o):Query.cpp:(.text+0x1712): undefined reference to `_mysql_store_result@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Query.o):Query.cpp:(.text+0x172b): undefined reference to `_mysql_fetch_field@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Query.o):Query.cpp:(.text+0x1962): undefined reference to `_mysql_fetch_field@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Database.o):Database.cpp:(.text+0x3c2): undefined reference to `_mysql_options@12'
mysqlwrapped/.libs/libmysqlwrapped.a(Database.o):Database.cpp:(.text+0x129c): undefined reference to `_mysql_init@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Database.o):Database.cpp:(.text+0x135d): undefined reference to `_mysql_real_connect@32'
mysqlwrapped/.libs/libmysqlwrapped.a(Database.o):Database.cpp:(.text+0x1405): undefined reference to `_mysql_real_connect@32'
mysqlwrapped/.libs/libmysqlwrapped.a(Database.o):Database.cpp:(.text+0x14c0): undefined reference to `_mysql_ping@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Database.o):Database.cpp:(.text+0x155a): undefined reference to `_mysql_ping@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Database.o):Database.cpp:(.text+0x15eb): undefined reference to `_mysql_close@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Database.o):Database.cpp:(.text+0x1ad9): undefined reference to `_mysql_close@4'
mysqlwrapped/.libs/libmysqlwrapped.a(Database.o):Database.cpp:(.text+0x1e1b): undefined reference to `_mysql_close@4'

我尝试了strings libmysqlclient.a | grep _mysql_ping 它返回两个结果,因此该库看起来有效。

命令i58​​6-mingw32msvc-objdump -x libmysqlclient.a | grep mysql_ping 输出[ 39](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x000012f0 _mysql_ping

<小时/>

这可能很重要:我的 gcc 目标是 i586-mingw32msvc

最佳答案

由于您使用的是 C++,因此您可能需要将 mysqlclient.h 包含在外部“C”中:

extern "C" {
#include <mysqlclient.h>
}

C++ 名称修饰可能会重命名符号,以便链接器无法找到它们。

关于c - 链接到在 Cygwin 上使用 mingw 构建的库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7359742/

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