mac/wxwidgets g++ compiling rage

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.
Kiithsjet
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Mar 14, 2016 1:20 am

mac/wxwidgets g++ compiling rage

Post by Kiithsjet »

I'm becoming furious with wxWidgets. I cant figure out how to compile a simple helloworld program on mac os 10.9.5 and I cant find any documentation online that is of any use. I have configured and "installed" wxWidgets exactly as instructed on wxwidgets.org without any issues. When I try to compile using [g++ widgetTest.cpp `wx-config --cxxflags --libs` -o widgetTest] as advertised on wxwidgets.org, the terminal outputs "Undefined symbols for architecture x86_64:" followed by 1000+ %$@%ing things that don't work despite having installed and configured everything in accordance with the supposed documentation. Somebody please help. I've spent the better half of a month desperately scouring the internet trying to get started with wxWidgets and have made no progress.
New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: mac/wxwidgets g++ compiling rage

Post by New Pagodi »

In no one can help you here, you might try asking on the list serve. I think there are more mac users there.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: mac/wxwidgets g++ compiling rage

Post by ONEEYEMAN »

Hi, Kiithsjet,
Couple of questions:
1. Did you successfully compile the library?
2. Did you use any special configure options?
3. What happens when you type "g++ --version" in terminal?
4. In the wxWidgets build directory there should be a file called config.log. If you open if the first meaningful line will be "configure <option1>,.....".
Could you post that line please?

Thank you.

P.S.: All this if you are still struggling...
Kiithsjet
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Mar 14, 2016 1:20 am

Re: mac/wxwidgets g++ compiling rage

Post by Kiithsjet »

I have successfully compiled the library.
I have only used ../configure --disable-shared --enable-unicode --prefix="$(pwd)" configure options.
Compiler version yields:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
line #7 of config.log reads:
$ ../configure --disable-shared --enable-unicode --prefix=/Users/myUser/Downloads/wxWidgets-svn/build-release
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: mac/wxwidgets g++ compiling rage

Post by ONEEYEMAN »

Hi,
More questions:

1. If you go to the wxWidgets/buildMac/samples/minimal and do "make" will it finish successfully? (buildMac is a directory where you compiled the library).
2. Go to the directory where you have you "hello world.cpp" and type "wx-config". Do you have any errors?

If 1 is successful and 2 is not you need to modify the $PATH variable on your Mac or give the path to the wx-config on compilation....

Thank you.
Kiithsjet
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Mar 14, 2016 1:20 am

Re: mac/wxwidgets g++ compiling rage

Post by Kiithsjet »

All I get when building the sample is the following:

