aws / aws-iot-device-sdk-embedded-C

SDK for connecting to AWS IoT from a device using embedded C.
MIT License
975 stars 623 forks source link

ld: symbol(s) not found for architecture arm64 - Error when installing libraries #1827

Closed MSKoWa closed 1 year ago

MSKoWa commented 1 year ago

Hello there,

I tried to install the libraries following the instructions in the README (clone and install section). I can download the repo and create a build folder using the cmake command. However, when it comes to sudo make install I receive the following error:

[  0%] Building C object CMakeFiles/aws_iot_defender.dir/libraries/aws/device-defender-for-aws-iot-embedded-sdk/source/defender.c.o
[  1%] Linking C shared library lib/libaws_iot_defender.dylib
[  1%] Built target aws_iot_defender
[  1%] Building C object CMakeFiles/aws_iot_shadow.dir/libraries/aws/device-shadow-for-aws-iot-embedded-sdk/source/shadow.c.o
[  2%] Linking C shared library lib/libaws_iot_shadow.dylib
[  2%] Built target aws_iot_shadow
[  3%] Building C object CMakeFiles/aws_iot_jobs.dir/libraries/aws/jobs-for-aws-iot-embedded-sdk/source/jobs.c.o
[  4%] Linking C shared library lib/libaws_iot_jobs.dylib
[  4%] Built target aws_iot_jobs
[  4%] Building C object CMakeFiles/aws_iot_json.dir/libraries/standard/coreJSON/source/core_json.c.o
[  5%] Linking C shared library lib/libaws_iot_json.dylib
[  5%] Built target aws_iot_json
[  6%] Building C object CMakeFiles/aws_iot_ota.dir/libraries/aws/ota-for-aws-iot-embedded-sdk/source/ota.c.o
[  7%] Building C object CMakeFiles/aws_iot_ota.dir/libraries/aws/ota-for-aws-iot-embedded-sdk/source/ota_interface.c.o
[  7%] Building C object CMakeFiles/aws_iot_ota.dir/libraries/aws/ota-for-aws-iot-embedded-sdk/source/ota_base64.c.o
[  8%] Linking C shared library lib/libaws_iot_ota.dylib
Undefined symbols for architecture arm64:
  "_OTA_JsonFileSignatureKey", referenced from:
      _otaJobDocModelParamStructure in ota.c.o
  "_appFirmwareVersion", referenced from:
      _validateUpdateVersion in ota.c.o
      _updateJobStatusFromImageState in ota.c.o
  "_cleanupControl_Mqtt", referenced from:
      _setControlInterface in ota_interface.c.o
  "_cleanupData_Mqtt", referenced from:
      _setDataInterface in ota_interface.c.o
  "_decodeFileBlock_Mqtt", referenced from:
      _setDataInterface in ota_interface.c.o
  "_initFileTransfer_Mqtt", referenced from:
      _setDataInterface in ota_interface.c.o
  "_requestFileBlock_Mqtt", referenced from:
      _setDataInterface in ota_interface.c.o
  "_requestJob_Mqtt", referenced from:
      _setControlInterface in ota_interface.c.o
  "_updateJobStatus_Mqtt", referenced from:
      _setControlInterface in ota_interface.c.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libaws_iot_ota.dylib] Error 1
make[1]: *** [CMakeFiles/aws_iot_ota.dir/all] Error 2
make: *** [all] Error 2

Does anyone have an idea what can causes this error? I tried to add the -v option vor verbose output but it only gave me this:

GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0

so I suppose it is the wrong way I did it (I just did sudo make install -v)

Thanks in advance!

aggarg commented 1 year ago

Which OS and hardware are you running on?

MSKoWa commented 1 year ago

MacOS 12.4

RichardKieneRivian commented 1 year ago

I'm having the exact same issue. If I exclude the OTA libraries when I run the initial cmake command with:

cmake -S . -Bbuild -DBUILD_DEMOS=0 -DBUILD_TESTS=0 -DINSTALL_TO_SYSTEM=1 -DINSTALL_LIBS="DEFENDER;SHADOW;JOBS;BACKOFF_ALGORITHM;HTTP;JSON;MQTT;PKCS"

then sudo make install succeeds.

However if I don't exclude OTA libraries then sudo make install fails with the same error shown above. When I run make -n install it reveals the following issue:

...
make[2]: *** No rule to make target `lib/libtinycbor.dylib', needed by `lib/libaws_iot_ota_mqtt.dylib'.  Stop.
make[1]: *** [CMakeFiles/aws_iot_ota_mqtt.dir/all] Error 2
make: *** [all] Error 2

This definitely seems like a library necessary for linking is not being built but I haven't been able to track it down yet.

RichardKieneRivian commented 1 year ago

Update:

If I run make in aws-iot-device-sdk-embedded-C/build/libraries then libtinycbor.dylib is created and placed in the lib folder. However that results in another library build failure.

make[2]: *** No rule to make target `lib/libsockets_posix.dylib', needed by `lib/libplaintext_posix.dylib'.  Stop.
make[1]: *** [platform/posix/transport/CMakeFiles/plaintext_posix.dir/all] Error 2
make: *** [all] Error 2
archigup commented 1 year ago

Hi, is there a specific reason you need to install the libraries? We don't recommend installing the libraries as system dynamic libraries; instead we would recommend you link the libraries statically as shown in our demos.

RichardKieneRivian commented 1 year ago

That definitely makes setting up a build more cumbersome but if dynamic linking isn't supported then I can go that route. Should the section on installing the libraries be removed if it isn't supported?

aggarg commented 1 year ago

Should the section on installing the libraries be removed if it isn't supported?

That seems like the right suggestion. I'll share with the team.

archigup commented 1 year ago

Removing install instructions here: https://github.com/aws/aws-iot-device-sdk-embedded-C/pull/1850