Cannot compile wxWidgets in MacOS

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
DjSt3rios
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Mar 11, 2021 4:41 pm

Cannot compile wxWidgets in MacOS

Post by DjSt3rios » Thu Mar 11, 2021 4:53 pm

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:
Image

Image

It was so simple on Windows...

User avatar
doublemax
Moderator
Moderator
Posts: 16194
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Cannot compile wxWidgets in MacOS

Post by doublemax » Thu Mar 11, 2021 5:07 pm

What was your configure command line?
Use the source, Luke!

DjSt3rios
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Mar 11, 2021 4:41 pm

Re: Cannot compile wxWidgets in MacOS

Post by DjSt3rios » Thu Mar 11, 2021 6:45 pm

I tried with the following configurations:

Code: Select all

../configure --disable-shared --enable-unicode --prefix="$(pwd)"

Code: Select all

../configure --enable-unicode
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 :cry:

User avatar
doublemax
Moderator
Moderator
Posts: 16194
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Cannot compile wxWidgets in MacOS

Post by doublemax » 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
Use the source, Luke!

DjSt3rios
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Mar 11, 2021 4:41 pm

Re: Cannot compile wxWidgets in MacOS

Post by DjSt3rios » Thu Mar 11, 2021 7:50 pm

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
Thank you very much, I will try asking there aswell! Have a good day!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5224
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Cannot compile wxWidgets in MacOS

Post by ONEEYEMAN » Thu Mar 11, 2021 10:40 pm

Hi,
You need to try with 3.1.4 and

Code: Select all

../configure --enable-debug
Can you post the error message and not the picture?

Thank you.

DjSt3rios
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Mar 11, 2021 4:41 pm

Re: Cannot compile wxWidgets in MacOS

Post by DjSt3rios » Fri Mar 12, 2021 10:47 am

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:

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/openssl@1.1/1.1.1j/include/ -L/usr/local/Cellar/openssl@1.1/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
(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?

User avatar
doublemax
Moderator
Moderator
Posts: 16194
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Cannot compile wxWidgets in MacOS

Post by doublemax » Fri Mar 12, 2021 11:59 am

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).

Code: Select all

ld: library not found for -lexpat
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).
Use the source, Luke!

Peter H
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Mar 12, 2021 12:29 pm

Re: Cannot compile wxWidgets in MacOS

Post by Peter H » Fri Mar 12, 2021 12:35 pm

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.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5224
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Cannot compile wxWidgets in MacOS

Post by ONEEYEMAN » Fri Mar 12, 2021 1:25 pm

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.

DjSt3rios
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Mar 11, 2021 4:41 pm

Re: Cannot compile wxWidgets in MacOS

Post by DjSt3rios » Fri Mar 12, 2021 4:12 pm

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:

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/openssl@1.1/1.1.1j/include/ -L/usr/local/Cellar/openssl@1.1/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
but I get errors like these:

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;
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. 😥

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5224
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Cannot compile wxWidgets in MacOS

Post by ONEEYEMAN » Fri Mar 12, 2021 4:35 pm

Hi,
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
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.

DjSt3rios
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Mar 11, 2021 4:41 pm

Re: Cannot compile wxWidgets in MacOS

Post by DjSt3rios » Fri Mar 12, 2021 5:00 pm

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:

Code: Select all

g++ *.o `wx-config --cxxflags --libs`
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!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5224
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Cannot compile wxWidgets in MacOS

Post by ONEEYEMAN » Fri Mar 12, 2021 6:37 pm

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.

Post Reply