Author Topic: wx project compile/link - behind the scenes activity  (Read 3593 times)

Offline sorinev

  • Multiple posting newcomer
  • *
  • Posts: 61
wx project compile/link - behind the scenes activity
« on: June 20, 2015, 06:53:17 am »
I rolled my own makefile for a wx project that I have as a part of my efforts to become familiar with the make system and command line compiling and so forth. I'm seeing some differences between the options being posted to the log (c::b) / console (my make) and in the resulting GUI of the app itself. I don't see any significant differences to my untrained eye in the command line being used (in the case of my make) and the options in codeblocks for the project. So I'm wondering what goes on with wx projects behind the scenes as far as command line goes that isn't seen in the project or ide options.

This is on Kubuntu 14.04, so global variables in C::B don't come into play like they would on Windows.

Here is my make file.

Code
CC := g++
EXE := wxDFedit
EXE_DIR := bin/
EXE_PATH := $(EXE_DIR)$(EXE)
OBJ_LIST = DFTab.o GeneralsTab.o wxDFeditApp.o wxDFeditMain.o
OBJ_DIR := obj/
OBJS = $(foreach obj,$(OBJ_LIST), $(OBJ_DIR)$(obj))
LIBS = $(shell wx-config --libs base, core, aui)
CXXFLAGS = -Wall -O2 -s $(shell wx-config --cflags)

build: $(EXE_PATH)

$(EXE_PATH): $(OBJS)
        $(CC) -s -o $@ $^ $(LIBS)

$(OBJ_DIR)%.o: interface/%.cpp
        $(CC) $(CXXFLAGS) -c $< -o $@

clean:
        -rm -f $(OBJS) $(EXE_PATH)

rebuild: clean build

which results in the following:

Code
g++ -Wall -O2 -s -I/usr/lib/x86_64-linux-gnu/wx/include/gtk2-unicode-3.0 -I/usr/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -c interface/DFTab.cpp -o obj/DFTab.o
g++ -Wall -O2 -s -I/usr/lib/x86_64-linux-gnu/wx/include/gtk2-unicode-3.0 -I/usr/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -c interface/GeneralsTab.cpp -o obj/GeneralsTab.o
g++ -Wall -O2 -s -I/usr/lib/x86_64-linux-gnu/wx/include/gtk2-unicode-3.0 -I/usr/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -c interface/wxDFeditApp.cpp -o obj/wxDFeditApp.o
g++ -Wall -O2 -s -I/usr/lib/x86_64-linux-gnu/wx/include/gtk2-unicode-3.0 -I/usr/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -c interface/wxDFeditMain.cpp -o obj/wxDFeditMain.o
g++ -s -o bin/wxDFedit obj/DFTab.o obj/GeneralsTab.o obj/wxDFeditApp.o obj/wxDFeditMain.o -L/usr/lib/x86_64-linux-gnu -pthread   -lwx_baseu-3.0 -lwx_gtk2u_core-3.0 -lwx_gtk2u_aui-3.0

The options relevant to wxWidgets in Code::Blocks for the project are:

Code
`wx-config --cflags`
Code
`wx-config --libs`

aside from general compiler options you'll see in the output below:

Code
++ -Wall -O2 -I/opt/wx/3.0_unicode_monolithic_shared/lib/wx/include/gtk3-unicode-3.0 -I/opt/wx/3.0_unicode_monolithic_shared/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -O2 -Wextra -Wall -std=c++11  -c ~/Code/wxWidgets/dfedit-wx/interface/DFTab.cpp -o obj/Release/interface/DFTab.o
g++ -Wall -O2 -I/opt/wx/3.0_unicode_monolithic_shared/lib/wx/include/gtk3-unicode-3.0 -I/opt/wx/3.0_unicode_monolithic_shared/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -O2 -Wextra -Wall -std=c++11  -c ~/Code/wxWidgets/dfedit-wx/interface/GeneralsTab.cpp -o obj/Release/interface/GeneralsTab.o
g++ -Wall -O2 -I/opt/wx/3.0_unicode_monolithic_shared/lib/wx/include/gtk3-unicode-3.0 -I/opt/wx/3.0_unicode_monolithic_shared/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -O2 -Wextra -Wall -std=c++11  -c ~/Code/wxWidgets/dfedit-wx/interface/wxDFeditApp.cpp -o obj/Release/interface/wxDFeditApp.o
g++ -Wall -O2 -I/opt/wx/3.0_unicode_monolithic_shared/lib/wx/include/gtk3-unicode-3.0 -I/opt/wx/3.0_unicode_monolithic_shared/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -O2 -Wextra -Wall -std=c++11  -c ~/Code/wxWidgets/dfedit-wx/interface/wxDFeditMain.cpp -o obj/Release/interface/wxDFeditMain.o

