Page 1 of 2

Multiple definition of functions when trying to use regex

Posted: Wed Apr 22, 2020 6:35 am
by zliudr
I "make clean" already. Code is minimal. It seems that I can't use

Code: Select all

In function `std::__throw_logic_error(char const*)':
functexcept.cc:(.text._ZSt19__throw_logic_errorPKc+0x0): multiple definition of `std::__throw_logic_error(char const*)'
My code: hello_world.cpp

Code: Select all

#include "esp_system.h"
#include <iostream>
#include <regex>


extern "C" void app_main()
{
	char char_array[]="12345678";
	//std::string str="12345678901234";
	std::regex reg1 ("^(\\d{8}|\\d{12,14})$");

   for (int i = 10; i >= 0; i--) 
	{
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
    esp_restart();
}

Re: Multiple definition of functions when trying to use regex

Posted: Wed Apr 22, 2020 8:08 am
by ESP_Sprite
If you haven't done this already, can you post this as an issue on Github as well? Makes it a bit easier for us to track it and give feedback.

Re: Multiple definition of functions when trying to use regex

Posted: Wed Apr 22, 2020 1:45 pm
by zliudr
Thank you for your advice! I've not raised this issue on git yet. I'm using V3.3 so I'm not very up to date. I've read that the beta version of ESP-IDF 4.1 has included regex.h support for C. I'd rather use C support than the C++ std (ugly and probably costs unnecessarily large memory footprint with concats). But I'm in the middle of an important development and don't want to introduce any uncertainties by updating my tool chain. If I can get regex match with V3.3 that would be great. Thanks.

Re: Multiple definition of functions when trying to use regex

Posted: Wed Apr 22, 2020 3:26 pm
by ESP_igrr
Tracking this internally as IDFGH-3153.

Re: Multiple definition of functions when trying to use regex

Posted: Thu Apr 23, 2020 3:18 am
by zliudr
Should I still post to git? Thanks.

Re: Multiple definition of functions when trying to use regex

Posted: Thu Apr 23, 2020 8:36 am
by ESP_igrr
No need, already have an issue logged for this. Will give you feedback once this is resolved.

Re: Multiple definition of functions when trying to use regex

Posted: Thu May 21, 2020 6:46 am
by nickname
Hi @zliudr,

Do you mind trying the attached patch? I could reproduce your problem on IDF v3.3 and the patch solves it.

Thanks!

Re: Multiple definition of functions when trying to use regex

Posted: Thu Jun 04, 2020 6:05 am
by zliudr
Hi sorry about the delay. Could you show me how to use that file please? I've never used this type of file before. I tried this under msys32:
diff --git a/components/cxx/cxx_exception_stubs.cpp b/components/cxx/cxx_exception_stubs.cpp index f09f946ddc..5e8f955a0b 100644

The shell doesn't under diff.

Can you please just give me a link to the new file? I don't know enough about git to make use of your solution. Also where is the link to the issue IDFGH-3153?

Re: Multiple definition of functions when trying to use regex

Posted: Wed Jun 10, 2020 7:33 pm
by zliudr
Please! If I knew how to implement this patch I wouldn't be bugging you at all. If you helped me once, please don't let your effort go to waste. Show me how to make the change, or just attach the modified file. I don't care what git does. Thank you.

Re: Multiple definition of functions when trying to use regex

Posted: Thu Jun 11, 2020 12:16 am
by PeterR
If I understand your question correctly then:
Expand zip into /esp-idf

Code: Select all

cd ./esp-idf
git apply 0001-Add-missing-regex_error-stub.patch
The main problem then is to make sure that you have checked out the correct version of the IDF to which this patch applies (basically a patch is a set of diffences and if your esp-idf is not the same as from which the .patch difference was generated then the patch process will fail).
Also note that if your lf/cr settings are different then Git patch will also complain. Typically an issue under Windows but if you clone from ming u should be ok (detail & detail excluded).

Its too late to dig deeper but thought I would throw in a quick little pointer as you seem in need of a hint!