[Solved] Cannot Find -lwxmsw31_core & -lwxbase31

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
DynAggelos
In need of some credit
In need of some credit
Posts: 7
Joined: Sat Apr 14, 2018 3:43 am

[Solved] Cannot Find -lwxmsw31_core & -lwxbase31

Post by DynAggelos »

(I managed to solve this myself, finally, just now. However, here are my comments on this experience.)

I was trying to set up Code::Blocks/wxWidgets to work on my Windows 7 system, and was running into issues. I was getting the following error codes when trying to compile a generic project that comes with Code::Blocks.

Code: Select all

ld.exe | cannot find -lwxmsw31_core
ld.exe | cannot find -lwxbase31
 | error: ld returned 1 exit status
After hours of working on it, I finally got things to compile.

My question now is: why is setting up wxWidgets on Windows so difficult? For example, I spent a great deal of time before I found out I needed to include %WX%\lib\gcc_dll\mswu" in my compiler directory to avoid the "setup.h" error. Couldn't this have been avoided by simply placing a setup.h header into the regular %WX%\include directory which itself includes the specific setup.h needed, depending on the system/compiler/compiler-settings used, rather than expecting users to simply figure this out for themselves? As far as the error I mentioned above, I'm not sure if it was due to wxWidgets 3.1.1 having the wrong file, or if Code::Blocks just hasn't caught up with a change made just recently to wxWidgets.

Anyway, I'm somewhat annoyed, but I still really like wxWidgets. If only it wasn't such a pain just to set up!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: [Solved] Cannot Find -lwxmsw31_core & -lwxbase31

Post by PB »

DynAggelos wrote:My question now is: why is setting up wxWidgets on Windows so difficult? For example, I spent a great deal of time before I found out I needed to include %WX%\lib\gcc_dll\mswu" in my compiler directory to avoid the "setup.h" error. ... If only it wasn't such a pain just to set up!
I believe the procedure is clearly described in the official documentation (WXWIN/docs/msw/install.txt). I am just curious, did you find it difficult to understand and if so, what exactly was unclear?

Edit: I apologize, it actually is not mentioned in the documentation. My mind is blown. The comment above the include that causes the error perhaps could mention the solution of it too...

I am itching to ask the developers why it is and unless somoene here (doublemax?) can provide an explanation I will do that.


Anyway, the reason why the build-specifc setup.h cannot be included automagically is probably because that directory is impossible to find out from inside the general WXWIN/include/wx/setup.h. E.g., how could the general setup.h tell that my build-specific setup.h is stored in gcc720_x86_lib-monolithic?
OTOH, msvc-specific setup.h tries to figure that out when autolinking the libraries and one can use some #defines (e.g., wxCOMPILER_PREFIX, wxCFG) to help it doing that.
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: [Solved] Cannot Find -lwxmsw31_core & -lwxbase31

Post by doublemax »

Notice that this file is later copied into a directory under lib for
each of the build configurations which allows to have different
build options for different configurations too if you edit any
configuration-specific file.
Just for the record, a lib not being found at link time can not have been fixed by adding that one include directory (which is only used at compile time).

If you use the provided make or project files, wxWidgets builds out of the box pretty much all the time.

I think the problem here is CB, which feels like it's responsible for most of the linker/compiler problems in this forum. I wish it had a proper auto-detection of what libraries/configurations are available, that shouldn't be too hard.
Use the source, Luke!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: [Solved] Cannot Find -lwxmsw31_core & -lwxbase31

Post by PB »

doublemax wrote:I think the problem here is CB, which feels like it's responsible for most of the linker/compiler problems in this forum.
I believe that the setup.h issue is not C::B specific, it is the same for MSVC, except it does not manifest when using the msvc-specific include. C::B is also widely used so it is no wonder it has a high count of people with issues. Additionaly, MSVC users have wxWidgets-provided MSVC solutions to look at when in need, a luxury GCC users do not have...

OTOH, IMO not setting up the library paths or listing the required libraries in the linker settings is purely on a user. That's basic C++ and must be done for every non-header-only library not shipped with the build toolchain...

IMO building and using wxWidgets on MSW is very easy, compared to some other libraries. I suppose the big part of that is they do not depend on any 3rd party library...
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: [Solved] Cannot Find -lwxmsw31_core & -lwxbase31

Post by PB »

PB wrote:I am itching to ask the developers why it is and unless somoene here (doublemax?) can provide an explanation I will do that.
Done.
DynAggelos
In need of some credit
In need of some credit
Posts: 7
Joined: Sat Apr 14, 2018 3:43 am

Re: [Solved] Cannot Find -lwxmsw31_core & -lwxbase31

Post by DynAggelos »

