Why does WX compile to different structures in Linux and Windows?

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
tigerbeard
Earned some good credits
Earned some good credits
Posts: 123
Joined: Sat Oct 07, 2006 1:56 pm

Why does WX compile to different structures in Linux and Windows?

Post by tigerbeard »

I am moving from Windows to Linux using CodeBlocks. I want to work with local installations of wxWdigets from a repository that work the same on any machine I checkout at. That means I will not use any globally installe wxWidgets in Linux but use the local libs with a relative path from the sources. Basically the idea is to have the setup of wxWidgets between Linux and Windows as similar as possible.
In CodeBlocks I use different build targets in C::B for Linux and Windows. You can define the platform to be used for each build target which is very smart.

Now I have the problem that in Linux I get a very different structure after compiling than I got in Windows. For example I have multiple include folders and I am confused which one to use. My guesss is that this does not make sense and I had made some mistake at compiling. I checked the wiki for some guidelines, but I only found tips to use wx-configure for flags.

On Windows I am used to include the following directories in the UDE search paths (depending on the build target):

Code: Select all

 ($WX)
   include/
        msvc/wx/setup.h
        wx                                              # headers
   lib/
     gcc_lib/mswu                                   # lib files
     gcc_lib/mswud
     gcc_dll/mswu
     gcc_dll/mswud
In Linux I expected to get a similar structure like this

Code: Select all

 
   include/
        gtl2/wx/setup.h
        wx                                              # headers
   lib/
     gtk2u_so
     gtk2ud_so
 
So the combined compiled wx-structure for use in Linux and Windows would look like this

Code: Select all

 ($WX)
   include/
        msvc/wx/setup.h
        gtl2/wx/setup.h
        wx                                              # headers
   lib/
     gcc_lib                                             # lib files
     gcc_dll
     gtk2u_so
     gtk2ud_so

But after compilation I get this

Code: Select all

 
   include/
        msvc/wx/setup.h
        gtl2/wx/setup.h
        wx                                              # headers
   lib/
      gtk2u_so
         include/wx-2.9/wx                       # headers
         lib/                                               # lib files
             wx/ 
                 config/                                 # seems to be connected with wx-config
                 include/
                    gtk2-unicode.2.9/wx/setup.h
      gtk2ud_so
         include/wx-2.9/wx                    
         lib/                                            
             wx/ 
                 config/                              
                 include/
                    gtk2-unicode.2.9/wx/setup.h
I did compile wxWidgets after unpacking the sources like this (same for the debug version)

Code: Select all

 mkdir build-gkt
 cd build-gkt
 make clean
 ../configure --with-gtk=2 --with-opengl --with-stl --prefix=$PWD/../lib/gtk2u_so
 make
 install
It seems strange to me to duplicate the headers files for each version in Linux but not in Windows. Also it seems strange to bury the setup.h so deep in the structure. Would there ever be more than one setup.h for a set of compiled libs in Linux, so there is a need to distinguish them from each other?

- did I do something wrong to end up with that structure? What is the correct way to do it?
- is that different by design for some specific reason? I
- what should I use for searth paths in CodeBlocks?

If there is some docu or a post explaining that thanks for pointing me there.

Edit:
I have found something in the wiki confirming the differences, but not getting into details. https://wiki.wxwidgets.org/Compiling_an ... ng_started. It does not give reasons why it has to be different and does not help to understand what paths would be needed.

There are two further links discussing wx-config (https://wiki.wxwidgets.org/Wx-Config, https://docs.wxwidgets.org/trunk/plat_gtk_install.html). From what I found there it is not clear how I can make CodeBlocks to use the wx config flags of only that local setup. It somehow involves setting the path to the bin subdirectory, but I am not sure where.
Specifically, the linked section says "From your IDE, you can simply put `wx-config --cxxflags` in compile flags and `wx-config --libs` in link flags" and "...a local wx-config will be created in the build directory. You can then simply get the flags by calling wx-config locally : ./wx-config. This can also help keeping different configurations truly separate and may avoid some conflicts." Its obvious how to so this on the command line, but how can I tell Codeblocks that for a specific BuildTarget it should use this local wx-config file? I guess its more a question for the codeblocks forum...
System config: Xubuntu22.04, wxWidgets 3.0.5,gcc, C::B
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 548
Joined: Fri Nov 03, 2006 2:00 pm

Re: Why does WX compile to different structures in Linux and Windows?

Post by stahta01 »

You are wrong! You are using the wrong wx/setup.h under widows because the right one is under the lib folder.
You are using the one that the wxTeam provided because too many MSVC users are to ignorant to use the correct location.

TIm S.
tigerbeard
Earned some good credits
Earned some good credits
Posts: 123
Joined: Sat Oct 07, 2006 1:56 pm

Re: Why does WX compile to different structures in Linux and Windows?

Post by tigerbeard »

OK, thanks for the hint.
I understand you are saying in Windows the proper way is this:

Code: Select all

 
 include
      msvc/wx/setup.h           # should not be used
 lib
    gcc_lib
        mswu/wx/setup.h        #  this is the original and this should be used.
    gcc_lib
        mswud/wx/setup.h      #  this is the original and this should be used.
     ...    
Interesting, I was not aware there was a setup.h in each lib folder.
System config: Xubuntu22.04, wxWidgets 3.0.5,gcc, C::B
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Why does WX compile to different structures in Linux and Windows?

Post by PB »

stahta01 wrote: Tue Jun 30, 2020 11:14 pm You are wrong! You are using the wrong wx/setup.h under widows because the right one is under the lib folder.
You are using the one that the wxTeam provided because too many MSVC users are to ignorant to use the correct location.
Sorry, I believe this is may not be true. The correct include paths for MSVC looks like
$(WXWIN)\include\msvc;$(WXWIN)\include
The official docs says
If using MSVC, prepend $WXWIN\include\msvc to the include paths too. Otherwise, append <wx-lib-dir>\mswu[d] to the include paths, where "d" should be used for debug builds only.
The MSVC specific include folder has setup.h which:
  1. Includes the build-specific setup.h (based on preprocessor defines).
  2. Autolinks all required wxWidgets and Windows libraries so they do not have to be listed manually.
It is not laziness on the side of wxWidgets users, it is a convenience provided by wxWidgets developers (many other C++ libraries including Boost do that as well). Unlike MSVC or Clang, GCC does not provide the autolink feature so this can be done only for MSVC.

IMO, the build-specific setup.h is a thing almost no-one uses but complicates life for all.
tigerbeard
Earned some good credits
Earned some good credits
Posts: 123
Joined: Sat Oct 07, 2006 1:56 pm

Re: Why does WX compile to different structures in Linux and Windows?

Post by tigerbeard »

In the mean time I got used to the structure, but I have to admit I do still not undestand it. The discussion focussed on Windows, but the point of my question actually was the Linux side.

For example according to my Diff tool the built libraries in the lib folders are identical between the builds. They are also identical to the main "include/wx" folder (i.e. all folders with "headers" below are the same). So there is duplication of source code, and I can not see any benefit.

Code: Select all

   
   include/wx                                    # headers
   lib/
      gtk2u_so
         include/wx-2.9/wx                       # headers
      gtk2ud_so
         include/wx-2.9/wx                       # headers
So in case someone can enlight be a bit it still would be appreciated. :D
System config: Xubuntu22.04, wxWidgets 3.0.5,gcc, C::B
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Why does WX compile to different structures in Linux and Windows?

Post by ONEEYEMAN »

Hi,
wxWidgets team , you need to include 2 folders - one is WXWIN\include, the other- build specific one, where the file is.

setup.h as convenient way to sconfigure the build under MSVX.
So, when you download and unpack the sources, you could open WXWIN\include\wx\.sw\setup.h, edit it to what you like and build the library.
This modified copy will end up in the build specific directory from WXWIN\lib.
In fact the very first thing MSVC does is to make the lib folder and copy the file to the appropriate configuration
And so, when you build your application you have to include 2 directories- one for WXWIN\include, the other - for the build-specific setup.h file.
Since neither MSVC nor MinGW have configure, that's how it works there.

On *nix-like systems things are different. You have configure script.
So, running configure/make the appropriate setup.h file is not created instead a build-specific wx-config script is made. And copied to the build install directory. So, when you run configure - you build the library in the WXWIN\lib folder and wx-config script is being put there. So that when building you application all you need is to run wx-config --cxxflags and wx-config--libs..

Now, since on Windows is de-facto standard to build static linking apps, there is no predefined place to install libraries. And if using MSVC/MinGW you just include the 2 dirs above and it will work.
On *nix-like system you can install libraries to platform defined locations (usually /usr/lical/lib, if you install things manually) or user specified location (done with supplying prefix option to configure). And so all you do is to run wx'config.

Thank you.
tigerbeard
Earned some good credits
Earned some good credits
Posts: 123
Joined: Sat Oct 07, 2006 1:56 pm

Re: Why does WX compile to different structures in Linux and Windows?

Post by tigerbeard »

ONEEYEMAN wrote: Sat Feb 04, 2023 5:06 pm On *nix-like system you can install libraries to platform defined locations (usually /usr/lical/lib, if you install things manually) or user specified location (done with supplying prefix option to configure). And so all you do is to run wx'config.
I can see the differences of build definitions with setup.h and wxconfig.

But the issue to have defined places for libs or the ability to include the paths the the application or add them from anywhere with ldconfig only affect lib files. it does not affect headers
Or does wxconfig require to have the headers duplicated nearby?
System config: Xubuntu22.04, wxWidgets 3.0.5,gcc, C::B
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Why does WX compile to different structures in Linux and Windows?

Post by ONEEYEMAN »

Hi,
What duplication you are talking about?
On what platform?

Please delete the whole wxWidgets directory and build it with SUPPORTED IDE/compiler.

Only one place for one build should be produced.

Only setup.h on Windows should be copied to the build specific directory.

Keep in mind that this is an open source project, so you can set it up to your liking.

Thank you.
tigerbeard
Earned some good credits
Earned some good credits
Posts: 123
Joined: Sat Oct 07, 2006 1:56 pm

Re: Why does WX compile to different structures in Linux and Windows?

Post by tigerbeard »

ONEEYEMAN wrote: Sat Feb 04, 2023 7:31 pm What duplication you are talking about?
On what platform?
I did compile from the command line. As I said I am in Linux (Xubuntu but that should not really matter).

Since I did compile with the autotools this is "out-of-the-box". Thats why I think the structures should make some intrinsic sense. Maybe I confused you with my windows reference. I have the windows install on a separate computer, of course. but the include/wx directory is unchanged after the build (i.e. its not copied anywhere). On my Linux box the default configure/make copies it for each build.
System config: Xubuntu22.04, wxWidgets 3.0.5,gcc, C::B
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Why does WX compile to different structures in Linux and Windows?

Post by ONEEYEMAN »

Hi,
Understood.
Are you using any "prefix" options? Do you do "make install"?

Thank you.
tigerbeard
Earned some good credits
Earned some good credits
Posts: 123
Joined: Sat Oct 07, 2006 1:56 pm

Re: Why does WX compile to different structures in Linux and Windows?

Post by tigerbeard »

ONEEYEMAN wrote: Sat Feb 04, 2023 8:56 pm Are you using any "prefix" options? Do you do "make install"?
Right, now I see why.

To get a local install I need to use the prefix, and then use make install. Since it can not know the prefix is inside the wxWidgets lib tree but anywhere on disk it also installs the include folders. So its built-in in the makefiles. Maybe there is an option to only install the lib files...
I wasn't seeing the forest for the trees #-o


But what is about the other two folders: bin and share. Bin seems clear it contains the wxconfig script. But what is with the stuff in share. On deploy I only copied the lib subfolder, so for running wxWidgets that can not be required. It all that 3MB stuff required to run wxconfig?
System config: Xubuntu22.04, wxWidgets 3.0.5,gcc, C::B
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Why does WX compile to different structures in Linux and Windows?

Post by ONEEYEMAN »

Hi,
It's not possible to install just libraries or just headers. How will you use it then? 😀
What does this share folder contain? Can you post "ls -la" on it?

Thank you.
tigerbeard
Earned some good credits
Earned some good credits
Posts: 123
Joined: Sat Oct 07, 2006 1:56 pm

Re: Why does WX compile to different structures in Linux and Windows?

Post by tigerbeard »

ONEEYEMAN wrote: Sun Feb 05, 2023 3:31 pm It's not possible to install just libraries or just headers. How will you use it then? 😀
I meant that when I deploy my own programs created with WX in Linux I only need the libs (=so objects) to run the application. In other words I "install" my binaries and "just" some libs.

ONEEYEMAN wrote: Sun Feb 05, 2023 3:31 pm What does this share folder contain? Can you post "ls -la" on it?
No idea what m4 or bakefiles have to do with my builds nor why I would need non-english messages when gcc spits out english only anyway..

Code: Select all

├── aclocal
│   └── wxwin.m4
├── bakefile
│   └── presets
│       ├── wx.bkl
│       ├── wx_presets.py
│       ├── wx_unix.bkl
│       ├── wx_win32.bkl
│       └── wx_xrc.bkl
└── locale
    ├── ca
    │   └── LC_MESSAGES
    ...
System config: Xubuntu22.04, wxWidgets 3.0.5,gcc, C::B
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Why does WX compile to different structures in Linux and Windows?

Post by ONEEYEMAN »

Hi,
tigerbeard wrote: Sun Feb 05, 2023 5:10 pm
ONEEYEMAN wrote: Sun Feb 05, 2023 3:31 pm It's not possible to install just libraries or just headers. How will you use it then? 😀
I meant that when I deploy my own programs created with WX in Linux I only need the libs (=so objects) to run the application. In other words I "install" my binaries and "just" some libs.
When you are ready to distribute, you will create rpm/deb which will take care of installing your app as well as any and all dependencies you program have.
tigerbeard wrote: Sun Feb 05, 2023 5:10 pm
ONEEYEMAN wrote: Sun Feb 05, 2023 3:31 pm What does this share folder contain? Can you post "ls -la" on it?
No idea what m4 or bakefiles have to do with my builds nor why I would need non-english messages when gcc spits out english only anyway..

Code: Select all

├── aclocal
│   └── wxwin.m4
├── bakefile
│   └── presets
│       ├── wx.bkl
│       ├── wx_presets.py
│       ├── wx_unix.bkl
│       ├── wx_win32.bkl
│       └── wx_xrc.bkl
└── locale
    ├── ca
    │   └── LC_MESSAGES
    ...
I don't know what is this shared folder for - I don't run "make install"...
All I can tell you - locale directory is for i18n of your app and has nothing to do with gcc...

Thank you.
Last edited by ONEEYEMAN on Sun Feb 05, 2023 7:46 pm, edited 1 time in total.
tigerbeard
Earned some good credits
Earned some good credits
Posts: 123
Joined: Sat Oct 07, 2006 1:56 pm

Re: Why does WX compile to different structures in Linux and Windows?

Post by tigerbeard »

ok, thanks for your feedback!
System config: Xubuntu22.04, wxWidgets 3.0.5,gcc, C::B
Post Reply