Azure / iot-edge-v1

Azure IoT Edge
http://azure.github.io/iot-edge/
Other
525 stars 258 forks source link

Error trying to build with nodejs bindings on macOS #439

Open rcastill opened 6 years ago

rcastill commented 6 years ago

I'm trying to compile /v1/samples/nodejs_simple_sample under macOS, so I follow the instructions.

I built nodejs running /v1/tools/build_nodejs.sh

The script didn't finish well because it couldn't copy any *.so files from the /v1/build_nodejs/node/out/Release/lib folder (there was a .dylib instead). So I copied it into the /v1/build_nodejs/dist/lib folder and made the symlinks.

Then tried to build iot-edge with nodejs bindings by running:

/v1 $ export NODE_INCLUDE=`pwd`/build_nodejs/dist/inc
/v1 $ export NODE_LIB=`pwd`/build_nodejs/dist/lib
/v1 $ ./tools/build.sh --enable-nodejs-binding --disable-native-remote-modules

Full output

~/dev/xompass/iot-edge/v1/build ~/dev/xompass/iot-edge/v1
-- The C compiler identification is AppleClang 9.0.0.9000038
-- The CXX compiler identification is AppleClang 9.0.0.9000038
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMake Install Prefix is /usr/local
-- AIG architecture: x86_64
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.1")
-- NANOMSG LIBRARIES: nanomsg
-- NANOMSG CFLAGS: -I/usr/local/Cellar/nanomsg/1.0.0/include
-- NANOMSG LOCATION: /usr/local/Cellar/nanomsg/1.0.0/lib/libnanomsg.dylib
-- Checking for one of the modules 'uuid'
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    compileOption_C
    run_e2e_tests
    run_valgrind