g++  -o bin/Release/wxDFedit obj/Release/interface/DFTab.o obj/Release/interface/GeneralsTab.o obj/Release/interface/wxDFeditApp.o obj/Release/interface/wxDFeditMain.o  -s -L/opt/wx/3.0_unicode_monolithic_shared/lib -pthread   -lwx_gtk3u-3.0

Code::Blocks version is 119,976 bytes.
My version is 115,880 bytes.

What I'm not getting is just looking at the wx-config string that I can see in C::B and the one I've used in my make, they seem to be exactly the same (aside from having to add core, base, aui manually because it fails to link with just plain wx-config --libs alone). But, they are resulting in different application results. The sizes are different (no suprise given the compiling and linking is different), and the application is visually different. On my system, closeable tabs from wxWidgets apps such as C::B itself have a red circle with a white x. My make-d application has this same look. The C::B version has a rounded square outline with a black x. Also in both C::B and my make-d app, menu options with key accelerators are underlined, but in the C::B version of the app, they aren't.

I was assuming the wx-config options would get passed as-is to the compiler and linker, but, I guess something else is happening to result in different output?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: wx project compile/link - behind the scenes activity
« Reply #1 on: June 20, 2015, 11:19:32 am »
It seems that you're somehow calling two different versions of wx-config. One is gtk2 and the other is gtk3. Probably you are modifying the path variable somewhere in you cb settings (env var plugin?).
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline sorinev

  • Multiple posting newcomer
  • *
  • Posts: 61
Re: wx project compile/link - behind the scenes activity
« Reply #2 on: June 20, 2015, 07:18:08 pm »
Yeah, and I don't get how that's happening. I haven't modified anything like that explicitly on my own, no. It's a standard svn build (10333) with contrib-plugins=all. Beyond that, I haven't changed anything important, just some syntax highlighting colors and maybe a couple of compiler switches (as in, just checkboxes). Is there somewhere that this can be shown?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: wx project compile/link - behind the scenes activity
« Reply #3 on: June 20, 2015, 08:01:39 pm »
Yeah, and I don't get how that's happening. I haven't modified anything like that explicitly on my own, no. It's a standard svn build (10333) with contrib-plugins=all. Beyond that, I haven't changed anything important, just some syntax highlighting colors and maybe a couple of compiler switches (as in, just checkboxes). Is there somewhere that this can be shown?

On the command line.

What does this result in?
Code
which wx-config

And, what does this result in?

Code
wx-config --list

Edit: And, what does this result in?
Code
update-alternatives --config wx-config

Tim S.
« Last Edit: June 20, 2015, 08:04:02 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline sorinev

  • Multiple posting newcomer
  • *
  • Posts: 61
Re: wx project compile/link - behind the scenes activity
« Reply #4 on: June 20, 2015, 08:29:42 pm »
Code
me@Kubuntu-1404:~$ which wx-config
/opt/wx/3.0_unicode_monolithic_shared/bin/wx-config

me@Kubuntu-1404:~$ wx-config --list

    Default config is gtk2-unicode-3.0

  Default config will be used for output

  Alternate matches:
    base-unicode-3.0

  Also available in /usr:
    base-unicode-release-2.8
    gtk2-unicode-release-2.8