g++ -mmacosx-version-min=10.5 -o minimal minimal_minimal.o -L/Users/calecampbell/Downloads/wxWidgets-svn/cales-build/lib -L/opt/local/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -lwx_osx_cocoau_core-3.1 -lwx_baseu-3.1 -lwxtiff-3.1 -lpng -lz -ljpeg -framework WebKit -lwxregexu-3.1 -L/opt/local/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -lz -lpthread -liconv -llzma -lz -lpthread -liconv -llzma
Undefined symbols for architecture x86_64:
.
.
...(lots of stuff here)
.
.
. wxPNGHandler::SaveFile(wxImage*, wxOutputStream&, bool) in libwx_osx_cocoau_core-3.1.a(corelib_imagpng.o)
"_wx_png_write_end", referenced from:
wxPNGHandler::SaveFile(wxImage*, wxOutputStream&, bool) in libwx_osx_cocoau_core-3.1.a(corelib_imagpng.o)
"_wx_png_write_info", referenced from:
wxPNGHandler::SaveFile(wxImage*, wxOutputStream&, bool) in libwx_osx_cocoau_core-3.1.a(corelib_imagpng.o)
"_wx_png_write_rows", referenced from:
wxPNGHandler::SaveFile(wxImage*, wxOutputStream&, bool) in libwx_osx_cocoau_core-3.1.a(corelib_imagpng.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [minimal] Error 1
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: mac/wxwidgets g++ compiling rage

Post by ONEEYEMAN »

Hi,
Kiithsjet wrote: All I get when building the sample is the following:

g++ -mmacosx-version-min=10.5 -o minimal minimal_minimal.o -L/Users/calecampbell/Downloads/wxWidgets-svn/cales-build/lib -L/opt/local/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -lwx_osx_cocoau_core-3.1 -lwx_baseu-3.1 -lwxtiff-3.1 -lpng -lz -ljpeg -framework WebKit -lwxregexu-3.1 -L/opt/local/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -lz -lpthread -liconv -llzma -lz -lpthread -liconv -llzma
Undefined symbols for architecture x86_64:
.

Something very weird is going on here.

1. Are you sure you are on 10.9.5?
2. Is this:

Code: Select all

 ../configure --disable-shared --enable-unicode --prefix="$(pwd)"
 
the line you used to configure the library and the line you see in the config.log file?

Please do following:
1. Grab the release files for 3.1.
2. Unpack in the new directory - wx_new, for example.
3. Do this:

Code: Select all

cd wx_new && mkdir buildMac && cd buildMac && ../configure --disable-shared --with-cocoa --with-macosx-version-min=10.7 && make
. You can change "10.7" to whatever the minimum requirement is for you software on Mac OSX is. 10.7 is the minimum supported version of OSX.
4. Make sure there is no errors on the previous step. Now do this:

Code: Select all

cd samples/minimal && make
5. Make sure there is no errors on the previous step. Now do this:

Code: Select all

open minimal.app
6. Try to compile you own code.

Post here if you encounter any issues during those steps.

Thank you.
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Re: mac/wxwidgets g++ compiling rage

Post by eranif »

Kiithsjet, this is how we build wxWidgets for building CodeLite on OSX:

http://codelite.org/Developers/BuildingCodeLiteOnAMac

Notice that we use clang++ and not g++

HTH,
Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: mac/wxwidgets g++ compiling rage

Post by ONEEYEMAN »

Hi, Eran,
Notice that he is on 10.9, didn't specify minimal OS version and his minimal compilation command mentions 10.5.

So at this point the best would be to recompile everything, making sure the minimal sample is buildable.

Thank you.
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Re: mac/wxwidgets g++ compiling rage

Post by eranif »

I did notice that he is on 10.9, however, I wrote this wiki page when I was using 10.8 - so I assumed its OK

Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org
Kiithsjet
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Mar 14, 2016 1:20 am

Re: mac/wxwidgets g++ compiling rage

Post by Kiithsjet »

ONEEYEMAN wrote:Hi,
Kiithsjet wrote: All I get when building the sample is the following:

g++ -mmacosx-version-min=10.5 -o minimal minimal_minimal.o -L/Users/calecampbell/Downloads/wxWidgets-svn/cales-build/lib -L/opt/local/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -lwx_osx_cocoau_core-3.1 -lwx_baseu-3.1 -lwxtiff-3.1 -lpng -lz -ljpeg -framework WebKit -lwxregexu-3.1 -L/opt/local/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -lz -lpthread -liconv -llzma -lz -lpthread -liconv -llzma
Undefined symbols for architecture x86_64:
.

Something very weird is going on here.

1. Are you sure you are on 10.9.5?
2. Is this:

Code: Select all

 ../configure --disable-shared --enable-unicode --prefix="$(pwd)"
 
the line you used to configure the library and the line you see in the config.log file?

Please do following:
1. Grab the release files for 3.1.
2. Unpack in the new directory - wx_new, for example.
3. Do this:

Code: Select all

cd wx_new && mkdir buildMac && cd buildMac && ../configure --disable-shared --with-cocoa --with-macosx-version-min=10.7 && make
. You can change "10.7" to whatever the minimum requirement is for you software on Mac OSX is. 10.7 is the minimum supported version of OSX.
4. Make sure there is no errors on the previous step. Now do this:

Code: Select all

cd samples/minimal && make
5. Make sure there is no errors on the previous step. Now do this:

Code: Select all

open minimal.app
6. Try to compile you own code.

Post here if you encounter any issues during those steps.

Thank you.
Ok, so the

Code: Select all

--with-macosx-version-min=10.7
seems to have done the trick. Everything above worked properly. The sample window app loads and runs as it should, however...
I'm now back to where I was when I had my original problem. Even when compiling with the wx-config --cxxflags wx-config --libs options:

Code: Select all

g++ -I/usr/local/lib/wx/include/osx_cocoa-unicode-static-3.1 -I/usr/local/include/wx-3.1 -D_FILE_OFFSET_BITS=64 -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__ -o myExec wxHello.cpp -L/usr/local/lib   -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL /usr/local/lib/libwx_osx_cocoau_xrc-3.1.a /usr/local/lib/libwx_osx_cocoau_qa-3.1.a /usr/local/lib/libwx_baseu_net-3.1.a /usr/local/lib/libwx_osx_cocoau_html-3.1.a /usr/local/lib/libwx_osx_cocoau_adv-3.1.a /usr/local/lib/libwx_osx_cocoau_core-3.1.a /usr/local/lib/libwx_baseu_xml-3.1.a /usr/local/lib/libwx_baseu-3.1.a -framework WebKit -lexpat -lwxregexu-3.1 -lwxtiff-3.1 -lwxjpeg-3.1 -lwxpng-3.1 -lz -lpthread -liconv -llzma
I'm still getting header file issues:

Code: Select all

/usr/local/include/wx-3.1/wx/strvararg.h:27:18: fatal error: 'tr1/type_traits' file not found
        #include <tr1/type_traits>
What I don't understand is why after configuring and installing everything on a per-system basis there are still pieces of the puzzle missing.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: mac/wxwidgets g++ compiling rage

Post by ONEEYEMAN »

Hi,
So we have solved one problem - build one.
Now lets work on how to make you program build.

1. Can you paste the results of:

Code: Select all

wx-config --cxxflags
wx-config --libs
Notice that those 2 commands above can be run anywhere on your machine, not necessary in the directory you build the library.

2. Can you show the exact command you use to compile you code?
3. Did you build the library from the Terminal or from the Xcode?
4. I presume that you did install wx in /usr/local, by specifying the "--prefix=" option to configure. Am I right?

Also, keep in mind that you will have to create a bundle in order to test the code. See how the sample does it (all commands after successful compilation) and when the code compiles do the same.

It might even be better (beneficial) to just copy you code over to the minimal sample folder, rename the minimal.cpp, rename you own source to minimal.cpp, compile and run. At the very least it will help to know if the code works.

Also notice that you don't have to install the library on you Mac. You can simply work with library from the directory you compiled it using "./wx-config"


Thank you.
Kiithsjet
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Mar 14, 2016 1:20 am

Re: mac/wxwidgets g++ compiling rage

Post by Kiithsjet »

The command I used is:

Code: Select all

$ make
clang++ -I/Users/myUser/widgetDir/wxWidgets-3.1.0/buildMac/lib/wx/include/osx_cocoa-unicode-static-3.1 -I/Users/myUser/widgetDir/wxWidgets-3.1.0/include -D_FILE_OFFSET_BITS=64 -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__  

-o myExec wxHello.cpp 

-L/Users/myUser/widgetDir/wxWidgets-3.1.0/buildMac/lib   -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL /Users/myUser/widgetDir/wxWidgets-3.1.0/buildMac/lib/libwx_osx_cocoau_xrc-3.1.a /Users/myUser/widgetDir/wxWidgets-3.1.0/buildMac/lib/libwx_osx_cocoau_qa-3.1.a /Users/myUser/widgetDir/wxWidgets-3.1.0/buildMac/lib/libwx_baseu_net-3.1.a /Users/myUser/widgetDir/wxWidgets-3.1.0/buildMac/lib/libwx_osx_cocoau_html-3.1.a /Users/myUser/widgetDir/wxWidgets-3.1.0/buildMac/lib/libwx_osx_cocoau_adv-3.1.a /Users/myUser/widgetDir/wxWidgets-3.1.0/buildMac/lib/libwx_osx_cocoau_core-3.1.a /Users/myUser/widgetDir/wxWidgets-3.1.0/buildMac/lib/libwx_baseu_xml-3.1.a /Users/myUser/widgetDir/wxWidgets-3.1.0/buildMac/lib/libwx_baseu-3.1.a -lpng -ljpeg -framework WebKit -lexpat -lwxregexu-3.1 -lwxtiff-3.1 -lz -lpthread -liconv -llzma
In file included from wxHello.cpp:3:
In file included from /Users/myUser/widgetDir/wxWidgets-3.1.0/include/wx/wx.h:15:
In file included from /Users/myUser/widgetDir/wxWidgets-3.1.0/include/wx/object.h:19:
In file included from /Users/myUser/widgetDir/wxWidgets-3.1.0/include/wx/memory.h:15:
In file included from /Users/myUser/widgetDir/wxWidgets-3.1.0/include/wx/string.h:37:
/Users/myUser/widgetDir/wxWidgets-3.1.0/include/wx/strvararg.h:27:18: fatal error: 'tr1/type_traits' file not found
        #include <tr1/type_traits>
                 ^
1 error generated.
make: *** [default] Error 1
And I get the same "tr1/type_traits file not found" error regardless of using g++, clang++, the linking flags from ./wx-config within the wxwidgets directory, the linking flags from wx-config outside of the wx-widgets directory, or any paired-combination of the four.
I didn't use the prefix option, and I'm not using Xcode, just the command line.
I don't know much about bundle creation, I assumed I could just create an executable.
And sorry if this is becoming a pain in the ass.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: mac/wxwidgets g++ compiling rage

Post by ONEEYEMAN »

Hi,
No, it does not. That's why people are here - to help others. ;-)

OK, now lets, do the following:

Still in Terminal, go to wxWidgets/buildMac/samples/minimal and type "make". If it says "Nothing to do, do "make clean" first.

Last time we tried it you said it finished successfully. So now you should be able to see what options is being used when the sample is building.

Compare the output with whatever you posted on you reply. See if there any discrepancies.

Report here if you either find any or not.

Thank you.
lpsmith
In need of some credit
In need of some credit
Posts: 1
Joined: Tue Apr 19, 2016 11:43 pm

Re: mac/wxwidgets g++ compiling rage

Post by lpsmith »

For what it's worth, we have a longstanding project that also uses wxwidgets, and which is also running into this same error, when compiling on macOS 10.10. The situation is the same: wxwidgets 3.1.0 compiles fine (3.0.2 didn't), and creates a working wx-config. I didn't install it anywhere; it's still sitting in ~/wxWidgets-3.1.0/build/