-- Build files have been written to: /Users/Rodolfo/dev/xompass/iot-edge/v1/build
Scanning dependencies of target parson
[  1%] Building C object core/deps/CMakeFiles/parson.dir/__/__/deps/parson/parson.c.o
[  2%] Linking C static library libparson.a
[  2%] Built target parson
Scanning dependencies of target gateway_static
Scanning dependencies of target module_host_static
Scanning dependencies of target gateway
[  3%] Building C object core/CMakeFiles/module_host_static.dir/adapters/dynamic_library_linux.c.o
[  4%] Building C object core/CMakeFiles/module_host_static.dir/adapters/gb_library_linux.c.o
[  5%] Building C object core/CMakeFiles/gateway_static.dir/adapters/dynamic_library_linux.c.o
[  7%] Building C object core/CMakeFiles/gateway.dir/adapters/dynamic_library_linux.c.o
[  8%] Building C object core/CMakeFiles/gateway_static.dir/adapters/gb_library_linux.c.o
[  9%] Building C object core/CMakeFiles/module_host_static.dir/src/message.c.o
[ 10%] Building C object core/CMakeFiles/gateway_static.dir/src/message.c.o
[ 11%] Building C object core/CMakeFiles/gateway.dir/adapters/gb_library_linux.c.o
[ 12%] Building C object core/CMakeFiles/gateway_static.dir/src/message_queue.c.o
[ 14%] Building C object core/CMakeFiles/gateway.dir/src/message.c.o
[ 15%] Building C object core/CMakeFiles/module_host_static.dir/src/message_queue.c.o
[ 16%] Building C object core/CMakeFiles/gateway_static.dir/src/module_loader.c.o
[ 17%] Building C object core/CMakeFiles/gateway.dir/src/message_queue.c.o
[ 18%] Building C object core/CMakeFiles/module_host_static.dir/src/module_loader.c.o
[ 20%] Building C object core/CMakeFiles/gateway.dir/src/module_loader.c.o
[ 21%] Building C object core/CMakeFiles/module_host_static.dir/src/module_loaders/dynamic_loader.c.o
[ 22%] Building C object core/CMakeFiles/gateway_static.dir/src/module_loaders/dynamic_loader.c.o
[ 23%] Building C object core/CMakeFiles/gateway.dir/src/module_loaders/dynamic_loader.c.o
[ 24%] Building C object core/CMakeFiles/module_host_static.dir/src/module_loaders/node_loader.c.o
[ 25%] Building C object core/CMakeFiles/gateway_static.dir/src/module_loaders/node_loader.c.o
[ 27%] Building C object core/CMakeFiles/gateway.dir/src/module_loaders/node_loader.c.o
[ 28%] Building C object core/CMakeFiles/gateway_static.dir/src/internal/event_system.c.o
[ 29%] Linking C static library libmodule_host_static.a
[ 30%] Building C object core/CMakeFiles/gateway.dir/src/internal/event_system.c.o
[ 31%] Building C object core/CMakeFiles/gateway.dir/src/gateway_internal.c.o
[ 31%] Built target module_host_static
[ 32%] Building C object core/CMakeFiles/gateway_static.dir/src/gateway_internal.c.o
[ 34%] Building C object core/CMakeFiles/gateway.dir/src/gateway.c.o
[ 35%] Building C object core/CMakeFiles/gateway_static.dir/src/gateway.c.o
[ 36%] Building C object core/CMakeFiles/gateway_static.dir/src/gateway_createfromjson.c.o
[ 37%] Building C object core/CMakeFiles/gateway.dir/src/gateway_createfromjson.c.o
[ 38%] Building C object core/CMakeFiles/gateway_static.dir/src/broker.c.o
[ 40%] Building C object core/CMakeFiles/gateway.dir/src/broker.c.o
[ 41%] Linking C shared library libgateway.dylib
[ 42%] Linking C static library libgateway_static.a
[ 42%] Built target gateway_static
[ 42%] Built target gateway
Scanning dependencies of target simulated_device
Scanning dependencies of target simulated_device_static
Scanning dependencies of target identity_map_static
Scanning dependencies of target identity_map
[ 44%] Building C object modules/simulated_device/CMakeFiles/simulated_device.dir/src/simulated_device.c.o
[ 44%] Building C object modules/simulated_device/CMakeFiles/simulated_device_static.dir/src/simulated_device.c.o
[ 45%] Building C object modules/identitymap/CMakeFiles/identity_map_static.dir/src/identitymap.c.o
[ 47%] Building C object modules/identitymap/CMakeFiles/identity_map.dir/src/identitymap.c.o
[ 48%] Linking C shared module libsimulated_device.so
[ 49%] Linking C static library libsimulated_device_static.a
[ 50%] Linking C shared module libidentity_map.so
[ 51%] Linking C static library libidentity_map_static.a
[ 51%] Built target simulated_device
[ 51%] Built target simulated_device_static
Scanning dependencies of target iothub
Scanning dependencies of target iothub_static
[ 51%] Built target identity_map
[ 51%] Built target identity_map_static
Scanning dependencies of target logger_static
Scanning dependencies of target logger
[ 52%] Building C object modules/iothub/CMakeFiles/iothub_static.dir/src/iothub.c.o
[ 54%] Building C object modules/iothub/CMakeFiles/iothub.dir/src/iothub.c.o
[ 55%] Building C object modules/logger/CMakeFiles/logger.dir/src/logger.c.o
[ 56%] Building C object modules/logger/CMakeFiles/logger_static.dir/src/logger.c.o
[ 57%] Linking C static library liblogger_static.a
[ 58%] Linking C shared module liblogger.so
[ 58%] Built target logger
[ 58%] Built target logger_static
[ 60%] Building C object modules/iothub/CMakeFiles/iothub.dir/src/null_protocol.c.o
[ 61%] Building C object modules/iothub/CMakeFiles/iothub_static.dir/src/null_protocol.c.o
Scanning dependencies of target hello_world_static
Scanning dependencies of target hello_world
[ 62%] Building C object modules/hello_world/CMakeFiles/hello_world_static.dir/src/hello_world.c.o
[ 63%] Building C object modules/hello_world/CMakeFiles/hello_world.dir/src/hello_world.c.o
[ 64%] Linking C shared module libiothub.so
[ 65%] Linking C static library libiothub_static.a
[ 67%] Linking C static library libhello_world_static.a
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: libiothub_static.a(null_protocol.c.o) has no symbols
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: libiothub_static.a(null_protocol.c.o) has no symbols
[ 68%] Linking C shared module libhello_world.so
[ 68%] Built target iothub_static
[ 68%] Built target hello_world_static
Scanning dependencies of target azure_functions_static
Scanning dependencies of target azure_functions
[ 68%] Built target iothub
[ 69%] Building C object modules/azure_functions/CMakeFiles/azure_functions.dir/src/azure_functions.c.o
[ 69%] Built target hello_world
[ 70%] Building C object modules/azure_functions/CMakeFiles/azure_functions_static.dir/src/azure_functions.c.o
Scanning dependencies of target nodejs_binding_static
Scanning dependencies of target nodejs_binding
[ 72%] Building CXX object bindings/nodejs/CMakeFiles/nodejs_binding_static.dir/src/nodejs.cpp.o
[ 72%] Building CXX object bindings/nodejs/CMakeFiles/nodejs_binding.dir/src/nodejs.cpp.o
[ 74%] Linking C shared module libazure_functions.so
[ 75%] Linking C static library libazure_functions_static.a
[ 75%] Built target azure_functions
[ 75%] Built target azure_functions_static
[ 76%] Building CXX object bindings/nodejs/CMakeFiles/nodejs_binding.dir/src/nodejs_idle.cpp.o
[ 77%] Building CXX object bindings/nodejs/CMakeFiles/nodejs_binding_static.dir/src/nodejs_idle.cpp.o
[ 78%] Building CXX object bindings/nodejs/CMakeFiles/nodejs_binding.dir/src/nodejs_utils.cpp.o
Scanning dependencies of target hello_world_sample
[ 80%] Building C object samples/hello_world/CMakeFiles/hello_world_sample.dir/src/main.c.o
[ 81%] Linking C executable hello_world_sample
/Users/Rodolfo/dev/xompass/iot-edge/v1/bindings/nodejs/src/nodejs.cpp:1215:25: error: ignoring return value of function declared with 'warn_unused_result' attribute [-Werror,-Wunused-result]
                        destroy_method->Call(context, gateway, 0, nullptr);
                        ^~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/Rodolfo/dev/xompass/iot-edge/v1/bindings/nodejs/src/nodejs.cpp:1308:25: error: ignoring return value of function declared with 'warn_unused_result' attribute [-Werror,-Wunused-result]
                        start_method->Call(context, gateway, 0, nullptr);
                        ^~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/Rodolfo/dev/xompass/iot-edge/v1/bindings/nodejs/src/nodejs.cpp:1215:25: error: ignoring return value of function declared with 'warn_unused_result' attribute [-Werror,-Wunused-result]
                        destroy_method->Call(context, gateway, 0, nullptr);
                        ^~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 81%] Built target hello_world_sample
