1

There is something wrong with multiple definition of `ERR_remove_thread_state' When I compile a c++ server and link openssl-1.0.2 libcrypto.a and libmysqlclient.a.Here is the error:

/usr/local/openssl-1.0.2/lib/libcrypto.a(err.o): In function `ERR_remove_thread_state':
err.c:(.text+0x1ac0): multiple definition of `ERR_remove_thread_state'
/usr/lib/x86_64-linux-gnu/libmysqlclient.a(ssl.cpp.o):(.text+0x1df0): first defined here
Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
jpliu
  • 11
  • 4
  • 2
    Is there a special reason you link statically? – Some programmer dude Aug 02 '18 at 03:56
  • @Someprogrammerdude - just a guess from `/usr/local`, but maybe to avoid all the stupid Linux path problems that have plagued the OS for the last 25 years or so. He will get the version he built, and not the wrong ones from `/lib{64}` at runtime. – jww Aug 02 '18 at 04:35
  • similar question here ---> https://stackoverflow.com/questions/57945558/g-compile-static-with-openssl-and-mysqlclient/57964429?noredirect=1#comment102368542_57964429 – Darren Smith Sep 17 '19 at 19:32

2 Answers2

1

It's not clear what you're asking, so I'll explain what the error means.

This is the linker telling you that the name ERR_remove_thread_state is defined in two different places: err.o and ssl.cpp.o.

It's also telling you that err.o is in libcrypto.o, and ssl.cpp.o is in libmysqlclient.a.

So in essence, it's telling you that by statically linking both to libcrypto and to the MySQL client library, you're causing it to be confused as to which function it should call.

EDIT: You might be able to solve this in a couple of ways:

  1. Upgrade libcrypto to 1.1.1 (still in beta as of this writing) since it looks like ERR_remove_thread_state was deprecated in 1.1.0, and removed after that.

  2. Build your own version of MySQL without SSL, to avoid the link error by not having that code in libmysqlclient.a.

Shalom Craimer
  • 20,659
  • 8
  • 70
  • 106
  • I did in first way above.But it has the same error of multiple definition of `ERR_remove_thread_state'.I installed libmysqlclient-dev by apt-get, and installed openssl by compiling source code. – jpliu Aug 02 '18 at 06:43
1

I have a same problem.
In my case, latest libmysqlclient and older libcrpyto is conflicted.
Therefore downgrade libmysqlclient from 5.7.23 to 5.7.21.
After then, there are no problems.

I hope it helps.

Etri
  • 11
  • 2