GCC update - linking problems! 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.
Ilya333
Earned some good credits
Earned some good credits
Posts: 136
Joined: Sun Jan 11, 2015 3:30 pm

GCC update - linking problems!

Post by Ilya333 » Fri May 22, 2015 9:01 am

Hello everyone,
Having some troubles after GCC update on Linux... GCC 5 shows lots of warnings inside wxWidgets library (-Wdeprecated-declarations - about 151 (!)).
But the problem is that when I launch the application, it says:
Fatal Error: Mismatch between the program and library build versions detected.
The library used 3.0 (wchar_t,compiler with C++ ABI 1002,wx containers,compatible with 2.8),
and your program used 3.0 (wchar_t,compiler with C++ ABI 1008,wx containers,compatible with 2.8).
Emergency stop (memory dump).
I use the version from the default Ubuntu repository (3.0.2).
Before the GCC update, everyrhing worked fine.
How can I solve it?

Ilya333
Earned some good credits
Earned some good credits
Posts: 136
Joined: Sun Jan 11, 2015 3:30 pm

Re: GCC update - linking problems!

Post by Ilya333 » Fri May 22, 2015 10:10 am

GCC version data:

Code: Select all

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.1.1-4ubuntu12' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=c++11 --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.1.1 20150504 (Ubuntu 5.1.1-4ubuntu12) 

catalin
Moderator
Moderator
Posts: 1594
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: GCC update - linking problems!

Post by catalin » Fri May 22, 2015 10:25 am

I guess the choices are 1) revert to the old GCC; 2) build wxW libs yourself with the new GCC.

Ilya333
Earned some good credits
Earned some good credits
Posts: 136
Joined: Sun Jan 11, 2015 3:30 pm

Re: GCC update - linking problems!

Post by Ilya333 » Fri May 22, 2015 4:54 pm

To compile wxWidgets on Linux, I need GTK+ 3.0 package. Installing it requires 1 GB to download and 4 GB of disk space after installation. Moreover, it will take lots of time to compile wxWidgets. So, I suppose the first option is better for me. How do I return to the old GCC?

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

Re: GCC update - linking problems!

Post by DavidHart » Fri May 22, 2015 5:36 pm

Hi,
compile wxWidgets on Linux, I need GTK+ 3.0 package
No you don't; not unless you particularly want gtk3. The normal dependency is libgtk2.0-dev.

wx3.0 can be built against either gtk2 or gtk3, gtk2 being the default. The current ubuntu wx3 package uses gtk2.

Regards,

David

Ilya333
Earned some good credits
Earned some good credits
Posts: 136
Joined: Sun Jan 11, 2015 3:30 pm

Re: GCC update - linking problems!

Post by Ilya333 » Fri May 22, 2015 5:46 pm

I though so because of make's output. It failed to build wx, as it "didn't find the 'gtk+-3.0' package". Well, I'll try to build it again tomorrow.
But what about the majority of wxWidgets users? Will they have to stay on GCC-4.9?

Ilya333
Earned some good credits
Earned some good credits
Posts: 136
Joined: Sun Jan 11, 2015 3:30 pm

Re: GCC update - linking problems!

Post by Ilya333 » Sat May 23, 2015 7:56 am

No, this output was provided by ./configure, not by make... Anyway, here it is:

Code: Select all

< .... >
checking for GTK+ - version >= 2.6.0... Package gtk+-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-2.0' found
Package gthread-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gthread-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gthread-2.0' found
no
*** Could not run GTK+ test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occurred. This usually means GTK+ is incorrectly installed.
checking for pkg-config... (cached) /usr/bin/pkg-config
checking for GTK+ - version >= 3.0.0... Package gtk+-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-3.0' found
Package gthread-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gthread-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gthread-2.0' found
no
*** Could not run GTK+ test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means GTK+ is incorrectly installed.
checking for gtk-config... no
checking for GTK - version >= 1.2.7... no
*** The gtk-config script installed by GTK could not be found
*** If GTK was installed in PREFIX, make sure PREFIX/bin is in
*** your path, or set the GTK_CONFIG environment variable to the
*** full path to gtk-config.
checking for gtk-config... (cached) no
checking for GTK - version >= 1.2.3... no
*** The gtk-config script installed by GTK could not be found
*** If GTK was installed in PREFIX, make sure PREFIX/bin is in
*** your path, or set the GTK_CONFIG environment variable to the
*** full path to gtk-config.
configure: error: 
The development files for GTK+ were not found. For GTK+ 2, please
ensure that pkg-config is in the path and that gtk+-2.0.pc is
installed. For GTK+ 1.2 please check that gtk-config is in the path,
and that the version is 1.2.3 or above. Also check that the
libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
--libs' are in the LD_LIBRARY_PATH or equivalent.

Ilya333
Earned some good credits
Earned some good credits
Posts: 136
Joined: Sun Jan 11, 2015 3:30 pm

Re: GCC update - linking problems!

Post by Ilya333 » Sat May 23, 2015 8:00 am

Installed libgtk2.0-dev - success! :D