me@Kubuntu-1404:~$ update-alternatives --config wx-config
update-alternatives: warning: /etc/alternatives/wx-config has been changed (manually or by a script); switching to manual updates only
There are 4 choices for the alternative wx-config (providing /usr/bin/wx-config).

  Selection    Path                                                          Priority   Status
------------------------------------------------------------
  0            /usr/lib/x86_64-linux-gnu/wx/config/gtk2-unicode-3.0           308       auto mode
  1            /usr/lib/x86_64-linux-gnu/wx/config/base-unicode-3.0           307       manual mode
  2            /usr/lib/x86_64-linux-gnu/wx/config/base-unicode-release-2.8   287       manual mode
  3            /usr/lib/x86_64-linux-gnu/wx/config/gtk2-unicode-3.0           308       manual mode
  4            /usr/lib/x86_64-linux-gnu/wx/config/gtk2-unicode-release-2.8   288       manual mode

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: wx project compile/link - behind the scenes activity
« Reply #5 on: June 20, 2015, 08:56:05 pm »
I think that this is NOT normal.

Code
me@Kubuntu-1404:~$ which wx-config
/opt/wx/3.0_unicode_monolithic_shared/bin/wx-config

What I get
Code
stahta01@debian:~$  which wx-config
/usr/bin/wx-config

Code
stahta01@debian:~$ update-alternatives --config wx-config
There are 4 choices for the alternative wx-config (providing /usr/bin/wx-config).

  Selection    Path                                                          Priority   Status
------------------------------------------------------------
  0            /usr/lib/x86_64-linux-gnu/wx/config/gtk2-unicode-3.0           308       auto mode
  1            /usr/lib/x86_64-linux-gnu/wx/config/base-unicode-3.0           307       manual mode
  2            /usr/lib/x86_64-linux-gnu/wx/config/base-unicode-release-2.8   287       manual mode
  3            /usr/lib/x86_64-linux-gnu/wx/config/gtk2-unicode-3.0           308       manual mode
* 4            /usr/lib/x86_64-linux-gnu/wx/config/gtk2-unicode-release-2.8   288       manual mode

Press enter to keep the current choice[*], or type selection number:

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

Offline sorinev

  • Multiple posting newcomer
  • *
  • Posts: 61
Re: wx project compile/link - behind the scenes activity
« Reply #6 on: June 21, 2015, 12:14:10 am »
Turns out it was a difference in my local ~/.profile. Back in November I had downloaded the wxWidgets 3.0.2 source and compiled it myself. I hadn't known about update-alternatives back then, so I wasn't sure how to use 2.x to compile CodeBlocks from svn updates, but 3.0 to compile my personal projects. So I added the directory that my self compiled wxWidgets installed to (prefix=) to the beginning of the path in my own ~/.profile file and made a couple of scripts to switch a symlink back and forth between 2.8 and 3.0 as necessary.

So whatever specific wxWidgets configuration (from /usr/bin) CodeBlocks was pointing to had some differences, which included AUI by default in --libs. (Another difference was a global compiler setting in CodeBlocks for std-c11).

Anyhow, the build output, binary sizes, and GUI elements are exactly the same now.


Not a CodeBlocks problem, sorry!

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: wx project compile/link - behind the scenes activity
« Reply #7 on: June 21, 2015, 02:01:47 pm »
I have had very similar problems in the past, I think it is a source of potential trouble that wx-config relies on path settings etc. I also build wx3.0 myself (to static libraries) but need to build C::B against wx in the Kubuntu repository

Therefore, I rolled my own C::B project setup with the following

under compiler settings/other options
`$(#wx.config) --cxxflags`

and under linker settings/other linker options
`$(#wx.config) --libs std,aui --static`

my wx global variable in C::B points to /usr/local (base) and it has a user-defined field "config" which is set to
/usr/local/bin/wx-config  --version=3.0  --toolkit=gtk2

This way I am always sure I get the right selection.

For some time I needed to build against both wx2.8 and wx3.0, and I managed to do it for many similar projects by changing the definition of the wx global variable only.