Undefined symbols for arm64
-
Hello,
I am trying to implement the Tiny AES library for a proyect (Mobile Android and iOS) and when I try to compile, I get this errors:
Undefined symbols for architecture arm64: "AES_ECB_encrypt(unsigned char*, unsigned char const*, unsigned char*, unsigned int)", referenced from: BLEInterface::onCharacteristicChanged(QLowEnergyCharacteristic const&, QByteArray const&) in bleinterface.o "AES_init(unsigned char)", referenced from: BLEInterface::onCharacteristicChanged(QLowEnergyCharacteristic const&, QByteArray const&) in bleinterface.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
The app has been working fine, this errors have appeared from the Tiny AES Lib import.
I have searched that it could be a wrong CMake config, but I have the -DCMAKE_OSX_ARCHITECTURES:STRING=arm64Thank you
-
Hello,
I am trying to implement the Tiny AES library for a proyect (Mobile Android and iOS) and when I try to compile, I get this errors:
Undefined symbols for architecture arm64: "AES_ECB_encrypt(unsigned char*, unsigned char const*, unsigned char*, unsigned int)", referenced from: BLEInterface::onCharacteristicChanged(QLowEnergyCharacteristic const&, QByteArray const&) in bleinterface.o "AES_init(unsigned char)", referenced from: BLEInterface::onCharacteristicChanged(QLowEnergyCharacteristic const&, QByteArray const&) in bleinterface.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
The app has been working fine, this errors have appeared from the Tiny AES Lib import.
I have searched that it could be a wrong CMake config, but I have the -DCMAKE_OSX_ARCHITECTURES:STRING=arm64Thank you
-
Hello,
I am trying to implement the Tiny AES library for a proyect (Mobile Android and iOS) and when I try to compile, I get this errors:
Undefined symbols for architecture arm64: "AES_ECB_encrypt(unsigned char*, unsigned char const*, unsigned char*, unsigned int)", referenced from: BLEInterface::onCharacteristicChanged(QLowEnergyCharacteristic const&, QByteArray const&) in bleinterface.o "AES_init(unsigned char)", referenced from: BLEInterface::onCharacteristicChanged(QLowEnergyCharacteristic const&, QByteArray const&) in bleinterface.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
The app has been working fine, this errors have appeared from the Tiny AES Lib import.
I have searched that it could be a wrong CMake config, but I have the -DCMAKE_OSX_ARCHITECTURES:STRING=arm64Thank you
-
@jsulm The library is provided as source https://github.com/kokke/tiny-AES-c
And I am not using its CMakeLists.txt, I have imported in my src/ and inc/ folders the .h .hpp and .c files and added to my CMakeLists.txt as other sources. -
@SGaist Hi,
This is my CMakeLists.txt
cmake_minimum_required(VERSION 3.16) project(BLETester VERSION 1.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_VERBOSE_MAKEFILE ON) find_package(Qt6 6.4 REQUIRED COMPONENTS Quick Bluetooth Positioning Location Widgets) qt_standard_project_setup() qt_add_executable(BLETester main.cpp mainwindow.cpp bleinterface.cpp mainwindow.h bleinterface.h characteristicinfo.cpp characteristicinfo.h aes.c aes.h aes.hpp ) set_target_properties(BLETester PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) if (APPLE) if (IOS) set_target_properties(BLETester PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist") endif() endif() target_link_libraries(BLETester PRIVATE Qt::Bluetooth Qt::Core Qt::Gui Qt::Qml Qt::Quick Qt::Positioning Qt::Location Qt::Widgets ) install(TARGETS BLETester BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
And included in bleinterface.h:
#include "aes.hpp"
And used in bleinterface.cpp:
AES_init(0); AES_ECB_encrypt(in_Buffer, key, output_Buffer, value[2]);
Thank you.
-
@SGaist Hi,
This is my CMakeLists.txt
cmake_minimum_required(VERSION 3.16) project(BLETester VERSION 1.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_VERBOSE_MAKEFILE ON) find_package(Qt6 6.4 REQUIRED COMPONENTS Quick Bluetooth Positioning Location Widgets) qt_standard_project_setup() qt_add_executable(BLETester main.cpp mainwindow.cpp bleinterface.cpp mainwindow.h bleinterface.h characteristicinfo.cpp characteristicinfo.h aes.c aes.h aes.hpp ) set_target_properties(BLETester PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) if (APPLE) if (IOS) set_target_properties(BLETester PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist") endif() endif() target_link_libraries(BLETester PRIVATE Qt::Bluetooth Qt::Core Qt::Gui Qt::Qml Qt::Quick Qt::Positioning Qt::Location Qt::Widgets ) install(TARGETS BLETester BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
And included in bleinterface.h:
#include "aes.hpp"
And used in bleinterface.cpp:
AES_init(0); AES_ECB_encrypt(in_Buffer, key, output_Buffer, value[2]);
Thank you.
-
@vcasado said in Undefined symbols for arm64:
aes.h aes.hpp
are aes.h and aes.hpp same? It is rare to define two files like that.
@JoeCFD No, the .hpp is like a wrapper that contains:
#ifndef _AES_HPP_ #define _AES_HPP_ #ifndef __cplusplus #error Do not include the hpp header in a c project! #endif //__cplusplus extern "C" { #include "aes.h" } #endif //_AES_HPP_
But in the CMakeLists.txt, the .h is included so it does not report that file not found when compiling
-
@JoeCFD No, the .hpp is like a wrapper that contains:
#ifndef _AES_HPP_ #define _AES_HPP_ #ifndef __cplusplus #error Do not include the hpp header in a c project! #endif //__cplusplus extern "C" { #include "aes.h" } #endif //_AES_HPP_
But in the CMakeLists.txt, the .h is included so it does not report that file not found when compiling
@vcasado
I know nothing about this, but are you sure the 2 undefined references with those parameters are really supposed to be in Tiny AES's libraryaes.h
? When I look at e.g. https://morioh.com/p/67a35723557d or https://github.com/kokke/tiny-AES-c/blob/master/aes.h I do not see either of them? -
@vcasado
I know nothing about this, but are you sure the 2 undefined references with those parameters are really supposed to be in Tiny AES's libraryaes.h
? When I look at e.g. https://morioh.com/p/67a35723557d or https://github.com/kokke/tiny-AES-c/blob/master/aes.h I do not see either of them?@JonB You are right, now the usage in bleinterface.cpp is:
struct AES_ctx ctx; AES_init_ctx(&ctx, key); for (int i = 0; i < 4; ++i) { AES_ECB_encrypt(&ctx, in_Buffer + (i * 16)); }
And the error is:
Undefined symbols for architecture arm64: "_AES_ECB_encrypt", referenced from: BLEInterface::onCharacteristicChanged(QLowEnergyCharacteristic const&, QByteArray const&) in bleinterface.o "_AES_init_ctx", referenced from: BLEInterface::onCharacteristicChanged(QLowEnergyCharacteristic const&, QByteArray const&) in bleinterface.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
-
@JonB You are right, now the usage in bleinterface.cpp is:
struct AES_ctx ctx; AES_init_ctx(&ctx, key); for (int i = 0; i < 4; ++i) { AES_ECB_encrypt(&ctx, in_Buffer + (i * 16)); }
And the error is:
Undefined symbols for architecture arm64: "_AES_ECB_encrypt", referenced from: BLEInterface::onCharacteristicChanged(QLowEnergyCharacteristic const&, QByteArray const&) in bleinterface.o "_AES_init_ctx", referenced from: BLEInterface::onCharacteristicChanged(QLowEnergyCharacteristic const&, QByteArray const&) in bleinterface.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
@vcasado
I also know nothing about cmake :) Can you at least show the full linker command line it uses, let's see whetherlibaes.a
is even there? Assuming it comes with a library not just source code you compile into yours. I also know nothing about Android/iOS building! -
@vcasado
I also know nothing about cmake :) Can you at least show the full linker command line it uses, let's see whetherlibaes.a
is even there? Assuming it comes with a library not just source code you compile into yours. I also know nothing about Android/iOS building! -
@JonB There is no compiled library, that is why I am compiling it as it would be more sources of my project
You have locked your project to C++ only. Remove that and rebuild.
-
@SGaist Hi,
This is my CMakeLists.txt
cmake_minimum_required(VERSION 3.16) project(BLETester VERSION 1.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_VERBOSE_MAKEFILE ON) find_package(Qt6 6.4 REQUIRED COMPONENTS Quick Bluetooth Positioning Location Widgets) qt_standard_project_setup() qt_add_executable(BLETester main.cpp mainwindow.cpp bleinterface.cpp mainwindow.h bleinterface.h characteristicinfo.cpp characteristicinfo.h aes.c aes.h aes.hpp ) set_target_properties(BLETester PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) if (APPLE) if (IOS) set_target_properties(BLETester PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist") endif() endif() target_link_libraries(BLETester PRIVATE Qt::Bluetooth Qt::Core Qt::Gui Qt::Qml Qt::Quick Qt::Positioning Qt::Location Qt::Widgets ) install(TARGETS BLETester BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
And included in bleinterface.h:
#include "aes.hpp"
And used in bleinterface.cpp:
AES_init(0); AES_ECB_encrypt(in_Buffer, key, output_Buffer, value[2]);
Thank you.
-
@vcasado said in Undefined symbols for arm64:
project(BLETester VERSION 1.1 LANGUAGES CXX)
I'm purely guessing, but chage this? E.g.
... LANGUAGES CXX C
?@JonB said in Undefined symbols for arm64:
@vcasado said in Undefined symbols for arm64:
project(BLETester VERSION 1.1 LANGUAGES CXX)
I'm purely guessing, but chage this? E.g.
... LANGUAGES CXX C
?Fixed with this! Thank you!