wxsqlite3.cpp: Undefined reference to `wxRegEx::~wxRegEx()'- Linux

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
AshtonC1
Earned some good credits
Earned some good credits
Posts: 100
Joined: Wed Feb 18, 2015 4:56 pm

wxsqlite3.cpp: Undefined reference to `wxRegEx::~wxRegEx()'- Linux

Postby AshtonC1 » Mon Jun 12, 2017 1:56 pm

I am receiving this compile error, I have never before received using SQLite3/wxSQLite3, in multiple projects.
(../src/wxsqlite3.cpp:4614: undefined reference to `wxRegEx::~wxRegEx()')

Code: Select all

-------------- Build: Debug in wxSQLi_417 (compiler: GNU GCC Compiler)---------------

g++ -L/usr/local/lib -L/usr/local/lib -o bin/Debug/wxSQLi_417 obj/Debug/metrics.o obj/Debug/pdf.o obj/Debug/quickmail.o obj/Debug/wxForm1.o obj/Debug/wxForm2.o obj/Debug/wxSQLi_417App.o obj/Debug/wxSQLi_417Main.o  -L/usr/local/lib -pthread   /usr/local/lib/libwx_gtk3u_xrc-3.0.a /usr/local/lib/libwx_gtk3u_qa-3.0.a /usr/local/lib/libwx_baseu_net-3.0.a /usr/local/lib/libwx_gtk3u_html-3.0.a /usr/local/lib/libwx_gtk3u_adv-3.0.a /usr/local/lib/libwx_gtk3u_core-3.0.a /usr/local/lib/libwx_baseu_xml-3.0.a /usr/local/lib/libwx_baseu-3.0.a -lgthread-2.0 -pthread -lX11 -lXxf86vm -lSM -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lpng -lexpat -lwxregexu-3.0 -lwxtiff-3.0 -lwxjpeg-3.0 -lz -ldl -lm  -lsqlite3 -lcurl  /usr/local/lib/libwxcode_gtk3u_wxsqlite3-3.0.a
/usr/local/lib/libwxcode_gtk3u_wxsqlite3-3.0.a(wxsqlite3.o): In function `wxSQLite3RegExpOperator::~wxSQLite3RegExpOperator()':
/home/stv/Downloads/wxsqlite3-3.5.3/build-gtk/../src/wxsqlite3.cpp:4614: undefined reference to `wxRegEx::~wxRegEx()'
/usr/local/lib/libwxcode_gtk3u_wxsqlite3-3.0.a(wxsqlite3.o): In function `wxRegEx::wxRegEx()':
/usr/local/include/wx-3.0/wx/regex.h:76: undefined reference to `wxRegEx::Init()'
/usr/local/lib/libwxcode_gtk3u_wxsqlite3-3.0.a(wxsqlite3.o): In function `wxSQLite3RegExpOperator::Execute(wxSQLite3FunctionContext&)':
/home/stv/Downloads/wxsqlite3-3.5.3/build-gtk/../src/wxsqlite3.cpp:4628: undefined reference to `wxRegEx::Compile(wxString const&, int)'
/home/stv/Downloads/wxsqlite3-3.5.3/build-gtk/../src/wxsqlite3.cpp:4632: undefined reference to `wxRegEx::Matches(wxString const&, int) const'
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 1 second(s))
5 error(s), 0 warning(s) (0 minute(s), 1 second(s))


I have researched this, but most of the other solutions, like link library order, didn't correct my errors.

The link libraries I have are: libwxcode_gtk3u_wxsqlite3-3.0.a and libwxregexu-3.0.a

Any advice greatly appreciated.
Last edited by AshtonC1 on Mon Jun 12, 2017 3:08 pm, edited 1 time in total.

