Hello,
this is my first topic on this forum and it is an absolute beginner question:
One week ago I started rewriting an old python project to c++. I wanted to get to know c++ a little bit better. Until then I just used it for Microcontrollers like Arduino.
I started rewriting the code in c++, which went surprisingly well. As a very simple GUI I used wxPython, so I decided to go with wxWidgets for the c++ version. I used
https://docs.wxwidgets.org/trunk/plat_osx_install.html
to build wxWidgets and the examples. It took around 15 minutes. I decided to skip advanced installing the library because "rarely desirable to install non-Apple software into system directories". "The examples are working very well, so I decided to try to compile a working example. I choose minimal from the examples I opened it up in Visual Studio Code and changed the path from wx/wx.h to an absolute path, as told in wiki. He found the files, but he had problems with dependencies from wx.h e.g. wx/defs.h. I changed the path, from one dependency by removing wx/, it worked. But then the same problem occurred again and again. I could not think that this is a mistake because it worked while building it. So I started to research and read the wiki article again. I was wondering about "use the full path to wx-config under the build directory when building an application using the library". The same instructions can be found in the docs OS X folder. I thought I had done it right by changing the path but then I looked up the wx-config file. And got confused. Now, I do not what to do. I built it once again, the same error.
These are more wx related questions:
Do I have to use wx-config, what does it?
How I set the path correctly?
How I make that the linker will find the build-cocoa-debug folder with the bin?
Do I have to use a Makefile/Builtfile/Bakefile?
In the samples/minimal folder, I do not know what the files are doing.
There I do not know, If they are related to wx but that was used in the examples, so I am going to ask it:
Where is the difference between Make-, Built and Bakefiles?
How do I create an .app Application as seen in the examples?
I am using macOS 10.15.4, VScodium 1.44.0, g++, Apple clang version 11. Xcode and command line tools are installed.
Thank you very much for your help and for this project/forum.
-f-
Using wxWidget on macOS 10.14.4 with VScode Topic is solved
Re: Using wxWidget on macOS 10.14.4 with VScode
Hi,
All this is very confusing.
The best way to start with wxWidgets in OSX is:
1. Download and unpack wxWidgets (for example in ~/wxWidgets)
2. OPen the Terminal
3. Do following:
After this will successfully finished you know that everything is compiled properly and you can start with building your own software.
In order to do that you do:
and
Then you should be able to build your own program.
Thank you.
P.S.: If you get any issues at any point - please post here and we will be able to help.
To answer your questions:
There I do not know, If they are related to wx but that was used in the examples, so I am going to ask it:
Bakefile is just a way to generate the Makefile.
You don't need to use it.
All this is very confusing.
The best way to start with wxWidgets in OSX is:
1. Download and unpack wxWidgets (for example in ~/wxWidgets)
2. OPen the Terminal
3. Do following:
Code: Select all
cd ~/wxWidgets && mkdir buildOSX && cd buildOSX && ../configure && make && cd samples/minimal && make
In order to do that you do:
Code: Select all
cd ~/wxWidgets/buildOSX && ./wx-config --cxxflags
Code: Select all
cd ~/wxWidgets/buildOSX && ./wx-config --libs
Thank you.
P.S.: If you get any issues at any point - please post here and we will be able to help.
To answer your questions:
wx-config is a little script that will help to indicate where the include folder and the libraries are located and also all additional options from the build.Do I have to use wx-config, what does it?
You don't have to - wx-config will help here.How I set the path correctly?
Again the wx-config command I posted above will help.How I make that the linker will find the build-cocoa-debug folder with the bin?
No, you don't have to.Do I have to use a Makefile/Builtfile/Bakefile?
You don't have to know.In the samples/minimal folder, I do not know what the files are doing.
There I do not know, If they are related to wx but that was used in the examples, so I am going to ask it:
Are you familiar with the build system and the Makefile? Basically "make" is the little script that will execute the g++/clang program and build yiour software based on the Makefile rules you or someone put in.Where is the difference between Make-, Built and Bakefiles?
Bakefile is just a way to generate the Makefile.
You don't need to use it.
Just look at how "minimal" sample will be built.How do I create an .app Application as seen in the examples?
Re: Using wxWidget on macOS 10.14.4 with VScode
Thank you very much for your fast answer. It has become a lot clearer.
An compiler error still exists:
This is used:
An compiler error still exists:
This is used:
Code: Select all
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
Code: Select all
user@Lucas-MBP wx % cd "/Users/user/Desktop/cpp/wx/" && g++ helloworld.cpp -o helloworld && "/Users/user/Desktop/cpp/wx/"helloworld
helloworld.cpp:3:10: fatal error: 'wx/wxprec.h' file not found
#include <wx/wxprec.h>
^~~~~~~~~~~~~
1 error generated.
user@Lucas-MBP wx %
Re: Using wxWidget on macOS 10.14.4 with VScode
Hi,
So I presume that the library and the minimal sample compiled OK.
Now for y0our own project you can either try to create an Xcode project or work from Terminal.
Now about the error:
What is an exact command you used to compile the code?
Thank you.
So I presume that the library and the minimal sample compiled OK.
Now for y0our own project you can either try to create an Xcode project or work from Terminal.
Now about the error:
What is an exact command you used to compile the code?
Thank you.
Re: Using wxWidget on macOS 10.14.4 with VScode
I will try to work from terminal.
I used
to compile.
I used
Code: Select all
g++ helloworld.cpp -o helloworld
Re: Using wxWidget on macOS 10.14.4 with VScode
Hi,
You should be using:
Make sure you are using "back-ticks" and not the "apostrophies" (symbol that is found in the top left key on the keyboard)
Thank you.
You should be using:
Code: Select all
g++ helloworld.cpp -o helloworld `~/wxWidgets/buildOSX/wx-config --cxxflags --libs`
Thank you.
Re: Using wxWidget on macOS 10.14.4 with VScode
Thank you very much. It worked fine.