Custom Static Library Issue Topic is solved

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
sam_des
Earned a small fee
Earned a small fee
Posts: 18
Joined: Wed Aug 30, 2017 4:55 am

Custom Static Library Issue

Post by sam_des »

Hello,

I have WX application which compiles/runs good. Now I need a static Library of all my Custom Components which again I was able to generate using CodeBlocks. When I try to link this static lib with my application, I get linker complaining about of wxHtmlEasyPrinitng class references,

Code: Select all

||=== Build: Release in eT_AE_DL2_v100 (compiler: GNU GCC Compiler) ===|
support\libeTLib.a(printing.o):printing.cpp|| undefined reference to `wxHtmlEasyPrinting::wxHtmlEasyPrinting(wxString const&, wxWindow*)'|
support\libeTLib.a(printing.o):printing.cpp|| undefined reference to `wxHtmlEasyPrinting::SetStandardFonts(int, wxString const&, wxString const&)'|
support\libeTLib.a(printing.o):printing.cpp|| undefined reference to `wxHtmlEasyPrinting::SetHeader(wxString const&, int)'|
support\libeTLib.a(printing.o):printing.cpp|| undefined reference to `wxHtmlEasyPrinting::SetFooter(wxString const&, int)'|
support\libeTLib.a(printing.o):printing.cpp|| undefined reference to `wxHtmlEasyPrinting::PreviewFile(wxString const&)'|
support\libeTLib.a(printing.o):printing.cpp|| undefined reference to `wxHtmlEasyPrinting::PrintFile(wxString const&)'|
support\libeTLib.a(printing.o):printing.cpp|| undefined reference to `wxHtmlEasyPrinting::PageSetup()'|
||error: ld returned 1 exit status|
||=== Build failed: 8 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
There are no issues with other WX classes. If I include the actual "printing.cpp", app links/runs fine. I checked the static lib & it indeed has "printing.o", generated from exact same "printing.cpp".

Do I need to need add something else while generating my static lib to resolve the wxHtmlEasyPrinting refs issue?

My setup is,
wxWidgets : 3.0.3 static linking
CodeBlocks : 16.01
Windows : 7/10
mingw : 4.9.2

Thanks in advance.
sam_des
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 548
Joined: Fri Nov 03, 2006 2:00 pm

Re: Custom Static Library Issue

Post by stahta01 »

Remember the order of objects and libraries matter in MinGW GCC.

Post the link command and maybe the issue will be clear to someone on this board.

Tim S.
sam_des
Earned a small fee
Earned a small fee
Posts: 18
Joined: Wed Aug 30, 2017 4:55 am

Re: Custom Static Library Issue

Post by sam_des »

Hello,
Remember the order of objects and libraries matter in MinGW GCC.
Thanks a lot. Weird but including my library before WX libs solved the issue.

sam_des
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: Custom Static Library Issue

Post by eranon »

sam_des wrote:Weird but including my library before WX libs solved the issue.
Yes, as stahta01 stated, lib orders matters for GCC. GCC considers the libs from right to left (or from bottom to top talking about CodeBlocks GUI).

So, from top to bottom in C::B, you have to provide them like this:
3. Your libs
2. wxWidgets libs
1. System libs

Your libs depend on the wxWidgets ones which depend on the system ones.
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
Post Reply