Author Topic: Linux with wxwidgets gtk undefined reference  (Read 9563 times)

Offline mimosa

  • Single posting newcomer
  • *
  • Posts: 6
Linux with wxwidgets gtk undefined reference
« on: September 11, 2014, 04:09:20 am »
Hello!
wxWidgets version: 3.0.1 (when in a terminal and typing wx-config --version)
Codeblocks version: 13.12 64bit build Jan 27 2014 with wx2.8.12 (linux unicode) installed with ubuntu software center
Compiler: gnu gcc 4.8.2
platform/OS: Linux 64 bit Ubuntu 14.04.1 LTS (codename trusty)

I posted my question on wxwidgets forum (http://forums.wxwidgets.org/viewtopic.php?f=19&t=40042), but no solution were found and it was recommended I ask here.

here is how I configured & installed my own wxwidgets in a terminal, under a folder I created within te unzipped folder (I do have the libwxgtk3.0-dev package installed):
../configure --with-gtk=3 --enable-debug --enable-debug_info --enable-debug_gdb --with-opengl --enable-monolithic
(then followed by "make" and "make install")

I then go into the samples folder, and compile the calendar sample and it works fine. my wxwidgets 3.0.1 dynamic library seems to be OK.

I create a new project in codeblocks like this:
File->New->Projects
GUI type
wxWidgets project
I select "wxWidgets 3.0.x" in the wxWidgets version option
wxSmith for my preferred GUI builder
Frame based application type
GNU GCC compiler
Advanced options: Dynamic: YES, and I select Unicode YES
Create and use precompiled header: CHECKED

The wizard adds these automatically:
`wx-config --cflags`
`wx-config --libs`

I also tried to replace with this (same I think):
`wx-config --cxxflags`
`wx-config --libs`

there is a global variable "wx" defined within Code::Blocks and the "base" points to this:
/usr/include/wx-3.0

I get this message when I try to compile:
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.a(gtkshow.o)||undefined reference to symbol 'gdk_app_launch_context_set_screen'|

So it seems I can't compile a project with wxwidgets 3.0.1 in Code::Blocks. The wxwidgets forum suspect something is not done correctly in Code::Blocks, and thus I am stuck.

here is the output for `wx-config --cxxflags` from a console
-I/usr/local/lib/wx/include/gtk3-unicode-3.0 -I/usr/local/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread

and the output for `wx-config --libs`
-L/usr/local/lib -pthread   -lwx_gtk3u-3.0

what am I missing? Thank you!

Offline SteelRat

  • Multiple posting newcomer
  • *
  • Posts: 45
  • Stainless
Re: Linux with wxwidgets gtk undefined reference
« Reply #1 on: September 11, 2014, 09:57:02 am »
You have to add additional libs to wx-config command, something like this:
`wx-config --libs std aui propgrid`

Offline mimosa

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linux with wxwidgets gtk undefined reference
« Reply #2 on: September 11, 2014, 05:01:51 pm »
You have to add additional libs to wx-config command, something like this:
`wx-config --libs std aui propgrid`

I just did that and try to rebuild. Same error.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: Linux with wxwidgets gtk undefined reference
« Reply #3 on: September 11, 2014, 05:59:10 pm »
You have to add additional libs to wx-config command, something like this:
`wx-config --libs std aui propgrid`

I just did that and try to rebuild. Same error.

Did you exit out of CB and reenter it after making the changes?

If not, try doing so.

The CB Devs disagree whether exiting and restarting CB is needed for changes in back-ticks expressions.

Tim S.

C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline SteelRat

  • Multiple posting newcomer
  • *
  • Posts: 45
  • Stainless
Re: Linux with wxwidgets gtk undefined reference
« Reply #4 on: September 11, 2014, 07:47:38 pm »
I just noticed that undefined reference is not to wxWidgets.
Try it `pkg-config --libs gtk+-2.0`

Offline mimosa

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linux with wxwidgets gtk undefined reference
« Reply #5 on: September 12, 2014, 09:50:51 am »
1) I added `wx-config --libs std aui propgrid` and it didn't work
2) I restarted code::blocks (after adding `wx-config --libs std aui propgrid`) and it didn't work
3) I added `pkg-config --libs gtk+-2.0` and it didn't work
4) I restarted code::blocks (after adding `pkg-config --libs gtk+-2.0`) and it didn't work

still no solution. I cannot compile a project with wxwidgets 3.0.1 in codeblocks under linux 64. If it works for you, tell me what you do (in the compile, linker, C::B options, or if you had to install extra packages in your machine)

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Linux with wxwidgets gtk undefined reference
« Reply #6 on: September 12, 2014, 10:31:41 am »
The pkg-config-stuff is not needed, unless you use gtk2 libs yourself.
By the way, it should be gtk3, as you build your wx against it.

I just tested your wx-configuration with wx-trunk (about tone or twoweeks old) and the default wx-project, same settings as you used and there are no issues.
The only diference is, that it is wx3.1 and a local build below my home-folder without running make install, so I have to use the absolute path for wx-config.
And I do not have the global variable wx set, but it is not used at all, so this should not make any difference.

Fedora 20, 64 bit, g++ 4.8.3

Offline cacb

  • Lives here!
  • ****
  • Posts: 547
Re: Linux with wxwidgets gtk undefined reference
« Reply #7 on: September 12, 2014, 10:16:06 pm »
1) I added `wx-config --libs std aui propgrid` and it didn't work
2) I restarted code::blocks (after adding `wx-config --libs std aui propgrid`) and it didn't work
3) I added `pkg-config --libs gtk+-2.0` and it didn't work
4) I restarted code::blocks (after adding `pkg-config --libs gtk+-2.0`) and it didn't work

still no solution. I cannot compile a project with wxwidgets 3.0.1 in codeblocks under linux 64. If it works for you, tell me what you do (in the compile, linker, C::B options, or if you had to install extra packages in your machine)

I use static library build of wx 3.0.1 under linux Kubuntu 14.04 (and also raspbian). From a typical project file (console app project):

<Target title="GCC_Release">
   <Option output=".cmp/gcc/bin/Release/raspimeter" prefix_auto="1" extension_auto="1" />
   <Option object_output=".cmp/gcc/obj/Release/" />
   <Option type="1" />
   <Option compiler="gcc" />
   <Option projectLinkerOptionsRelation="2" />
   <Compiler>
      <Add option="-Os" />
      <Add option="-std=c++0x" />
      <Add option="-W" />
      <Add option="-fPIC" />
      <Add option="-fexceptions" />
      <Add option="`$(#wx.config) --cxxflags`" />
      <Add option="-DNOPCH" />
   </Compiler>
   <Linker>
      <Add option="`$(#wx.config) --libs std,aui --static`" />
   </Linker>
</Target>


'wx' is a C::B global variable with a user defined field 'config'.

wx.base = /usr/local
wx.config = /usr/local/bin/wx-config  --version=3.0  --toolkit=gtk2

This works fine here.

« Last Edit: September 12, 2014, 10:21:48 pm by cacb »

Offline mimosa

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linux with wxwidgets gtk undefined reference
« Reply #8 on: September 13, 2014, 04:14:19 am »
OK, I have something interesting. I deleted ~/.codeblocks/default.conf and restarted C::B and it's all good. (if you do this, you should delete the ~/.codeblocks/default.conf from you as a user, and/or as root depending from which user you launch C::B, I just deleted both the ~/.codeblocks/default.conf from me as user and from the root).

Good, now I am back into coding! Great! Thanks a lot guys!