Odd linkage error

General questions regarding the usage of CodeLite
wittend
CodeLite Enthusiast
Posts: 44
Joined: Thu Oct 09, 2008 9:11 pm
Contact:

Odd linkage error

Post by wittend »

I have been developing a small WX gui program on Linux. I have encountered a problem that may or may not be related to Codelite's build behavior.
For a variety of reasons I have been using the following environment:

Linux Mint 18.3 (with Ubuntu 14.04)
Codelite 9.1.0
WxWidgets 3.1.1 from git

The program is unremarkable and I have been sticking to well-known controls, the fanciest probably being wxAUINotebook. This has gone well.
The wxWidgets I have been using was built using:

Code: Select all

../configure --enable-monolithic --with-opengl --enable-webview
I realized that I needed a compact build of my program to transfer to another machine where I could not build the version of the libraries, so I decided to rebuild them and link to them statically.
I used:

Code: Select all

../configure --enable-unicode --with-opengl --disable-shared  --enable-webview --enable-monolithic
When I rebuilt my program against these libraries, I got a linker error:
...
/usr/bin/ld: /usr/local/lib/libwx_gtk2u-3.1.a(monolib_xml.o): undefined reference to symbol 'XML_SetUserData'
...
I tried linking with expat without success, and searched the Web for similar situations. Most of these I found implied linking order errors building with wx2.7, 2.8, or 3.0 as in this solution:
Adding -v -Wl,-v to the flags allowed me to see the command lines for collect2 and ld.
For some reason, the original Makefile was putting the libraries (-L and -l options) before most of the object files. I put the libraries at the end of the command line and now it compiles.
I did not want to edit the Makefile at this stage, so I thought that I would try building static, but not monolithic:
I used:

Code: Select all

../configure --enable-unicode --with-opengl --disable-shared  --enable-webview
When I built against the resulting libs, I found that I needed an explicit link to wx_gtk2u_aui-3.1.a, but once that was added everything worked nicely.
Is combining --disable-shared and --enable-monolithic known not to work? Or are there other non-wx libraries that I should have added?

Thanks,
Dave
DavidGH
CodeLite Plugin
Posts: 819
Joined: Wed Sep 03, 2008 7:26 pm
Contact:

Re: Odd linkage error

Post by DavidGH »

Hi,
Is combining --disable-shared and --enable-monolithic known not to work?
It's more a matter of --enable-monolithic being used very rarely on Linux. There's seldom a reason to build static libs anyway, and when it is done it's usually not monolithic. Seldom used means seldom tested.

Recent distro versions have turned on the ld --as-needed flag so, as you found, the makefile must put .o files before the libs.
What was happening in the failing CodeLite makefile? Did it get the order wrong? If so, it's a (minor) CodeLite bug. If not, it's not our fault ;) .

Regards,

David
wittend
CodeLite Enthusiast
Posts: 44
Joined: Thu Oct 09, 2008 9:11 pm
Contact:

Re: Odd linkage error

Post by wittend »

Thanks for the reply. Since I found a setting that works, I have lost my build logs for the for the offending instance. I was pretty well convinced that it was the ordering of the build at the time, but I won't swear to it. I didn't know about the --as-needed flag. Perhaps I can get back to it when I'm less pressed for time.

I like to use static builds so that I can test the development releases before end users encounter them. Dynamic builds of multiple versions of lib code creates clutter at best, and requires me to install (and usually scratch-build) on every platform where I do a provisional test. Monolithic is even tidier on the build machine, but mostly I spec'd it because I thought Erfan used to use it. Perhaps I'm wrong about that, or perhaps that was just in Windows.

Anyway, thanks!

Dave
Post Reply