/Users/Rodolfo/dev/xompass/iot-edge/v1/bindings/nodejs/src/nodejs.cpp:1308:25: error: ignoring return value of function declared with 'warn_unused_result' attribute [-Werror,-Wunused-result]
                        start_method->Call(context, gateway, 0, nullptr);
                        ^~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 82%] Building CXX object bindings/nodejs/CMakeFiles/nodejs_binding_static.dir/src/nodejs_utils.cpp.o
2 errors generated.
make[2]: *** [bindings/nodejs/CMakeFiles/nodejs_binding_static.dir/src/nodejs.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
2 errors generated.
make[2]: *** [bindings/nodejs/CMakeFiles/nodejs_binding.dir/src/nodejs.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
Scanning dependencies of target simulated_device_cloud_upload_sample
Scanning dependencies of target events_sample
[ 83%] Building C object samples/simulated_device_cloud_upload/CMakeFiles/simulated_device_cloud_upload_sample.dir/src/module_service_config_disabled.c.o
[ 84%] Building C object samples/experimental/events_sample/CMakeFiles/events_sample.dir/src/main.c.o
[ 85%] Building C object samples/simulated_device_cloud_upload/CMakeFiles/simulated_device_cloud_upload_sample.dir/src/main.c.o
make[1]: *** [bindings/nodejs/CMakeFiles/nodejs_binding.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 87%] Linking C executable events_sample
[ 88%] Linking C executable simulated_device_cloud_upload_sample
[ 88%] Built target events_sample
[ 88%] Built target simulated_device_cloud_upload_sample
make[1]: *** [bindings/nodejs/CMakeFiles/nodejs_binding_static.dir/all] Error 2
make: *** [all] Error 2

I tried to run ./tools/build.sh with -cl -Wno-everything and later -cl -w with no success.

I suppose my next attempt will be to patch that code, but it doesn't look like a good solution. Is this a known issue? is it macOS (clang) related?

Thanks in advance!

damonbarry commented 6 years ago

@rcastill Thanks for trying this out. When we added macOS support a while back (April 2017), we only did the work to support the native (C) components and the Java binding. We later added support for out-of-proc Java modules too. We'd like to add support for Node.js and .NET Core modules also, but we haven't been able to allocate the time/resources to do it. The work shouldn't be difficult--probably just fixing a few little hang-ups like the issues you encountered--but we just haven't done it yet.

So the next step would, in fact, be to (1) update build_nodejs.sh to copy dylibs in the macOS case, and (2) fix the build errors, as you suggested. We'd happily accept your contribution!

rcastill commented 6 years ago

@damonbarry thanks for your answer, I'll see what I can do!