DavidHart
Site Admin
Site Admin
Posts: 3615
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: wxsqlite3.cpp: Undefined reference to `wxRegEx::~wxRegEx()'- Linux

Postby DavidHart » Mon Jun 12, 2017 2:15 pm

I'm not clear what you are doing to get that error. Are you building wxsqlite, or are you trying to link to it?

If the latter, can you post or pastebin a minimal compilable program that demonstrates the problem. And did the wxsqlite samples build successfully?

AshtonC1
Earned some good credits
Earned some good credits
Posts: 100
Joined: Wed Feb 18, 2015 4:56 pm

Re: wxsqlite3.cpp: Undefined reference to `wxRegEx::~wxRegEx()'- Linux

Postby AshtonC1 » Mon Jun 12, 2017 2:47 pm

Thanks David,
...Are you building wxsqlite, or are you trying to link to it?


I don't believe so, No.

The build log indicates that: function `wxSQLite3RegExpOperator::~wxSQLite3RegExpOperator()' is referring to the ../src/wxsqlite3.cpp file.
The way I read it.

The build log should indicate what is happening, but I'm not understanding the cause yet.

DavidHart
Site Admin
Site Admin
Posts: 3615
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: wxsqlite3.cpp: Undefined reference to `wxRegEx::~wxRegEx()'- Linux

Postby DavidHart » Mon Jun 12, 2017 3:04 pm

>>...Are you building wxsqlite, or are you trying to link to it?
I don't believe so, No.

I'd assumed that the answer to one of those questions would be 'Yes' ;) .

Please could you explain more about what you are doing, and why...

AshtonC1
Earned some good credits
Earned some good credits
Posts: 100
Joined: Wed Feb 18, 2015 4:56 pm

Re: wxsqlite3.cpp: Undefined reference to `wxRegEx::~wxRegEx()'- Linux

Postby AshtonC1 » Mon Jun 12, 2017 3:25 pm

Edit:
The IDE was causing the original wxRegex error apparently.
When I closed it, it became unresponsive.
Upon re-open and build of project, the below new wxRegex error displayed.

Code: Select all

/usr/bin/ld: /usr/local/lib/libwxcode_gtk3u_wxsqlite3-3.0.a(wxsqlite3.o): undefined reference to symbol '_ZNK7wxRegEx7MatchesERK8wxStringi@@WXU_3.0'
//usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 17 second(s))
2 error(s), 1 warning(s) (0 minute(s), 17 second(s))
 

AshtonC1
Earned some good credits
Earned some good credits
Posts: 100
Joined: Wed Feb 18, 2015 4:56 pm

Re: wxsqlite3.cpp: Undefined reference to `wxRegEx::~wxRegEx()'- Linux

Postby AshtonC1 » Mon Jun 12, 2017 6:52 pm

Edit: incorrect drivel out..

I created a new project with only this bit of code to open a database, same error on build.

Code: Select all

void db_Connect_GUIFrame::OnButton1Click(wxCommandEvent& event)
{
    wxSQLite3/usr/local/lib/libwxcode_gtk3u_wxsqlite3-3.0.aDatabase* db = new wxSQLite3Database();
  wxString testDBName = wxGetCwd() + wxT("/database.db");
    db->Open(testDBName);
   wxSQLite3ResultSet Res = db->ExecuteQuery(wxString::Format(_("%s"),txtSQL->GetValue()));

  wxMessageBox("db Opened....");
}
Last edited by AshtonC1 on Mon Jun 12, 2017 8:00 pm, edited 1 time in total.

