Azure / azure-iot-sdk-c

A C99 SDK for connecting devices to Microsoft Azure IoT services
https://azure.github.io/azure-iot-sdk-c
Other
588 stars 737 forks source link

libcrypto.a(dso_dlfcn.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5' when compile with openssl in different folder #589

Closed mamungm closed 6 years ago

mamungm commented 6 years ago

Hi, I am facing the below problem

[ 80%] Building C object iothub_client/samples/iothub_ll_client_x509_sample/CMakeFiles/iothub_ll_client_x509_sample.dir////certs/certs.c.o cd /home/mamun/Desktop/azure/azure-iot-sdk-c/cmake/iothub_client/samples/iothub_ll_client_x509_sample && /usr/bin/cc -DARCHITECTURE_x86_64=1 -DSET_TRUSTED_CERT_IN_SAMPLES -DUSE_AMQP -DUSE_HTTP -DUSE_MQTT -I/home/mamun/Desktop/azure/azure-iot-sdk-c/c-utility/inc -I/home/mamun/Desktop/azure/azure-iot-sdk-c/c-utility/pal/linux -I/home/mamun/Desktop/azure/azure-iot-sdk-c/iothub_client/../deps/parson -I/home/mamun/Desktop/azure/azure-iot-sdk-c/deps/uhttp/deps/c-utility/inc -I/home/mamun/Desktop/azure/azure-iot-sdk-c/iothub_client/inc -I/home/mamun/Desktop/azure/azure-iot-sdk-c/iothub_client/inc/internal -I/home/mamun/Desktop/azure/azure-iot-sdk-c/uamqp/inc -I/home/mamun/Desktop/azure/azure-iot-sdk-c/umqtt/inc -I/home/mamun/Desktop/azure/azure-iot-sdk-c/certs -I/home/mamun/Desktop/azure/azure-iot-sdk-c/iothub_client/samples/iothub_ll_client_x509_sample/. -fPIC -Werror -std=gnu99 -o CMakeFiles/iothub_ll_client_x509_sample.dir////certs/certs.c.o -c /home/mamun/Desktop/azure/azure-iot-sdk-c/certs/certs.c [ 80%] Linking C executable iothub_ll_client_x509_sample cd /home/mamun/Desktop/azure/azure-iot-sdk-c/cmake/iothub_client/samples/iothub_ll_client_x509_sample && /usr/bin/cmake -E cmake_link_script CMakeFiles/iothub_ll_client_x509_sample.dir/link.txt --verbose=1 /usr/bin/cc -fPIC -Werror -rdynamic CMakeFiles/iothub_ll_client_x509_sample.dir/iothub_ll_client_x509_sample.c.o CMakeFiles/iothub_ll_client_x509_sample.dir///__/certs/certs.c.o -o iothub_ll_client_x509_sample ../../libiothub_client.a ../../../c-utility/libaziotsharedutil.a ../../libiothub_client_http_transport.a -lcurl ../../libiothub_client_amqp_transport.a ../../../uamqp/libuamqp.a ../../../c-utility/libaziotsharedutil.a ../../libiothub_client_mqtt_transport.a ../../../umqtt/libumqtt.a ../../libiothub_client_amqp_ws_transport.a ../../libiothub_client_mqtt_ws_transport.a ../../../umqtt/libumqtt.a ../../../libparson.a ../../../c-utility/libaziotsharedutil.a -lcurl /home/mamun/Desktop/azure/openssl-1.0.2o/libssl.a /home/mamun/Desktop/azure/openssl-1.0.2o/libcrypto.a -lpthread -lm -lrt -luuid /usr/bin/x86_64-linux-gnu-ld: /home/mamun/Desktop/azure/openssl-1.0.2o/libcrypto.a(dso_dlfcn.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5' //lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status iothub_client/samples/iothub_ll_client_x509_sample/CMakeFiles/iothub_ll_client_x509_sample.dir/build.make:138: recipe for target 'iothub_client/samples/iothub_ll_client_x509_sample/iothub_ll_client_x509_sample' failed make[2]: [iothub_client/samples/iothub_ll_client_x509_sample/iothub_ll_client_x509_sample] Error 1 make[2]: Leaving directory '/home/mamun/Desktop/azure/azure-iot-sdk-c/cmake' CMakeFiles/Makefile2:1649: recipe for target 'iothub_client/samples/iothub_ll_client_x509_sample/CMakeFiles/iothub_ll_client_x509_sample.dir/all' failed make[1]: [iothub_client/samples/iothub_ll_client_x509_sample/CMakeFiles/iothub_ll_client_x509_sample.dir/all] Error 2 make[1]: Leaving directory '/home/mamun/Desktop/azure/azure-iot-sdk-c/cmake' Makefile:143: recipe for target 'all' failed make: *** [all] Error 2

I am trying to buil the "iothub_ll_client_x509_sample" with a custom downloaded folder of openssl. First I downloaded openssl code. It is in the directory "/home/mamun/Desktop/azure/openssl-1.0.2o". I configured it and build. There is .a and .so build. Now I am trying to build the sample application with command of cmake cmake -Duse_openssl:BOOL=ON -DOPENSSL_ROOT_DIR:PATH=/home/mamun/Desktop/azure/openssl-1.0.2o ..

cmake executes successfully. Then I issue "cmake --build ." command and it compiles and then links to create the sample application. After running 80% I am getting the above error. Please help in this regard.

ewertons commented 6 years ago

Hi @mamungm , for some reason your application is not linking dl. If you see here, it can be linked passing -ldl to the compiler.

Since we haven't seen that error before, that tells me that issue might not be directly related to the Azure ioT SDK, but to the dependency (openssl), as it might not have the proper lib linked.

When you run the cmake as you did above, could you try this way:

cmake -Duse_openssl:BOOL=ON -DOPENSSL_ROOT_DIR:PATH=/home/mamun/Desktop/azure/openssl-1.0.2o -DcompileOption_C="-ldl" ..
ewertons commented 6 years ago

@mamungm , we will close this issue for now, but please feel free to reopen it if you would like to follow up. Thanks for using the Azure IoT SDK!

az-iot-builder-01 commented 6 years ago

@mamungm, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey