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
Experienced Solver
Experienced Solver
Posts: 64
Joined: Sat Oct 07, 2006 1:56 pm

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

Post by tigerbeard » Tue Jun 30, 2020 10:10 am

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: Xubuntu16.04/Win7/XP/2K, wxWidgets 2.9.3, C::B, GCC, VC

stahta01
Super wx Problem Solver
Super wx Problem Solver
Posts: 365
Joined: Fri Nov 03, 2006 2:00 pm

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

Post by stahta01 » 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.

TIm S.

tigerbeard
Experienced Solver
Experienced Solver
Posts: 64
Joined: Sat Oct 07, 2006 1:56 pm

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

Post by tigerbeard » Wed Jul 01, 2020 10:10 am

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: Xubuntu16.04/Win7/XP/2K, wxWidgets 2.9.3, C::B, GCC, VC

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2511
Joined: Sun Jan 03, 2010 5:45 pm

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

Post by PB » Wed Jul 01, 2020 10:37 am

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.

Post Reply