DavidHart
Site Admin
Site Admin
Posts: 3615
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: wxsqlite3.cpp: Undefined reference to `wxRegEx::~wxRegEx()'- Linux

Postby DavidHart » Mon Jun 12, 2017 7:16 pm

(Written before your edit and update:

Thank you, that's much clearer.

I can think of 2 things to try:
1) First check your static wx3.0.3 build supports wxRegEx. I just did that with mine by adding to the source of the 'minimal' sample:
#include "wx/regex.h"
and in the frame ctor:
wxRegEx foo("Test");
IIt built OK.
As you probably don't have the samples on the target box, copy over the 'minimal' source to it, adjust it as above, then build it with:
g++ minimal.cpp `wx-config --cxxflags --libs` -o minimal
having first made sure your wx is the static build; the easy way to do that is to prepend it to the PATH:
PATH=/full/path/to/wxstaticbuild:$PATH

2) If that works OK, do the same thing with wxSQLite3ResultSet Res;
adding the correct #include(s), and linker line for libwxcode_gtk3u_wxsqlite3-3.0.a

DavidHart
Site Admin
Site Admin
Posts: 3615
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: wxsqlite3.cpp: Undefined reference to `wxRegEx::~wxRegEx()'- Linux

Postby DavidHart » Mon Jun 12, 2017 7:17 pm

Doing:
c++filt _ZNK7wxRegEx7MatchesERK8wxStringi
gives:
wxRegEx::Matches(wxString const&, int) const

AshtonC1
Earned some good credits
Earned some good credits
Posts: 100
Joined: Wed Feb 18, 2015 4:56 pm

Re: wxsqlite3.cpp: Undefined reference to `wxRegEx::~wxRegEx()'- Linux

Postby AshtonC1 » Mon Jun 12, 2017 9:11 pm

Thanks David,

1)
#include "wx/regex.h"
and in the frame ctor:
wxRegEx foo("Test");


Result:

Code: Select all

-------------- Build: Debug in db_Connect_GUI (compiler: GNU GCC Compiler)---------------
g++ -I/usr/lib/x86_64-linux-gnu/wx/include/gtk2-unicode-3.0 -I/usr/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -Wall -g -std=c++11 -I/usr/local/lib -c /home/stv/Documents/wxW_Projs/db_Connect_GUI/db_Connect_GUIMain.cpp -o obj/Debug/db_Connect_GUIMain.o
g++ -L/usr/local/lib -o bin/Debug/db_Connect_GUI obj/Debug/db_Connect_GUIApp.o obj/Debug/db_Connect_GUIMain.o  -L/usr/lib/x86_64-linux-gnu -pthread   -lwx_gtk2u_xrc-3.0 -lwx_gtk2u_html-3.0 -lwx_gtk2u_qa-3.0 -lwx_gtk2u_adv-3.0 -lwx_gtk2u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0  -lsqlite3 -lcurl  /usr/local/lib/libwxcode_gtk3u_wxsqlite3-3.0.a
/usr/local/lib/libwx_baseu-3.0.a(baselib_regex.o): In function `wxRegExImpl::~wxRegExImpl()':
regex.cpp:(.text+0x51): undefined reference to `wx_regfree'
/usr/local/lib/libwx_baseu-3.0.a(baselib_regex.o): In function `wxRegEx::~wxRegEx()':
regex.cpp:(.text+0x2cc): undefined reference to `wx_regfree'
/usr/local/lib/libwx_baseu-3.0.a(baselib_regex.o): In function `wxRegExImpl::GetErrorMsg(int, bool) const':
regex.cpp:(.text+0x4c2): undefined reference to `wx_regerror'
regex.cpp:(.text+0x4ee): undefined reference to `wx_regerror'
/usr/local/lib/libwx_baseu-3.0.a(baselib_regex.o): In function `wxRegExImpl::Compile(wxString const&, int)':
regex.cpp:(.text+0xa2a): undefined reference to `wx_re_comp'
regex.cpp:(.text+0x1381): undefined reference to `wx_regfree'
/usr/local/lib/libwx_baseu-3.0.a(baselib_regex.o): In function `wxRegEx::Compile(wxString const&, int)':
regex.cpp:(.text+0x16c4): undefined reference to `wx_regfree'
/usr/local/lib/libwx_baseu-3.0.a(baselib_regex.o): In function `wxRegExImpl::Matches(wchar_t const*, int, unsigned long) const':
regex.cpp:(.text+0x1813): undefined reference to `wx_re_exec'
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 2 second(s))
9 error(s), 0 warning(s) (0 minute(s), 2 second(s))


With: #include "wx/regex.h" and
wxRegEx foo("Test");
commented it builds fine.

Code: Select all

-------------- Build: Debug in db_Connect_GUI (compiler: GNU GCC Compiler)---------------
g++ -I/usr/lib/x86_64-linux-gnu/wx/include/gtk2-unicode-3.0 -I/usr/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -Wall -g -std=c++11 -I/usr/local/lib -c /home/stv/Documents/wxW_Projs/db_Connect_GUI/db_Connect_GUIMain.cpp -o obj/Debug/db_Connect_GUIMain.o
g++ -L/usr/local/lib -o bin/Debug/db_Connect_GUI obj/Debug/db_Connect_GUIApp.o obj/Debug/db_Connect_GUIMain.o  -L/usr/lib/x86_64-linux-gnu -pthread   -lwx_gtk2u_xrc-3.0 -lwx_gtk2u_html-3.0 -lwx_gtk2u_qa-3.0 -lwx_gtk2u_adv-3.0 -lwx_gtk2u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0  -lsqlite3 -lcurl  /usr/local/lib/libwxcode_gtk3u_wxsqlite3-3.0.a
Output file is bin/Debug/db_Connect_GUI with size 2.49 MB
Process terminated with status 0 (0 minute(s), 2 second(s))
0 error(s), 0 warning(s) (0 minute(s), 2 second(s))


There is something very wrong with the way I have this notebook setup.
I have built 20+ small test apps, including using wxSQLite3, create PDF reports, send email, and much more over that last couple months, in my other Linux mint desktop PC setup similarly.
I have never seen Anything to do with Regex.
Last edited by AshtonC1 on Mon Jun 12, 2017 9:24 pm, edited 1 time in total.

utelle
Moderator
Moderator
Posts: 756
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxsqlite3.cpp: Undefined reference to `wxRegEx::~wxRegEx()'- Linux

