-
-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to find NimBLEServerCallbacks during linking in IDF as Lib environment #255
Comments
Interesting, I've not done this before so I don't have a lot to offer. It looks like something is either being built differently this way (flags of some kind?) or it is not able to find an instance of the class declared. |
Thank you for your response, After further investigation, I found that the issue was indeed related to a compiler option, as you suggested. Specifically, enabling RTTI in the SDK config resolves the issue, as described in the ESP-IDF documentation. This enables the -frtti compiler flag. However, since RTTI is disabled by default in ESP-IDF, I'm hesitant to use it due to its potential drawbacks, such as increased code size and memory usage. I have two follow-up questions:
|
Interesting indeed, there should be no need for RTTI though. It's not used in platformio or Arduino either. |
Strange, indeed. When RTTI is enabled, the I’ll investigate the matter and the impact of enabling RTTI further when I have more time. If the impact on code size and performance is minimal, I may consider using it as a workaround. However, since you mentioned RTTI shouldn’t be necessary, I’d prefer not to rely on it unless required. That said, if you have any insights or ideas in the meantime, I’d greatly appreciate them. |
What commit are you using from this repo? |
Okay, one more question. If you remove the callbacks completely from your application code does it build? The reason I am asking is because I have not really done any updates to those examples and some of the signatures could be off, which doesn't show up compiling with esp-idf. |
The callbacks themselves build fine, until I add the following line: pServer->setCallbacks(new ServerCallbacks()); So no callbacks, no Declaring a class that inherits from |
If you try the client example do you get this issue with it's callbacks? |
Yes I face the same issues with the client example. Additionally I want to clarify that I was wrong earlier. Declaring a class that inherits from static ServerCallbacks serverCallbacks; // Inherited from NimBLEServerCallbacks So generally I think creating instances of callback child classes seems to be the problem in my case. |
I can answer this question
It is disabled everywhere. It has major impact in code size. It is disabled by default in IDF projects too. https://github.com/espressif/esp-idf/blob/083aad99cfc1a7981009ac7f18e29824c47ffba2/CMakeLists.txt#L60-L65 |
I am attempting to replicate the Advanced NimBLE Server example provided in this repository within an environment where ESP-IDF is used as a library (IDF as Lib). This setup minimizes dependence on the ESP-IDF build system and instead uses a more traditional CMake workflow, as outlined in the Espressif IDF as Lib example.
The integration involves the following steps:
esp-nimble-cpp
as a submodule and including it as an external component.esp-nimble-cpp
usingidf_build_component(component_dir)
.idf::esp-nimble-cpp
.While basic functionality of the NimBLE example works, implementing custom callback methods fails during the linking stage with errors indicating that the
NimBLEServerCallbacks
class cannot be found.Steps to Reproduce:
Set up a project using the IDF as Lib structure.
Add
esp-nimble-cpp
as an external component using CMake:Build the project with
idf_build_component
.Implement and use custom callbacks that inherit from
NimBLEServerCallbacks
as done in the example:Link and build the project.
Expected Behavior:
The project should build and link successfully, allowing the use of
NimBLEServerCallbacks
and custom callback methods without errors.Actual Behavior:
The linker fails to resolve
NimBLEServerCallbacks
methods, resulting in errors similar to the following:This issue suggests that the linker is unable to locate the
NimBLEServerCallbacks
symbols, despite them being defined inesp_nimble_cpp
.Findings and Investigations:
Linker Error:
The full linker error output is as follows (paths obfuscated):
Symbols Verification:
Using
nm
to inspect theesp_nimble_cpp
library confirms that theNimBLEServerCallbacks
symbols are present:nm build/esp-idf/esp_nimble_cpp/libesp_nimble_cpp.a | grep NimBLEServerCallbacks 00000000 T _ZN12NimBLEServer12setCallbacksEP21NimBLEServerCallbacksb 00000000 T _ZN21NimBLEServerCallbacks10onIdentityER14NimBLEConnInfo 00000000 T _ZN21NimBLEServerCallbacks12onDisconnectEP12NimBLEServerR14NimBLEConnInfoi 00000000 W _ZN21NimBLEServerCallbacksD0Ev 00000000 V _ZTV21NimBLEServerCallbacks ...
TypeInfo Issues:
The missing
_ZTI21NimBLEServerCallbacks
(type info) suggests that the runtime type information (RTTI) or vtable for this class is not being linked correctly.Environment:
Additional Context:
CMake Setup for Library:
The
esp-nimble-cpp
component is built as follows in the rootCMakeLists.txt
:This setup works for most components but fails to resolve the symbols for
NimBLEServerCallbacks
.Potential Setup Differences:
I acknowledge that my setup diverges from what is described in the project’s README. This is somewhat unconventional, and I realize it might cause unforeseen issues.
Despite this, I am reaching out in case you have any insights or ideas that could help resolve this problem. Any guidance would be greatly appreciated!
Thank you for your time and support!
The text was updated successfully, but these errors were encountered: