Symbols error on windows build using ESP-IDF 4.1

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Symbols error on windows build using ESP-IDF 4.1

Postby PeterR » Fri Dec 20, 2019 6:09 pm

I have been using Legacy GNU make with ESP-IDF 4.0 and toolchain from 3.3 stable for some time.
The application built and ran ok.
I attempted to use ESP-IDF 4.1 legacy with toolchain esp32-2019r2. That combination built my application code but failed to link reporting an issue with pthread linkage (viewtopic.php?f=2&t=13563#p53403)

So I then attempted to convert to CMake (EDIT: because a small example failed pthred linkage as a GNU legacy build but was fine as a Cmake build). I now get several linking errors from my own routines (which used to link) - I have swapped one problem for another.
For example the following complains that I am missing my HTTP content type lookup function (a simple file extension to content type):

Code: Select all

c:/users/pete/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/WebApp/libWebApp.a(WebAppRequestServer.cpp.obj):(.literal._ZN19WebAppRequestServer7RequestEP12IHttpRequestP13IHttpResponse+0x44): undefined reference to `HttpContentType(char const*)'
The calling code is (WebAppRequestServer.cpp, libWebApp.a):

Code: Select all

HTTP_HANDLER_RESULT WebAppRequestServer::Request(IHttpRequest *request, IHttpResponse *response)
{
    response->SetHeader(HttpHeaderContentType, HttpContentType(".json"));
and the called routine is (HttpCommon, libPlatforms.a):

Code: Select all

const char *HttpContentType(const char *filename)
{

Code: Select all

nm libPlatforms.a
tells me:

Code: Select all

HttpCommon.cpp.obj:
00000000 T _Z15HttpContentTypePKc
         U _ZN9MimeTypes7getTypeEPKc
00000000 D HttpHeaderCacheControl
00000000 D HttpHeaderCacheControlNoStore
00000000 D HttpHeaderContentEncoding
00000000 D HttpHeaderContentType
         U printf

Code: Select all

nm libWebApp.a
Tells me:

Code: Select all

WebAppRequestServer.cpp.obj:
         U __cxa_allocate_exception
         U __cxa_free_exception
         U __cxa_pure_virtual
         U __cxa_throw
         U __gxx_personality_v0
00000000 t _GLOBAL__sub_D__Z12ParseBooleanNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
00000000 t _GLOBAL__sub_I__Z12ParseBooleanNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
         U _Unwind_Resume
00000000 T _Z12ParseBooleanNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
         U _Z15HttpContentTypePKc
So reference and declaration seem the same to me.
The errors seem centred around three files (HttpCommon.cpp, HttpPath.cpp, HttpFileServer.cpp) in one folder '/Platforms/Common/src' - but not all the files in that folder!
The files exist in the CMakeList.txt

EDIT: Seems to me that I am missing something obvious. My directory structure is a little convoluted, I need to refactor sure, but a static library is a static library! Why then missing symbols!
& I also believe that IDF CAN should be fixed.

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: Symbols error on windows build using ESP-IDF 4.1

Postby PeterR » Sat Dec 21, 2019 12:28 pm

Moving the .cpp files to the caller's component's directory (but not headers) allows me to complete the build.
Along the way I first only updated the new CMakeList.txt and so confirmed the missing file build error from original CMakeList.txt.

Moving files is not a long term solution however!

I have not yet been able to reproduce this with a small worked example.
Along with the C++11 pthread linking issue within the legacy GNU build though then there does seem to be an issue with the linking process.
& I also believe that IDF CAN should be fixed.

Who is online

Users browsing this forum: Baidu [Spider], burtrum, Google [Bot] and 127 guests