Azure / azure-iot-sdk-python

A Python SDK for connecting devices to Microsoft Azure IoT services
MIT License
425 stars 379 forks source link

Unable to cross compile the python SDK #197

Closed naveen3p closed 6 years ago

naveen3p commented 6 years ago

Hi,

Description of the issue:

I modified the hsm_client_data.c file in SDK to look for the specific location to read the X509 certificate and key. I Successfully compiled in my host system (Ubuntu 14.04) and used the python examples without any problem. Then, I started to cross compile the same SDK by following the cross compilation steps described in the Example of Cross Compiling the Azure IoT SDK for Python.md. However, cross compilation is getting failed at 97% and error was mentioned below

Console log of the issue:

[ 97%] Building CXX object c/python/src/CMakeFiles/iothub_client_python.dir/iothub_client_python.cpp.o cd /home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/cmake/c/python/src && /home/sumish/test1/Linux_Source/bg349_dtvplus_linux/distr/build_armv7l-timesys-linux-gnueabihf/toolchain/usr/bin/armv7l-timesys-linux-gnueabihf-g++ -DARCHITECTURE_ARM=1 -DUSE_AMQP -DUSE_HTTP -DUSE_MQTT -DUSE_WEBSOCKETS -Diothub_client_python_EXPORTS --std=c++11 -fPIC -Werror -fPIC -I/home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/c/c-utility/inc -I/home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/c/c-utility/pal/linux -I/home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/SitaraBoost/include -I/home/sumish/test1/Linux_Source/bg349_dtvplus_linux/distr/build_armv7l-timesys-linux-gnueabihf/toolchain/usr/include/python2.7 -I/home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/c/deps/uhttp/deps/c-utility/inc -I/home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/c/iothub_client/inc -I/home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/c/iothub_client/inc/internal -I/home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/c/uamqp/inc -I/home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/c/umqtt/inc -I/home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/c/provisioning_client/inc -I/home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/device/iothub_client_python/src/. -o CMakeFiles/iothub_client_python.dir/iothub_client_python.cpp.o -c /home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/device/iothub_client_python/src/iothub_client_python.cpp /home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/device/iothub_client_python/src/iothub_client_python.cpp: In member function 'void IoTHubModuleClient::CreateFromEnvironment(IOTHUB_TRANSPORT_PROVIDER)': /home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/device/iothub_client_python/src/iothub_client_python.cpp:2321:97: error: 'IoTHubModuleClient_CreateFromEnvironment' was not declared in this scope iotHubClientHandle = IoTHubModuleClient_CreateFromEnvironment(GetProtocol(_protocol)); ^ /home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/device/iothub_client_python/src/iothub_client_python.cpp: In member function 'void IoTHubModuleClient::InvokeMethodAsyncOnModule(std::string, std::string, std::string, std::string, unsigned int, boost::python::api::object&, boost::python::api::object&)': /home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/device/iothub_client_python/src/iothub_client_python.cpp:2351:0: error: 'IoTHubModuleClient_ModuleMethodInvokeAsync' was not declared in this scope result = IoTHubModuleClient_ModuleMethodInvokeAsync(iotHubClientHandle, deviceId.c_str(), moduleId.c_str(), methodName.c_str(), methodPayload.c_str(), timeout, iotHubInvokeModuleOrDeviceMethodCallback, invokeContext); ^ /home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/device/iothub_client_python/src/iothub_client_python.cpp: In member function 'void IoTHubModuleClient::InvokeMethodAsyncOnDevice(std::string, std::string, std::string, unsigned int, boost::python::api::object&, boost::python::api::object&)': /home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/device/iothub_client_python/src/iothub_client_python.cpp:2382:0: error: 'IoTHubModuleClient_DeviceMethodInvokeAsync' was not declared in this scope result = IoTHubModuleClient_DeviceMethodInvokeAsync(iotHubClientHandle, deviceId.c_str(), methodName.c_str(), methodPayload.c_str(), timeout, iotHubInvokeModuleOrDeviceMethodCallback, invokeContext); ^ make[2]: [c/python/src/CMakeFiles/iothub_client_python.dir/iothub_client_python.cpp.o] Error 1 make[2]: Leaving directory `/home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/cmake' make[1]: [c/python/src/CMakeFiles/iothub_client_python.dir/all] Error 2 make[1]: Leaving directory `/home/sumish/Azure_Python_SDk/CrossCompiled_Azure_Python_Sdk/azure-iot-sdk-python/cmake' make: *** [all] Error 2

I am not sure why cross compilation is getting failed. I have checked for the path and environment related issues and couldn't find any. I am very grateful if you could help me on this.

Thank you.

pierreca commented 6 years ago

Assigning to @markrad in hope he has time to look into this since he's the original author of the document.

markrad commented 6 years ago

Hi @naveen3p,

Can you tell me what cross compile toolchain you are using please? If this is a public toolchain, please include a download link. I will try and reproduce the issue.

Thanks.

Mark Radbourne MSFT

naveen3p commented 6 years ago

Hi @markrad ,

Thank you for your response. I debugged more into this error and compared the cross compiler scripts with the my host build scripts. I forgot to include custom HSM related flags "-Duse_prov_client:BOOL=ON -Dhsm_custom_lib= destination folder" when i call the cmake in my script file. This was caused the above error.

Now, i was able to compile without any build errors. I yet to test this build in the target machine.

Thank you very much for your support and assistance.

markrad commented 6 years ago

Hi @naveen3p,

Thank you for letting me know. I have closed your issue. If you have any further problems with the Python cross compile feel free to reopen it or create a new one.

Mark Radbourne MSFT

az-iot-builder-01 commented 6 years ago

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