Postby utelle » Mon Jun 12, 2017 9:16 pm

If the symbol wxUSE_REGEX is defined for the wxWidgets library (which is usually the case), then wxSQLite3 provides a regular expression function implementation for use in SQL statements. However, this requires to add the wxregex* library to the list of link libraries. This is the case in the compile/link command given in original post. But AFAIK under Linux the order of link libraries matter. That is, the wxSQLite library should be specified first, and thereafter the libraries that are required to resolve all missing symbols from the wxWidgets libraries.

Regards,

Ulrich

AshtonC1
Earned some good credits
Earned some good credits
Posts: 100
Joined: Wed Feb 18, 2015 4:56 pm

Re: wxsqlite3.cpp: Undefined reference to `wxRegEx::~wxRegEx()'- Linux

Postby AshtonC1 » Mon Jun 12, 2017 9:18 pm

This is a clip from the ../configure results from wxSQLite3. But doesn't mention Regex.
    checking if g++ supports -c -o file.o... (cached) yes
    checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
    checking dynamic linker characteristics... (cached) GNU/Linux ld.so
    checking how to hardcode library paths into programs... immediate
    checking for wx-config... /usr/local/bin/wx-config
    checking for wxWidgets version >= 2.8.0... yes (version 3.0.3)
    checking for wxWidgets static library... yes
    checking for wx-config... (cached) /usr/local/bin/wx-config
    checking for wxWidgets version >= 2.8.0... yes (version 3.0.3)
    checking for wxWidgets static library... yes
    checking if wxWidgets was built with UNICODE enabled... yes
    checking if wxWidgets was built in DEBUG mode... no
    checking if wxWidgets was built in STATIC mode... yes
    checking which wxWidgets toolkit was selected... gtk3

AshtonC1
Earned some good credits
Earned some good credits
Posts: 100
Joined: Wed Feb 18, 2015 4:56 pm

Re: wxsqlite3.cpp: Undefined reference to `wxRegEx::~wxRegEx()'- Linux