Ilya333
Earned some good credits
Earned some good credits
Posts: 136
Joined: Sun Jan 11, 2015 3:30 pm

Re: GCC update - linking problems!

Post by Ilya333 » Sat May 23, 2015 6:10 pm

Well, I've run 'sudo make install', and it says:

Code: Select all

The installation of wxWidgets is finished. On certain
platforms (e.g. Linux) you'll now have to run ldconfig
if you installed a shared library and also modify the
LD_LIBRARY_PATH (or equivalent) environment variable.
What should I execute? How to modify this variable?
P.S. And do I need to remove the binary installation from Ubuntu repo?

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

Re: GCC update - linking problems!

Post by DavidHart » Sat May 23, 2015 9:16 pm

Doing:
sudo ldconfig
will certainly do no harm.

If you did a standard: ./configure
without providing a --prefix=<somewhere else> option, you will now have two wx installations:
  • 1) The original package one in /usr/
    2) The new one in /usr/local/
See what the output is of doing, in a terminal: wx-config --libs
If that gives the /usr/local/ version, you're probably OK. If not, you need to do something, which could be one or more of:
  • 1) Remove the package version if you're sure you (and other packages) don't need it.
    2) Select the new wx install using update-alternatives, if that has picked it up.
    3) To make a built wx app locate the wx libs, do: export LD_LIBRARY_PATH=/usr/local
    in the terminal each time you open one, or put it in your .bashrc
    4) Similarly when building a wx app in a terminal you can start with: export PATH=/usr/local/bin:$PATH
    5) Point directly to the correct wx-config in the settings of any IDE you use.

Ilya333
Earned some good credits
Earned some good credits
Posts: 136
Joined: Sun Jan 11, 2015 3:30 pm

Re: GCC update - linking problems!

Post by Ilya333 » Sun May 24, 2015 10:51 am

Everything now works fine; my application crashed on launch in Code::Blocks, and I had to replace 'wx-config --libs' with '/usr/local/bin/wx-config --libs' to make it work.
But again, I wonder what the majority of programmers are going to do? Will the wx libs be rebuilt in order to suit GCC 5.1.1? Or will people have to continue using older versions of GCC?

Ilya333
Earned some good credits
Earned some good credits
Posts: 136
Joined: Sun Jan 11, 2015 3:30 pm

Re: GCC update - linking problems!

Post by Ilya333 » Sun May 24, 2015 12:57 pm

Another project which used wxWidgets now has following issues:

Code: Select all

In function `EyeCareDialog::OnTimer(wxTimerEvent&)':
EyeCareMain.cpp:(.text+0x362): undefined reference to `vtable for wxNotificationMessage'
EyeCareMain.cpp:(.text+0x38a): undefined reference to `wxNotificationMessage::Show(int)'
EyeCareMain.cpp:(.text+0x396): undefined reference to `wxNotificationMessage::~wxNotificationMessage()'
EyeCareMain.cpp:(.text+0x535): undefined reference to `wxNotificationMessage::~wxNotificationMessage()'
collect2: error: ld returned 1 exit status
How to solve it?

UPD. Solved. Replace `wx-config --cflags` with `/usr/local/bin/wx-config --cflags` in Project->Build options->Compiler settings->Other options of Code::Blocks IDE.

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

Re: GCC update - linking problems!

Post by DavidHart » Sun May 24, 2015 1:05 pm

Most Linux users won't have heard of gcc, so they won't experience your problems. They'll carry on doing what they've done for years: use their distro packages which (barring accidents) have been shown to work with the supplied toolchain.

People like you want to upgrade to the latest-and-greatest things, in this case gcc, and will need to solve the ensuing problems.

I suspect most programmers will be between those extremes, but will only upgrade their toolchain if they have a particular need. Certainly I've never installed a non-package or non-official gcc.

Ilya333
Earned some good credits
Earned some good credits
Posts: 136
Joined: Sun Jan 11, 2015 3:30 pm

Re: GCC update - linking problems!

Post by Ilya333 » Mon May 25, 2015 9:36 am

Well, I haven't upgraded the GCC manually, it was updated automatically, so, I assume it's now the default on Ubuntu. I've got Ubuntu Vivid Vervet 15.04.

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

Re: GCC update - linking problems!

Post by DavidHart » Mon May 25, 2015 10:03 am

Well, I haven't upgraded the GCC manually, it was updated automatically, so, I assume it's now the default on Ubuntu. I've got Ubuntu Vivid Vervet 15.04.
Ah, I see. We'd both assumed that you had upgraded gcc yourself.

I have a vivid install, and have used the official wx packages to build programs without any problem. Mine is a fresh install in a clean partition. Is yours the same, or did you upgrade from an earlier ubuntu version? Also, the gcc that was installed is 4.9.2, though there's a gcc-5-base package installed too. What does synaptic (or whatever) say about your installation?

Could you describe more about what your original problem was. Were you building a program yourself? If so, was it a new project, or a rebuild of an old one? If the latter, there may have been some stale .o files that caused the problem.

Post Reply