iot-edge-v1 icon indicating copy to clipboard operation
iot-edge-v1 copied to clipboard

LIBCMT linker warnings when building Release config

Open YufeiHu opened this issue 7 years ago • 6 comments

On my Windows 7 PC, I run build.cmd by following the tutorial and everything was built successfully. Then I run simulated_device_cloud_upload_sample.exe under \azure-iot-gateway-sdk\build\samples\simulated_device_cloud_upload\Debug and the temperature data was successfully sent to IoT Hub on my Azure.

Then I opened azure_iot_gateway_sdk.sln under \azure-iot-gateway-sdk\build in Visual Studio 2015 and changed Solution Configuration from Debug to Release. The Solution Platform remains to be Win32. After this, I built my solution. Then I changed the contents of every module.path in simulated_device_cloud_upload_win.json from ...\\Debug\\... to ...\\Release\\.... The contents of my JSON file is shown below:

  "modules": [
    {
      "name": "IotHub",
      "loader": {
        "name": "native",
        "entrypoint": {
          "module.path": "..\\..\\..\\modules\\iothub\\Release\\iothub.dll"
        }
      },
      "args": {
        "IoTHubName": "NI-IoTHub-2",
        "IoTHubSuffix": "azure-devices.net",
        "Transport": "HTTP"
      }
    },
    {
      "name": "mapping",
      "loader": {
        "name": "native",
        "entrypoint": {
          "module.path": "..\\..\\..\\modules\\identitymap\\Release\\identity_map.dll"
        }
      },
      "args": [
        {
          "macAddress": "01:01:01:01:01:01",
          "deviceId": "Device1",
          "deviceKey": "rmfD0NlC3IpETnv0MWzY/0fTa3b2SufkhtQt38okzdQ="
        }
      ]
    },
    {
      "name": "BLE1",
      "loader": {
        "name": "native",
        "entrypoint": {
          "module.path": "..\\..\\..\\modules\\simulated_device\\Release\\simulated_device.dll"
        }
      },
      "args": {
        "macAddress": "01:01:01:01:01:01",
        "messagePeriod": 2000
      }
    },
    {
      "name": "Logger",
      "loader": {
        "name": "native",
        "entrypoint": {
          "module.path": "..\\..\\..\\modules\\logger\\Release\\logger.dll"
        }
      },
      "args": {
        "filename": "deviceCloudUploadGatewaylog.log"
      }
    }
  ],
  "links": [
    {
      "source": "*",
      "sink": "Logger"
    },
    {
      "source": "BLE1",
      "sink": "mapping"
    },
    {
      "source": "mapping",
      "sink": "IotHub"
    },
    {
      "source": "IotHub",
      "sink": "mapping"
    },
    {
      "source": "mapping",
      "sink": "BLE1"
    }
  ]
}

After all this, I run simulated_device_cloud_upload_sample.exe under \azure-iot-gateway-sdk\build\samples\simulated_device_cloud_upload\Release with the JSON file (shown above) path as input argument. Then my program crashed. 01

Could you please show me how to build and run a sample under release mode?

YufeiHu avatar Apr 20 '17 02:04 YufeiHu

Hi Yufei,

Seems like your problem is that you followed the tutorial (using build script) for Debug and changed to release just in Visual Studio. So the dependencies got to be built as well in Release.

My suggestion is to follow the same script, bit change de configuration to Releas on Command line and add the option to Rebuild dependencies.

The options are on the usage of build script.

Try it out and Let us know,

Angelo Ribeiro

Sent from my phone

On Apr 19, 2017, at 7:30 PM, Yufei Hu [email protected] wrote:

On my Windows 7 PC, I run build.cmd by following the tutorial and everything was built successfully. Then I run simulated_device_cloud_upload_sample.exe under \azure-iot-gateway-sdk\build\samples\simulated_device_cloud_upload\Debug and the temperature data was successfully sent to IoT Hub on my Azure.

