alanxz / SimpleAmqpClient

Simple C++ Interface to rabbitmq-c
MIT License
404 stars 213 forks source link

unresolved external symbol __imp_htonl when compiling SimpleAmqpClient (64bit) using VS2013 #166

Open lqj1990 opened 7 years ago

lqj1990 commented 7 years ago

I try to compile SimpleAmqpClient (64bit) using VS2013. The setting is as follows. OpenSSL: v1.0.21 boost: v1.62.0 rabbitmq-c: v0.8.0 SimpleAmqpClient: v2.4.0 code generation: Multi-thread \MT (release) Multi-thread Debug \MTd (debug)

When I use Cmake to generate rabbitmq-c code, it shows

Looking for htonll Looking for htonll - found Looking for poll Looking for poll - not found Looking for clock_gettime in rt Looking for clock_gettime in rt - not found Looking for posix_spawnp in rt Looking for posix_spawnp in rt - not found Performing Test HAVE_GNU90 Performing Test HAVE_GNU90 - Failed Performing Test HAVE_C90 Performing Test HAVE_C90 - Failed Could NOT find POPT (missing: POPT_INCLUDE_DIR POPT_LIBRARY) Could NOT find XMLTO (missing: XMLTO_EXECUTABLE) Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) Looking for pthread.h Looking for pthread.h - not found

Cmake still can generate code for rabbitmq-c and I compile rabbitmq-c library successfully (\MT for release version, and \MTd for debug version with the corresponding OpenSSL library). However, when I compile SimpleAmqpClient, something is wrong. I get a lot of link errors.

Error 9 error LNK2001: unresolved external symbol imp_htonl librabbitmq.4.lib(amqp_connection.obj) Error 10 error LNK2001: unresolved external symbol imp_htonl librabbitmq.4.lib(amqp_table.obj) Error 12 error LNK2001: unresolved external symbol imp_htons librabbitmq.4.lib(amqp_connection.obj) Error 13 error LNK2001: unresolved external symbol imp_htons librabbitmq.4.lib(amqp_table.obj) ....

I repeat the whole procedure for several times. But I get the same result. What configuration should I use to compile rabbitmq-c and SimpleAmqpClient rightly?

I try to compile the x86 version, the same problem happens again.

Thank you.

alanxz commented 7 years ago

Can you tell if the linker is attempting to link against winsock2?

lqj1990 commented 7 years ago

Thank you. After I use the master version of SimpleAmqpClient, I find that the version I used does not link against winsock2. After add the winsock22 library, the problem is solved.

But I need to disable OpenSSL when compile the rabbitmq-c, otherwise I will get some link error related to amqp_openssl. I don't know what operation causes the problem. Do I use the wrong version of OpenSSL? Which version do you suggest?

Thank you.

alanxz commented 7 years ago

Are you attempting to link against a statically built version of rabbitmq-c?

If so, unless you have a really good reason, I'd recommend building and linking against the shared library version of rabbitmq-c.

If you really need to use a static library version of rabbitmq-c, you need to link against the same version of OpenSSL that rabbitmq-c was built against.