Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 多定义符号:mysqlclient、pthread-win32_C++_Mysql_Windows_Visual Studio_Pthreads - Fatal编程技术网

C++ 多定义符号:mysqlclient、pthread-win32

C++ 多定义符号:mysqlclient、pthread-win32,c++,mysql,windows,visual-studio,pthreads,C++,Mysql,Windows,Visual Studio,Pthreads,继续我的移植项目。。。尝试用Visual Studio 2013 PRO.获得Linux上的Windows C++应用程序 这是一个多线程的应用程序,所以我加入了混合。它也使用MySQL,所以我也安装了二进制32位 一切都很顺利,直到VS尝试将其连接起来。然后我得到这个: pthreadVSE2.lib(pthreadVSE2.dll) : error LNK2005: _pthread_exit already defined in mysqlclient.lib(my_winthread.o

继续我的移植项目。。。尝试用Visual Studio 2013 PRO.

获得Linux上的Windows C++应用程序 这是一个多线程的应用程序,所以我加入了混合。它也使用MySQL,所以我也安装了二进制32位

一切都很顺利,直到VS尝试将其连接起来。然后我得到这个:

pthreadVSE2.lib(pthreadVSE2.dll) : error LNK2005: _pthread_exit already defined in mysqlclient.lib(my_winthread.obj)
pthreadVSE2.lib(pthreadVSE2.dll) : error LNK2005: _pthread_join already defined in mysqlclient.lib(my_winthread.obj)
pthreadVSE2.lib(pthreadVSE2.dll) : error LNK2005: _pthread_create already defined in mysqlclient.lib(my_winthread.obj)
事实证明,MySQL开发人员也遇到了同样的问题(windows上缺少pthread),所以他们将pthread库的一部分放进了自己的库中(或者用相同的函数名/签名放进了自己的库中——我还没仔细看)

但这只是其中的一部分——我试图从链接中删除pthread-win32,认为可能mysqlclient库中嵌入了所有pthread——但这会产生大量未解析的符号

对如何解决这个问题有什么建议吗?这里是完整的windows开发者新手,所以没有建议是愚蠢的


谢谢

好的,如果有人遇到同样的问题,下面是我如何解决的。我进入了MySQL连接器源代码,重命名了多定义函数并重新编译了库

pthread_exit() renamed to mysql_pthread_exit()
pthread_join() renamed to mysql_pthread_join()
pthread_create() renamed to mysql_pthread_create()
声明在include/my_pthread.h中,在mysys/my_winthread.c中实现,它们不会在库中的任何地方调用

pthread_exit() renamed to mysql_pthread_exit()
pthread_join() renamed to mysql_pthread_join()
pthread_create() renamed to mysql_pthread_create()
这允许一个干净的编译和链接。MySQL的东西不在我的代码的多线程部分,而且它似乎工作得很好

这并不是一个理想的解决方案,因为我现在必须在MySQL连接器库的修改版本中来回移动,并且在新版本出现时重新进行修改。但它现在起作用了