Linking errors in release mode

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
Pier Simon Tilma
In need of some credit
In need of some credit
Posts: 5
Joined: Tue Mar 10, 2020 4:52 pm

Linking errors in release mode

Post by Pier Simon Tilma » Tue Mar 10, 2020 5:30 pm

Anjum, 10 march 2020

Hello,

Recently I switched from Windows to Ubuntu. On Ubuntu I compiled the wxWidgets libraries
and all went well (shared debug and shared no debug). Compiling, linking and running my application in debug
mode goes well, but in release mode during linking I get a lot of the following type of errors :
alarmAssignmentFrame.cpp:(.text+0x1172): undefined reference to `wxTrapInAssert'
alarmAssignmentFrame.cpp:(.text+0x117b): undefined reference to `wxTrapInAssert'
alarmAssignmentFrame.cpp:(.text+0x13d0): undefined reference to `wxTheAssertHandler'
alarmAssignmentFrame.cpp:(.text+0x13f9): undefined reference to `wxOnAssert(char const*, int, char const*, char const*, char const*)'
What is going on ?

System : Ubuntu 18.04.1, wxWidgets 3.1.3, gcc 7.4.0

Kind regards
Pier Tilma
The Netherlands

User avatar
doublemax
Moderator
Moderator
Posts: 14889
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Linking errors in release mode

Post by doublemax » Tue Mar 10, 2020 7:34 pm

These methods are only available in debug mode. You must be linking to at least one library just was built in debug mode.

Cam you build the "minimal" sample that comes with wxWidgets in release mode?
Use the source, Luke!

Pier Simon Tilma
In need of some credit
In need of some credit
Posts: 5
Joined: Tue Mar 10, 2020 4:52 pm

Re: Linking errors in release mode

Post by Pier Simon Tilma » Wed Mar 11, 2020 9:31 am

Anjum, 11 march 2020

Hello,

I did try the minimal example. It gives exactly the same problem.

This is what I did :
Created a project "minimal" in CodeBlocks.
Copied the files minimal.cpp and sample.xpm (from wxWidgets-3.1.3) to
that codeBlocks project directory.
In Debug mode compiling, linking and running goes well.
In Release mode linking gives again the "assert" errors.
minimal.cpp:(.text._ZN20wxEventFunctorMethodI14wxEventTypeTagI14wxCommandEvent
E12wxEvtHandler7wxEventS3_EclEPS3_RS4_[_ZN20wxEventFunctorMethodI14wxEventType
TagI14wxCommandEventE12wxEvtHandler7wxEventS3_EclEPS3_RS4_]+0x3b):
undefined reference to `wxTheAssertHandler'
System : Ubuntu 18.04.1, wxWidgets 3.1.3, gcc 7.4.0, CodeBlocks 17.12

Kind regards from
Pier Tilma
The Netherlands

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2434
Joined: Sun Jan 03, 2010 5:45 pm

Re: Linking errors in release mode

Post by PB » Wed Mar 11, 2020 11:54 am

I do not use Linux but afaik there are no separate debug and release wxWidgets libraries there.

IIRC, I got this error on MSW where I had defined different (lower) value for wxDEBUG_LEVEL and wxDEBUG_FLAG when building wxWidgets than when building my application.

User avatar
doublemax
Moderator
Moderator
Posts: 14889
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Linking errors in release mode

Post by doublemax » Wed Mar 11, 2020 1:47 pm

I did try the minimal example. It gives exactly the same problem.
Try to build the "minimal" sample that comes with wxWidgets with the provided make files from the command line, not in CB.
Use the source, Luke!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4170
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Linking errors in release mode

Post by ONEEYEMAN » Wed Mar 11, 2020 2:12 pm

Hi,
Did you use different directories when building debug and release libraries?

Thank you.

Pier Simon Tilma
In need of some credit
In need of some credit
Posts: 5
Joined: Tue Mar 10, 2020 4:52 pm

Re: Linking errors in release mode

Post by Pier Simon Tilma » Wed Mar 11, 2020 2:59 pm

Anjum, 11 march 2020
Did you use different directories when building debug and release libraries?
Yes I did.

Pier Simon Tilma
The Netherlands

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4170
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Linking errors in release mode

Post by ONEEYEMAN » Wed Mar 11, 2020 3:01 pm

Hi,
And you did use appropriate directory when building yuor program in Release mode?

Thank you.

Pier Simon Tilma
In need of some credit
In need of some credit
Posts: 5
Joined: Tue Mar 10, 2020 4:52 pm

Re: Linking errors in release mode

Post by Pier Simon Tilma » Wed Mar 11, 2020 3:08 pm

Anjum, 11 march 2020

I just found out :
When I link my release application with the "debug shared libraries"
instead of the "no debug shared libraries" than everything works well.

For the time being I can live with that. But the question remains.
Why is linking with the "no debug shared libraries" giving wxAssert
errors.

System : Ubuntu 18.04.1, wxWidgets 3.1.3, gcc 7.4.0, CodeBlocks 17.12

Pier Simon Tilma
The Netherlands

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4170
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Linking errors in release mode

Post by ONEEYEMAN » Wed Mar 11, 2020 4:51 pm

Hi,
I think you make it vice versa.
Also, keep in mind that in Linux there is no difference between "Debug" and "Release" libraries. They both use the same CRT.

Thank you.

Pier Simon Tilma
In need of some credit
In need of some credit
Posts: 5
Joined: Tue Mar 10, 2020 4:52 pm

Re: Linking errors in release mode

Post by Pier Simon Tilma » Thu Mar 12, 2020 7:03 pm

Anjum, march 12th 2020

Hello everybody,
Try to build the "minimal" sample that comes with wxWidgets
with the provided make files from the command line, not in CB.
And that is what I did. The compilation, linking and running of the samples
are working without problems. During compilation I noticed -DwxDEBUG_LEVEL=0.
So I entered this into my codeBlocks environment (release->compiler settings->tab #defines).
Now the linking goes well and I can run the executable.

The wxDEBUG_LEVEL define was already mentioned earlier in one of the posts but
probably I gave it too little attention.

Everybody thanks for your help.

Kind regards
Pier Simon Tilma
The Netherlands.

Post Reply