When building the program that links to it, however, I (eventually) get:


g++ -DHAVE_CONFIG_H -I. -I.. -I./config -DLAMARC_COMPILE_MACOSX -DNDEBUG -O3 -funroll-loops -Wall -Wextra -Wno-unused -I ./config -I ../config -I ../src/bayeslike -I ../src/control -I ../src/conversion -I ../src/convErr -I ../src/convModel -I ../src/convParse -I ../src/convStrings -I ../src/convUtil -I ../src/datalike -I ../src/force -I ../src/guiconv -I ../src/guiutil -I ../src/lamarcmenus -I ../src/menu -I ../src/postlike -I ../src/report -I ../src/tools -I ../src/tree -I ../src/ui_interface -I ../src/ui_util -I ../src/ui_vars -I ../src/xml -I ../boost -I ../resources -I ../tinyxml -I/Users/lpsmith/wxWidgets-3.1.0/build/lib/wx/include/osx_cocoa-unicode-3.1 -I/Users/lpsmith/wxWidgets-3.1.0/include -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__ -DTIXML_USE_STL -MT lam_conv-gc_errhandling.o -MD -MP -MF .deps/lam_conv-gc_errhandling.Tpo -c -o lam_conv-gc_errhandling.o `test -f 'src/convErr/gc_errhandling.cpp' || echo '../'`src/convErr/gc_errhandling.cpp
In file included from ../src/convErr/gc_errhandling.cpp:13:
In file included from ../src/convErr/gc_errhandling.h:15:
In file included from /Users/lpsmith/wxWidgets-3.1.0/include/wx/string.h:37:
/Users/lpsmith/wxWidgets-3.1.0/include/wx/strvararg.h:27:18: fatal error: 'tr1/type_traits' file not found
#include <tr1/type_traits>
^

This general setup has worked in the past with older versions of MacOSX, and with older versions of wxWidgets (I think the last time we got it working was with 3.0.0, perhaps with 10.9?)

Any insights would be appreciated!
Post Reply