OTOH, IMO not setting up the library paths or listing the required libraries in the linker settings is purely on a user. That's basic C++ and must be done for every non-header-only library not shipped with the build toolchain...
I'm sure it's elementary to you, but to someone who is just learning about how to compile a program like myself, every additional step is a challenge. This is only my first time trying to create a GUI C++ program. Before this, simply compiling a single-file program using g++ was an event. Add to this the fact that I not only needed to find out what was going wrong, but how to fix it in a relatively unfamiliar program (Code::Blocks), and I think you can imagine some of my frustration.

I suppose my primary complaint is really about documentation? I found it to either be incomplete for a beginner (i.e. assumes I know things, even though I might just now be trying to code for the first time), or too complicated (i.e. too technical language-wise, too much information without any visuals [the sort of thing that just overwhelms and goes over a new person's head]). I'm hoping my experience can perhaps be used to make it easier for newbies to use wxWidgets in the future. As I said before, I really like wxWidgets, it was just going from a Linux where everything was set up already, to a Windows, where hardly anything could be taken for granted that threw me for a loop.

If I were to make any suggestions that might help future green horns get set up using wxWidgets, it would be:
  • Don't assume someone new to wxWidgets has ever changed environment variables before. Please provide some link to a resource that explains how to do this.
  • It would be nice if the setup-redirect.h file contained more information other than just "This file should not normally be used, except where makefiles have not yet been adjusted to take into account of the new scheme whereby a setup.h is created under the lib directory." This was the first place I looked when the compiler complained that it couldn't find setup.h, and finding something about where this lib directory was would have helped me from the get-go. (Unfortunately, I don't get things through osmosis, especially when exploring something completely new to me.) Or better yet, perhaps simply a URL to a wiki page (or even a wiki search) that explains how best to setup the compiler/linker paths.
  • Perhaps include a URL to wiki pages in the generic installation documentation for each IDE covered in the wiki. (So much information in one place, without visuals, is a head-ache to newbies.)
  • Include information (or link to information) about setting up `wx-config --cxxflags` and `wx-config --libs` when talking about setting up Code::Blocks for using wxWidgets. As I said, it might be elementary to you, but common folk like me expect programs (like Code::Blocks) to just work, and not require special tuning just to use them for the first time. If it does require this, please at least say so.
At any rate, I really do appreciate that there are so many people who are willing to help beginners out, even if sometimes information gets omitted in the communication process. It would be much harder without you!
DynAggelos
In need of some credit
In need of some credit
Posts: 7
Joined: Sat Apr 14, 2018 3:43 am

Re: [Solved] Cannot Find -lwxmsw31_core & -lwxbase31

Post by DynAggelos »

PB wrote:I believe the procedure is clearly described in the official documentation (WXWIN/docs/msw/install.txt). I am just curious, did you find it difficult to understand and if so, what exactly was unclear?
I think the amount of information threw me off. Besides that, the basic instructions "Using plain makefiles" was buried beneath a more complicated "Using configure" section, so I naturally looked at the more complicated instructions first. I felt confused and overwhelmed, and gave up trying to understand it, turning instead to YouTube so I could at least see what should be going on. I think the simpler instructions should come first, but then with a note that instructions for using MSYS or Cygwin to compile wxWidgets would follow, for someone who is already familiar with that method.

To be honest, I didn't even know the makefiles instructions were there until I just now looked. I was under the impression the MSW install instructions contained instructions which had no connections to those I found online. It didn't make any sense, and now I understand why.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: [Solved] Cannot Find -lwxmsw31_core & -lwxbase31

Post by PB »

I do understand that for a newbie it can be difficult to deal with so many things at once: C++ langauge, a complex GUI toolkit, an IDE...

OTOH, one cannot reasonably expect that a GUI toolkit documentation will teach you C++. Documentation for C++ libraries rightfully expects their readers to be proficient at C++, be it the language itself or the building process.

Similarly, I believe that setting an environment variable is just a mid-level Windows user stuff. I would expect a (n aspiring) C++ programmer to be above-average capable user of his PC, once again C++ toolkit documentaion is not a place to teach one how to use the OS...

I do not think anyone ever claimed that C++ was easy. Complexity of C++ is one of the reasons why there are many other programming langauges people gravitate towards. Frankly, C++ may not be the best choice for developing regular smaller scale GUI applications any longer, other languages such as Python + GUI toolkit or even the Electron may prove to be more suitable for the task.

Sorry for being honest.
DynAggelos
In need of some credit
In need of some credit
Posts: 7
Joined: Sat Apr 14, 2018 3:43 am

Re: [Solved] Cannot Find -lwxmsw31_core & -lwxbase31

Post by DynAggelos »

PB wrote:I do understand that for a newbie it can be difficult to deal with so many things at once: C++ langauge, a complex GUI toolkit, an IDE...
Certainly.
PB wrote:OTOH, one cannot reasonably expect that a GUI toolkit documentation will teach you C++. Documentation for C++ libraries rightfully expects their readers to be proficient at C++, be it the language itself or the building process.
I believe I understand where you are coming from, but please understand where I am coming from. When I chose Code::Blocks as an IDE, I did it because I am unfamiliar with make, and I would prefer to use an IDE over make. I have no problem with being forced to use make to compile wxWidgets, as long as the documentation clearly explains how to do this. The only thing the official documentation that comes with the wx library lacks is a slight reorganization of the information, to make it clear to all how to set up wxWidgets (and I'm sure we all agree that one of the primary goals of wxWidgets is to make creating C++ GUIs easier for as many people as possible). I'm not complaining about how difficult computers, or programming, or C++, or wxWidgets is, I'm just trying to point out that there could be improvements to the documentation to help more people get started.

I will point out that while I am a beginner to C++, I am not a complete beginner. I am very close to completing a second class in C++. Due to IDEs like Visual Studio and Code::Blocks, I've never had any need to use make until now. All I am saying is, if I had an extreme amount of trouble setting up wxWidgets on my Windows, other people like me are having that trouble too. Obviously nobody owes it to us, but it would be nice if our trouble could be addressed somehow.
PB wrote:Similarly, I believe that setting an environment variable is just a mid-level Windows user stuff. I would expect a (n aspiring) C++ programmer to be above-average capable user of his PC, once again C++ toolkit documentaion is not a place to teach one how to use the OS...
Essentially what you are saying is that I have no place learning C++ :( . I disagree. People come to C++ (like any programming language) from all kinds of directions, and I don't believe they should be turned away simply because they aren't advanced computer users. They should be educated so they can progress, not turned away at the door.

I have taken three computer classes that might have taught me about environment variables, and didn't: CIS 102 (Introduction to Computers and Information Systems), CIS 176 (Introduction to C/C++ Programming), and CIS 177 (Advanced C/C++ Programming). I don't know of any cases where environment variables would be needed, besides in compiling programs. It would be helpful and convenient if something about them was included (or linked to) in documentation about setting up wxWidgets.
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 550
Joined: Fri Nov 03, 2006 2:00 pm

Re: [Solved] Cannot Find -lwxmsw31_core & -lwxbase31

Post by stahta01 »

You need to understand "environment variables" is a Operating System (OS) piece of knowledge; you would not normally learn it in an C++ Class!!

Tim S.
DynAggelos
In need of some credit
In need of some credit
Posts: 7
Joined: Sat Apr 14, 2018 3:43 am

Re: [Solved] Cannot Find -lwxmsw31_core & -lwxbase31

Post by DynAggelos »

stahta01 wrote:You need to understand "environment variables" is a Operating System (OS) piece of knowledge; you would not normally learn it in an C++ Class!!
That more or less proves my point.
DynAggelos
In need of some credit
In need of some credit
Posts: 7
Joined: Sat Apr 14, 2018 3:43 am

Re: [Solved] Cannot Find -lwxmsw31_core & -lwxbase31

Post by DynAggelos »

Since the wiki here is an open wiki, I've created an account and edited some pages to do something more along the lines of what I would like to see. Hopefully other people won't have the same problems I've had. For example, it turns out there are already two pages on the wiki that talk about environment variables, they just hadn't been linked to in the article on setting up Code::Blocks.

I've updated the following pages:
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: [Solved] Cannot Find -lwxmsw31_core & -lwxbase31

Post by PB »

DynAggelos wrote:Essentially what you are saying is that I have no place learning C++
That is not what I was saying, I did not realize my English was THAT bad.

I did not go to college nor learned about computers at school, so I have no idea what all those classes you listed cover. Seeing as I am not educated and unfortunately and I am not smart either, I may be a living proof that anyone can learn C++, at least up to a certain level: all that is needed is being able to read and type. After all, C++ is a very simple language, its complexity being several orders of magnitude lower than that of a natural language. But still, one has to learn to walk before he runs and stumbling is expected to happen during the process.

BTW, I have never created a makefile in my life, having been exclusively using IDEs since I started.
DynAggelos
In need of some credit
In need of some credit
Posts: 7
Joined: Sat Apr 14, 2018 3:43 am

Re: [Solved] Cannot Find -lwxmsw31_core & -lwxbase31

Post by DynAggelos »

I see. No hard feelings. After I posted that, I did reread what I had said in a previous post, and realized you might have thought I was just starting to get my feet wet with C++.

I.e.,
DynAggelos wrote:I'm sure it's elementary to you, but to someone who is just learning about how to compile a program like myself, every additional step is a challenge. This is only my first time trying to create a GUI C++ program. Before this, simply compiling a single-file program using g++ was an event.
PB wrote:
PB wrote:I am itching to ask the developers why it is and unless somoene here (doublemax?) can provide an explanation I will do that.
Done.
Thanks for that.
Post Reply