Cannot compile wxWidgets in MacOS
Cannot compile wxWidgets in MacOS
Hi, I have been trying for 2 days to get wxWidgets compiled with no luck, and unfortunately I am not very familiar with Mac. I've been following this guide: https://wiki.wxwidgets.org/Compiling_wx ... (Terminal)
wxWidgets: 3.1.4
I am using Mac Big Sur(11.3 Beta) and G++ (clang 12).
Here are 2 pictures:
It was so simple on Windows...
wxWidgets: 3.1.4
I am using Mac Big Sur(11.3 Beta) and G++ (clang 12).
Here are 2 pictures:
It was so simple on Windows...
Re: Cannot compile wxWidgets in MacOS
I tried with the following configurations:
unfortunately none of them worked. I tried a few more which I found in the forums and google, but I can't remember all of them
Code: Select all
../configure --disable-shared --enable-unicode --prefix="$(pwd)"
Code: Select all
../configure --enable-unicode
Re: Cannot compile wxWidgets in MacOS
I don't work under OSX, so i can't offer a solution, but especially for OSX it might be worth a try to get the latest version from Github and try again.
If no one here knows a solution, try asking at: https://groups.google.com/g/wx-users
If no one here knows a solution, try asking at: https://groups.google.com/g/wx-users
Use the source, Luke!
Re: Cannot compile wxWidgets in MacOS
Thank you very much, I will try asking there aswell! Have a good day!doublemax wrote: ↑Thu Mar 11, 2021 7:04 pm I don't work under OSX, so i can't offer a solution, but especially for OSX it might be worth a try to get the latest version from Github and try again.
If no one here knows a solution, try asking at: https://groups.google.com/g/wx-users
Re: Cannot compile wxWidgets in MacOS
Hi,
You need to try with 3.1.4 and
Can you post the error message and not the picture?
Thank you.
You need to try with 3.1.4 and
Code: Select all
../configure --enable-debug
Thank you.
Re: Cannot compile wxWidgets in MacOS
Thank you for your replies. I downloaded it again for github using git clone, and I managed to compile it. However I am still having issues with compiling my project. After running "wx-config --cxxflags --libs", I got some flags, and I ended up with this command:
(I know, it's so freaking long :c)
but I am getting this error:
ld: library not found for -lexpat
collect2: error: ld returned 1 exit status
I tried removing it but then I got the same error about png (the next flag)
Does that mean something went wrong with compiling the engine?
Code: Select all
g++-10 -mmacosx-version-min=11.2 -std=c++17 -F/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Frameworks -I/Library/Developer/CommandLineTools/usr/include/c++/v1/ -I/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/usr/include -I/usr/local/Cellar/boost/1.75.0_2/include -L/usr/local/Cellar/boost/1.75.0_2/lib -I/usr/local/Cellar/cpprestsdk/2.10.18/include -L/usr/local/Cellar/cpprestsdk/2.10.18/lib -I/usr/local/Cellar/[email protected]/1.1.1j/include/ -L/usr/local/Cellar/[email protected]/1.1.1j/lib -lcpprest -lssl -lcrypto -lboost_system -lboost_thread-mt -lboost_chrono-mt -I/Users/asterios/desktop/wxwidgets/wxwidgets/build-release/lib/wx/include/osx_cocoa-unicode-static-3.1 -I/Users/asterios/desktop/wxwidgets/wxwidgets/include -D_FILE_OFFSET_BITS=64 -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__ -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=1 -DWX_PRECOMP -fno-strict-aliasing -fno-common -Wall -L/Users/asterios/desktop/wxwidgets/wxwidgets/build-release/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL /Users/asterios/desktop/wxwidgets/wxwidgets/build-release/lib/libwx_osx_cocoau_xrc-3.1.a /Users/asterios/desktop/wxwidgets/wxwidgets/build-release/lib/libwx_osx_cocoau_qa-3.1.a /Users/asterios/desktop/wxwidgets/wxwidgets/build-release/lib/libwx_baseu_net-3.1.a /Users/asterios/desktop/wxwidgets/wxwidgets/build-release/lib/libwx_osx_cocoau_html-3.1.a /Users/asterios/desktop/wxwidgets/wxwidgets/build-release/lib/libwx_osx_cocoau_core-3.1.a /Users/asterios/desktop/wxwidgets/wxwidgets/build-release/lib/libwx_baseu_xml-3.1.a /Users/asterios/desktop/wxwidgets/wxwidgets/build-release/lib/libwx_baseu-3.1.a -framework WebKit -lwxregexu-3.1 -lwxscintilla-3.1 -lexpat -lpng -ljpeg -ltiff -lz -framework Security -lpthread -liconv -isysroot -c $(find /Users/asterios/Desktop/app -type f -iregex '.*\.cpp') -g
but I am getting this error:
ld: library not found for -lexpat
collect2: error: ld returned 1 exit status
I tried removing it but then I got the same error about png (the next flag)
Does that mean something went wrong with compiling the engine?
Re: Cannot compile wxWidgets in MacOS
After building the library, first try to build the "minimal" sample that comes with wxWidgets. If that works, you can continue to build your own project (and you know a working command line).
If you look at the output from "configure" on your first screenshot, you see that there are a few libraries (like expat) where wxWidgets can either use its own versions (=builtin) or the ones from the system (=sys). If expat is configured as "sys" you must not add it to the list of included libraries. If the "-lexpat" was part of the wx-config output, there must be some kind of mismatch.
I'm not 100% sure, but i think OSX comes with wxWidgets pre-installed. Maybe the wx-config you executed came from that version and not the one you built (just guessing here).
Code: Select all
ld: library not found for -lexpat
I'm not 100% sure, but i think OSX comes with wxWidgets pre-installed. Maybe the wx-config you executed came from that version and not the one you built (just guessing here).
Use the source, Luke!
Re: Cannot compile wxWidgets in MacOS
Hello,
I am not a Mac user, but you could try DialogBlocks. http://www.dialogblocks.com
It can -even in the demo version- compile wxWidgets and it generates compilable and runnable sample makefiles and projects.
I am not a Mac user, but you could try DialogBlocks. http://www.dialogblocks.com
It can -even in the demo version- compile wxWidgets and it generates compilable and runnable sample makefiles and projects.
Re: Cannot compile wxWidgets in MacOS
Hi,
Which command you use?
Just "git clone"?
You should use the command from http://www.wxwidgets.org/develop/code-repository/
Delete the build directory, update submodules and try to build again.
Thank you.
Which command you use?
Just "git clone"?
You should use the command from http://www.wxwidgets.org/develop/code-repository/
Delete the build directory, update submodules and try to build again.
Thank you.
Re: Cannot compile wxWidgets in MacOS
Thanks for your replies. I managed to build it and build the demos and samples, but trying to build my own project seems impossible.
I am currently running this command:
but I get errors like these:
By googling a bit, seems like there is an linking issue, the weird thing is I put "/Library/Developer/CommandLineTools/usr/include/c++/v1" as an include folder, but when I went to the folder "/Library/Developer/CommandLineTools/usr/libs" I did not find a c++ folder or anything that indicates relevant libraries, but I added this folder as a lib folder just in case with no luck. 4th day and I still can't compile my project in Mac.
I am currently running this command:
Code: Select all
g++-10 -std=c++17 -F/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Frameworks -I/Library/Developer/CommandLineTools/usr/include/c++/v1/ -I/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/usr/include -L/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/usr/lib -L/Library/Developer/CommandLineTools/usr/lib -I/usr/local/Cellar/boost/1.75.0_2/include -I/usr/local/Cellar/libiconv/1.16/include -L/usr/local/Cellar/libiconv/1.16/lib -L/usr/local/Cellar/boost/1.75.0_2/lib -I/usr/local/Cellar/cpprestsdk/2.10.18/include -L/usr/local/Cellar/cpprestsdk/2.10.18/lib -I/usr/local/Cellar/[email protected]/1.1.1j/include/ -L/usr/local/Cellar/[email protected]/1.1.1j/lib -lcpprest -lssl -lcrypto -lboost_system -lboost_thread-mt -lboost_chrono-mt -I/usr/local/include -L/usr/local/lib `/Users/Asterios/Desktop/wxwidgets/wxwidgets/build-release3/wx-config --cxxflags --libs` -c $(find /Users/asterios/Desktop/app -type f -iregex '.*\.cpp') -g
Code: Select all
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:386:9: error: 'sqrtf' has not been declared in '::'
386 | using ::sqrtf;
| ^~~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:387:9: error: 'tan' has not been declared in '::'
387 | using ::tan;
| ^~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:388:9: error: 'tan' has not been declared in '::'
388 | using ::tanf;
| ^~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:390:9: error: 'tan' has not been declared in '::'
390 | using ::tanh;
| ^~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:391:9: error: 'tanhf' has not been declared in '::'
391 | using ::tanhf;
| ^~~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:393:9: error: 'acosh' has not been declared in '::'
393 | using ::acosh;
Re: Cannot compile wxWidgets in MacOS
Hi,
What is your configure line when youi built wxWidgets?
Can you run:
Are you trying to build you program in Terminal or with Xcode?
Look at the command that is used to build the "minimal" sample and use it to build your own software (if you are building in Terminal) as is (no changes). Does it builds?
Thank you.
What is your configure line when youi built wxWidgets?
Can you run:
Code: Select all
~/wxWidgets/buildMac/wx-config --cxxflags
~/wxWidgets/buildMac/wx-config --libs
Look at the command that is used to build the "minimal" sample and use it to build your own software (if you are building in Terminal) as is (no changes). Does it builds?
Thank you.
Re: Cannot compile wxWidgets in MacOS
I checked the sample and it was using g++ and not the latest g++-10 so I tried it and I think it worked, at least I see some .o files and no errors in the console, so I guess it's a good step. Now if I am not mistaken I have to convert it to executable somehow. Do I need to use a makefile for this?
EDIT: I ran g++ again and linked the files, with the following command:
and then a file a.out was created and I could run it. Not sure how to create an executable but I guess that's not an wxWidgets issue so I will find my answer elsewhere. Thank you all for helping me with this!
EDIT: I ran g++ again and linked the files, with the following command:
Code: Select all
g++ *.o `wx-config --cxxflags --libs`
Re: Cannot compile wxWidgets in MacOS
Hi,
You should run the exact same compiler everywhere. Otherwise you will get all kind of different behavior.
In terms of creating the appropriaste App Bundle on OSX - look at the build command for the minimal sample again.
All this stuff like "mkdir" and "cp" after building will give you the right command to properly create an Application Bundle to distribute on OSX.
Keep in mind that (especially on latest OSX) Application Bundle IS a proper way to create an application for Mac OSX.
Thank you.
You should run the exact same compiler everywhere. Otherwise you will get all kind of different behavior.
In terms of creating the appropriaste App Bundle on OSX - look at the build command for the minimal sample again.
All this stuff like "mkdir" and "cp" after building will give you the right command to properly create an Application Bundle to distribute on OSX.
Keep in mind that (especially on latest OSX) Application Bundle IS a proper way to create an application for Mac OSX.
Thank you.