Then I opened azure_iot_gateway_sdk.sln under \azure-iot-gateway-sdk\build in Visual Studio 2015 and changed Solution Configuration from Debug to Release. The Solution Platform remains to be Win32. After this, I built my solution. Then I changed the contents of every module.path in simulated_device_cloud_upload_win.json from ...\Debug\...to ...\Release\.... The contents of my JSON file is shown below:

"modules": [ { "name": "IotHub", "loader": { "name": "native", "entrypoint": { "module.path": "..\..\..\modules\iothub\Release\iothub.dll" } }, "args": { "IoTHubName": "NI-IoTHub-2", "IoTHubSuffix": "azure-devices.net", "Transport": "HTTP" } }, { "name": "mapping", "loader": { "name": "native", "entrypoint": { "module.path": "..\..\..\modules\identitymap\Release\identity_map.dll" } }, "args": [ { "macAddress": "01:01:01:01:01:01", "deviceId": "Device1", "deviceKey": "rmfD0NlC3IpETnv0MWzY/0fTa3b2SufkhtQt38okzdQ=" } ] }, { "name": "BLE1", "loader": { "name": "native", "entrypoint": { "module.path": "..\..\..\modules\simulated_device\Release\simulated_device.dll" } }, "args": { "macAddress": "01:01:01:01:01:01", "messagePeriod": 2000 } }, { "name": "Logger", "loader": { "name": "native", "entrypoint": { "module.path": "..\..\..\modules\logger\Release\logger.dll" } }, "args": { "filename": "deviceCloudUploadGatewaylog.log" } } ], "links": [ { "source": "*", "sink": "Logger" }, { "source": "BLE1", "sink": "mapping" }, { "source": "mapping", "sink": "IotHub" }, { "source": "IotHub", "sink": "mapping" }, { "source": "mapping", "sink": "BLE1" } ] } After all this, I run simulated_device_cloud_upload_sample.exe under \azure-iot-gateway-sdk\build\samples\simulated_device_cloud_upload\Release with the JSON file (shown above) path as input argument. Then my program crashed.

Could you please show me how to build and run a sample under release mode?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

aribeironovaes avatar Apr 20 '17 02:04 aribeironovaes

This is likely to be a consequence of the dependencies being built as Debug, i.e., when you ran build.cmd it would have built all the dependencies using the debug build configuration by default. Then when you switched the build configuration to Release in Visual Studio later for the gateway itself, it continued to use the debug bits for the dependencies. For building the release configuration, you might want to run build.cmd again like so:

tools\build.cmd --config Release --rebuild-deps

avranju avatar Apr 20 '17 02:04 avranju

Hey guys! Thank you for your suggestions. It does work (at least to some extent) but it still seems to have some small errors.

After I run tools\build.cmd --config Release --rebuild-deps in build.cmd, I got 3 warnings shown below. It states that LIBCMT conflicts. But since these are just warnings so I ignored them first. 02

Then I ran simulated_device_cloud_upload_sample.exe under \azure-iot-gateway-sdk\build\samples\simulated_device_cloud_upload\Release. Temperature data was sent to IoT Hub successfully, but when I pressed Enter to stop the program, I got an error. The screenshot is shown below: 03

Though it does not affect sending data to IoT Hub, I still want to figure out what caused these warnings and errors. Thx!

YufeiHu avatar Apr 20 '17 07:04 YufeiHu

We should fix the warnings. The VECTOR error is harmless but annoying. We'll fix that too. Thanks!

damonbarry avatar Apr 20 '17 18:04 damonbarry

Removed warning in #231 (commit 818b421 ) but I'm still looking at that linker warning.

darobs avatar Apr 25 '17 23:04 darobs

I've been looking into this recently, the libuv library is built with the /MT flag, and the rest of the gateway repo is built with /MD flag. This is not recommended. However, I have not found a good way to fix this in our repository. I'm doing some other work with building this week, and I'll try to incorporate any fix I find into that work.

darobs avatar May 22 '17 19:05 darobs