Postby AshtonC1 » Mon Jun 12, 2017 9:37 pm

Thanks Ulrich,
Adding the /usr/include/lib/libwxregexu-3.0.a to the link libraries resolved the problem with the simple regex compile test.

Code: Select all

#include "wx/regex.h"
wxRegEx foo("Test");


The test db app is still displaying this after Adding the /usr/include/lib/libwxregexu-3.0.a to the link libraries,

Code: Select all

-------------- Build: Debug in db_Connect_GUI (compiler: GNU GCC Compiler)---------------
g++ -I/usr/lib/x86_64-linux-gnu/wx/include/gtk2-unicode-3.0 -I/usr/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -Wall -g -std=c++11 -I/usr/local/lib -c /home/stv/Documents/wxW_Projs/db_Connect_GUI/db_Connect_GUIMain.cpp -o obj/Debug/db_Connect_GUIMain.o
g++ -L/usr/local/lib -o bin/Debug/db_Connect_GUI obj/Debug/db_Connect_GUIApp.o obj/Debug/db_Connect_GUIMain.o  -L/usr/lib/x86_64-linux-gnu -pthread   -lwx_gtk2u_xrc-3.0 -lwx_gtk2u_html-3.0 -lwx_gtk2u_qa-3.0 -lwx_gtk2u_adv-3.0 -lwx_gtk2u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0  -lsqlite3 -lcurl  /usr/local/lib/libwxcode_gtk3u_wxsqlite3-3.0.a /usr/local/lib/libwxregexu-3.0.a
/usr/bin/ld: /usr/local/lib/libwxcode_gtk3u_wxsqlite3-3.0.a(wxsqlite3.o): undefined reference to symbol '_ZNK7wxRegEx7MatchesERK8wxStringi@@WXU_3.0'
//usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 1 second(s))
2 error(s), 0 warning(s) (0 minute(s), 1 second(s))
Last edited by AshtonC1 on Mon Jun 12, 2017 10:10 pm, edited 1 time in total.

utelle
Moderator
Moderator
Posts: 756
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxsqlite3.cpp: Undefined reference to `wxRegEx::~wxRegEx()'- Linux

Postby utelle » Mon Jun 12, 2017 10:00 pm

Without seeing the full command line including the order of link libraries it is hard to tell why linking still throws this error. But most probably the order of link libraries is still not correct.

Regards,

Ulrich

DavidHart
Site Admin
Site Admin
Posts: 3615
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: wxsqlite3.cpp: Undefined reference to `wxRegEx::~wxRegEx()'- Linux

Postby DavidHart » Mon Jun 12, 2017 10:08 pm

Adding the /usr/include/lib/libwxregexu-3.0.a to the link libraries resolved the problem with the simple regex compile test.

But why wasn't it there already? Aren't you calling wx-config to get the libs?

Even in an IDE like C::B, you should have in your linker options something like:
$(shell wx-config --libs)
That's the CodeLite syntax, so it might be different for you.

The compiler options should similarly call wx-config --cxxflags.

The advantage: you are protected against this sort of situation, where a change in wx renders your settings stale.
The drawback: if you have more than one wx build on your system, you need to do something to choose the correct one. The easiest way in an IDE is to use e.g. $(shell /full/path/to/that/wx-config --libs)

AshtonC1
Earned some good credits
Earned some good credits
Posts: 100
Joined: Wed Feb 18, 2015 4:56 pm

Re: wxsqlite3.cpp: Undefined reference to `wxRegEx::~wxRegEx()'- Linux

Postby AshtonC1 » Mon Jun 12, 2017 10:33 pm

** Last build log (above) updated to show all all commands **

I do have `wx-config --libs` under other linker options.
`wx-config --cflags` for other compiler options.

Checking on the number of wx builds on my system....
I have one wx-config located in /usr/local/bin.


Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 1 guest