undefined reference to memcpy, memmove, memset, ...

jumjum123
Posts: 199
Joined: Mon Oct 17, 2016 3:11 pm

undefined reference to memcpy, memmove, memset, ...

Postby jumjum123 » Thu Sep 07, 2017 10:33 am

Just downloaded latest ESP-IDF.
During linking with my make, I get an undefined reference error for memcpy, memmove, memset, memcmp, and strcmp, strcpy
This was not the case with ESP-IDF about a week ago.
Is there anything new in actual download ?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: undefined reference to memcpy, memmove, memset, ...

Postby kolban » Thu Sep 07, 2017 2:26 pm

Howdy,
Just a thought ... knowing the project you are working with, I believe you are working with a custom "Makefile" building apps. Specifically, you are performing your own link in your own custom Makefile. The ESP-IDF provides its own "build system" that happens "under the covers" through the ESP-IDF Makefile. ESP-IDF releases may change the libraries that are linked and your own custom Makefile will have to replicate those changes to be consistent.

Again ... just a guess.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

jumjum123
Posts: 199
Joined: Mon Oct 17, 2016 3:11 pm

Re: undefined reference to memcpy, memmove, memset, ...

Postby jumjum123 » Thu Sep 07, 2017 3:44 pm

Hello Neil,

yes, I'm still working on Espruino.
Already had some problems with new heap component, but this is solved.

Problem is to find out, which library (or whatever) needs to be involved.
Any idea, how to check this ?

Right now compiling runs fine, after adding libc-psram-workaround.a. Thats based on guess, trial and error
Sounds good, but now it does not start Espruoino anymore :(

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: undefined reference to memcpy, memmove, memset, ...

Postby ESP_Angus » Thu Sep 07, 2017 10:57 pm

I think I saw this as well recently with partial builds after an update, there's an intermediate build file that isn't being regenerated like it should.

"make clean" and then building again should solve it, you shouldn't need to hack up any IDF files.

If it's still broken, let us know and we'll try and take a look at your project.

jumjum123
Posts: 199
Joined: Mon Oct 17, 2016 3:11 pm

Re: undefined reference to memcpy, memmove, memset, ...

Postby jumjum123 » Fri Sep 08, 2017 11:36 am

Thanks for the feedback, downloaded latest version from github and still got undefined reference

Next added
-T(ESP_IDF_PATH)/components/esp32/ld/esp32.rom.spiram_incompatible_fns.ld
Now got undefined reference for esp_pthread_init

Next added
-L$(ESP_APP_TEMPLATE_PATH)/build/pthread \
-I$(ESP_IDF_PATH)/components/pthread/include \
-lheap \

Compiling runs fine. Size of binary is about 30k less than before.

Uploaded to ESP Board and it works, at least with simple test. 8-)

Would there be any way to find changes like this, instead of my simple textsearch, trial & error ?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: undefined reference to memcpy, memmove, memset, ...

Postby kolban » Fri Sep 08, 2017 6:26 pm

One way would be to write a simple ESP-IDF application using the Espressif ESP-IDF build system. You can then set the environment variable V=1 and run the build system. This will produce a detailed description of all the flags passed to the compile when the C code is compiled and all the linked flags passed to the linker when the link step is performed. From this, you can reverse engineer the flags that the ESP-IDF build system is using.

To the best of my knowledge, the "internals" of the build system supplied be ESP-IDF aren't documented/broken apart and the high level expectation is to use the build environment to create ESP32 applications. That said, there should be no mystery nor magic in the build meaning that if you write your own scripts or build your own Makefile that does the same as the ESP-IDF build system, you should be just fine.

To perform "regression" checks, get yourself to a working environment and take a copy of the Makefiles necessary to build a regular ESP-IDF environment. Put them somewhere safe. Now, when ever you grab a new copy of the master ESP-IDF, you can perform a file diff against those few files and the ones you had saved when it was working. That way you will at least be "made aware" when a change is made to the build environment so that you can reflect any necessary changes back into your own build environment.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

jumjum123
Posts: 199
Joined: Mon Oct 17, 2016 3:11 pm

Re: undefined reference to memcpy, memmove, memset, ...

Postby jumjum123 » Sat Sep 09, 2017 6:48 am

@nkolban,
thanks, for the idea.We have a wording for what happens to me from time to time.

Sometimes you cannot see the wood, because of all the trees :)

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: undefined reference to memcpy, memmove, memset, ...

Postby ESP_Sprite » Sun Sep 10, 2017 6:30 am

Jumjum123: Hehe, either you're Dutch or multiple languages developed the same saying :)

jumjum123
Posts: 199
Joined: Mon Oct 17, 2016 3:11 pm

Re: undefined reference to memcpy, memmove, memset, ...

Postby jumjum123 » Sun Sep 10, 2017 7:18 am

@ESP_Sprite,
good guess, its Germany close to Venlo :D

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: undefined reference to memcpy, memmove, memset, ...

Postby kolban » Sun Sep 10, 2017 11:03 pm

Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Who is online

Users browsing this forum: Majestic-12 [Bot] and 367 guests