Undefined Reference in Static Library

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
vanerio
In need of some credit
In need of some credit
Posts: 4
Joined: Thu Sep 20, 2018 12:51 pm

Undefined Reference in Static Library

Post by vanerio »

Windows 8 + Code::Blocks v17.12 + MinGW

Hi!
I have been trying to make wxWidgets Static work in Code::Blocks, but I really need your help as I have wasted so many hours trying to solve it by myself and I could not find a solution :oops:

I have compiled wxWidgets so many times, MONOLITHIC=0, MONOLITHIC=1, just Debug, just Release, Both, first Static, first Dynamic, etc....................
And I could not make it work :(
And I didn´t have any compiling errors!

So, my results (when compiling apps in Code::Blocks) are:

Dynamic Library: It´works perfectly fine. It works well in Code::Blocks and the code compiles as expected.

Static Library: It does never work. Here you are just some of the errors when building the app:
C:\wxWidgets-3.1.1\lib\gcc_lib\libwxmsw31u_core.a(corelib_window.o):window.cpp|| undefined reference to `OpenThemeData@8'|

C:\wxWidgets-3.1.1\lib\gcc_lib\libwxmsw31u_core.a(corelib_menuitem.o):menuitem.cpp|| undefined reference to `OpenThemeData@8'|

C:\wxWidgets-3.1.1\lib\gcc_lib\libwxmsw31u_core.a(corelib_msw_statbox.o):statbox.cpp|| undefined reference to `OpenThemeData@8'|

C:\wxWidgets-3.1.1\lib\gcc_lib\libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp|| undefined reference to `jpeg_resync_to_restart'|

C:\wxWidgets-3.1.1\lib\gcc_lib\libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp|| undefined reference to `TIFFClientOpen'|

C:\wxWidgets-3.1.1\lib\gcc_lib\libwxmsw31u_core.a(corelib_renderer.o):renderer.cpp|| undefined reference to `OpenThemeData@8'|

C:\wxWidgets-3.1.1\lib\gcc_lib\libwxmsw31u_core.a(corelib_uxtheme.o):uxtheme.cpp|| undefined reference to `IsAppThemed@0'|

C:\wxWidgets-3.1.1\lib\gcc_lib\libwxmsw31u_core.a(corelib_msw_anybutton.o):anybutton.cpp|| undefined reference to `OpenThemeData@8'|

C:\wxWidgets-3.1.1\lib\gcc_lib\libwxmsw31u_core.a(corelib_combo.o):combo.cpp|| undefined reference to `OpenThemeData@8'|

C:\wxWidgets-3.1.1\lib\gcc_lib\libwxmsw31u_core.a(corelib_msw_notebook.o):notebook.cpp|| undefined reference to `OpenThemeData@8'|

C:\wxWidgets-3.1.1\lib\gcc_lib\libwxmsw31u_core.a(corelib_access.o):access.cpp|| undefined reference to `CreateStdAccessibleObject@16'|

C:\wxWidgets-3.1.1\lib\gcc_lib\libwxmsw31u_core.a(corelib_systhemectrl.o):systhemectrl.cpp|| undefined reference to `SetWindowTheme@12'|
I am so sorry if this is too obvious. It is the first time I am dealing with C++ and programming outside Visual Studio and I really tried to solve it by myself, but not even google could help me.

Thank you very much!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Undefined Reference in Static Library

Post by PB »

You need to add the missing windows libraries, see e.g. here
viewtopic.php?f=19&t=44529&p=183882#p183898
vanerio
In need of some credit
In need of some credit
Posts: 4
Joined: Thu Sep 20, 2018 12:51 pm

Re: Undefined Reference in Static Library

Post by vanerio »

PB wrote:You need to add the missing windows libraries, see e.g. here
viewtopic.php?f=19&t=44529&p=183882#p183898
Unfortunately I can´t make it work yet.

I tried both:
1.Adding libuxtheme.a and liboleacc.a to Linker Settings
2.Adding libuxtheme.a and liboleacc.a to Linker Settings and copying these files to wxWidgets lib/gcc_lib folder.

Thank you!
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Undefined Reference in Static Library

Post by doublemax »

At the very least you should have seen fewer errors. Did you or did you get the same ones as before?
copying these files to wxWidgets lib/gcc_lib folder.
That should not be necessary and usually does more harm than good. Reverse it.
Use the source, Luke!
vanerio
In need of some credit
In need of some credit
Posts: 4
Joined: Thu Sep 20, 2018 12:51 pm

Re: Undefined Reference in Static Library

Post by vanerio »

doublemax wrote:At the very least you should have seen fewer errors. Did you or did you get the same ones as before?
copying these files to wxWidgets lib/gcc_lib folder.
That should not be necessary and usually does more harm than good. Reverse it.
Ok! Done!
But just adding both libuxtheme.a and liboleacc.a does not work anyway
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Undefined Reference in Static Library

Post by ONEEYEMAN »

Hi,
So what happen?
Did you get errors? Or you can't run the executable?

Thank you.
vanerio
In need of some credit
In need of some credit
Posts: 4
Joined: Thu Sep 20, 2018 12:51 pm

Re: Undefined Reference in Static Library

Post by vanerio »

Dear friends:
I finally solved the issue.

After adding both libuxtheme.a and liboleacc.a , I was getting Undefined Reference with Jpg and Tiff.
So the final step was to add: wxJpeg and also wxTiff in the wxWidgets Project Wizard.

So now, please let me ask something else:
1. Was this issue due to me making something wrong? And I ask that because I supposed that it should be added everything by default when creating a new app trough Project Wizard.
2. Is there a way (apart from saving a default project) to make this changes permanent? I mean when creating a new project trough Project Wizard.
3. Is it normal that these errors appear only when using the static library and not the dynamic one?

Thank you very much! :D
tigerbeard
Earned some good credits
Earned some good credits
Posts: 123
Joined: Sat Oct 07, 2006 1:56 pm

Re: Undefined Reference in Static Library

Post by tigerbeard »

When I do not misunderstand you you are talking about how to setup wxWidget project with CodeBlock in the future?

Generally you might want to check out the CodeBlock forum for issuses around CB Porjects with wxWidgets.
I tend to setup my compiler seetings to include the wxWIdgets library and standard build targets Release and Debug, but also Release DLL, ReleaseMonolithic etc. I am using C::B environment variables to set the path to the wxWidget libs, which safes a lot of typing in the compiler setting dialogs. The big advantage is that after having done that once, you can forget about all that and just concentrate on your code.
No matter what project, the wxLibs are already there, just just need to add other libs.

The best ist that the setup ist stored in your profile. When moving to a new machine, just copy your profile to the new machine and you can just keep going.

Dawbacks: you need to repeat it for version changes of wxWidgets and need to have a special setup when you want to produce minimal sized code, i.e. do not link in unnecessary librs. That can be solved, but I found its rare and I needed it only for a few project which got an own setup.


Hope it helps.

Edit: I often ran into problems, becuase the order of libs was not correct. If you have strange problems, might be worth to play around with that.
System config: Xubuntu22.04, wxWidgets 3.0.5,gcc, C::B
Post Reply