Creating a WXWidgets template in XCode

128 views
Skip to first unread message

Tim Burgess

unread,
Jan 11, 2011, 8:50:19 AM1/11/11
to wx-u...@googlegroups.com

Hi,

 

I've been trying to follow the article at:

 

http://wiki.wxwidgets.org/Creating_Xcode_projects_for_wxWidgets_applications#Creating_the_project_and_its_files

 

However, I've got the latest XCode and it doesn't seem to have a CPP Carbon template available - is this something that I can remedy (how?) and, if not, what's my best way forward to develop WX projects using XCode?  

 

Best wishes.

 

Tim Burgess

Raised Bar Ltd

Phone:  +44 (0)1827 719822

 

Don't forget to vote for improved access to music and music technology at

 

http://www.raisedbar.net/petition.htm

 

KT

unread,
Jan 11, 2011, 11:49:31 AM1/11/11
to wx-users
On Jan 11, 8:50 am, "Tim Burgess" <t...@raisedbar.net> wrote:
> Hi,
>
> I've been trying to follow the article at:
>
> http://wiki.wxwidgets.org/Creating_Xcode_projects_for_wxWidgets_appli...
> #Creating_the_project_and_its_files
>
> However, I've got the latest XCode and it doesn't seem to have a CPP Carbon
> template available - is this something that I can remedy (how?) and, if not,
> what's my best way forward to develop WX projects using XCode?  

If it helps at all, I've always just made a copy of minimal.xcodeproj
and worked from that.

M Gagnon

unread,
Jan 11, 2011, 2:32:48 PM1/11/11
to wx-u...@googlegroups.com
Hi Tim,

as the article mentions, any app bundle target will do, so you can use the cocoa one.

-- Auria

"Tim Burgess" <t...@raisedbar.net> Jan 11 01:50PM ^
       
      Hi,
       

       
      I've been trying to follow the article at:
       

       

      #Creating_the_project_and_its_files
       

       
      However, I've got the latest XCode and it doesn't seem to have a CPP Carbon
      template available - is this something that I can remedy (how?) and, if not,
      what's my best way forward to develop WX projects using XCode?
       

       

    Tim

    unread,
    Jan 11, 2011, 11:56:09 PM1/11/11
    to wx-u...@googlegroups.com
    Hi Tim B,

    Apple appears to be encouraging people to move toward Cocoa and stop using Carbon.  wxCocoa is in pretty good shape so I've stopped using wxCarbon a few months ago.

    Here's how I build the library:

    # Build the library for Cocoa
    rm -rf build-cocoa-debug
    mkdir build-cocoa-debug
    cd build-cocoa-debug
    ../configure --enable-unicode --enable-debug --disable-shared --with-osx_cocoa
    make;cd ..
    # Build the samples and demos
    cd build-cocoa-debug/samples; make;cd ../..
    cd build-cocoa-debug/demos;   make;cd ../..

    # Use Finder to run some of the samples to prove to yourself they work

    # Then copy one of the samples to your own directory and compile it like this

      Create an empty directory
      Add the source code files *.h, *.cpp, etc.
      You may also need sample.xpm if it is included in your main .cpp file
      Start XCode
      File, New Project...
      Application, Cocoa Application
      Next
      Set Project Name
      Set Project Directory to be the directory with the source code files.
      Finish
      The project window should appear
      Highlight main.m and delete it
      Change the configuration from "Release" to "Debug"
      Project, Add To Project...
      Highlight all of the .cpp files in the directory
      Add, Add
      Open a terminal window
        cd wx/build-cocoa-debug
        ./wx-config --cxxflags   
        ./wx-config --libs
        It is critical that you use ./wx-config not wx-config in those two lines.
        You will copy the output of those two lines into Xcode in the next steps.
      Go back to Xcode
      Click the "info" icon (blue circle with white i)
      Choose the "Build" tab
      Set the Configuration to "Debug"
      Set Show to "All Settings"
      In the Linking section,
        Uncheck ZeroLink
        Set Other Linker Flags to the output of --libs from the terminal window
      In the GCC Code Generation Section
        Uncheck Inline Methods Hidden
        Uncheck Symbols Hidden by Default
        Set Other C Flags to the output of --cxxflags from the terminal window
      In the Packaging section
        Set Product Name to a suitable name
      Close the configuration window
      Return to the project window
      Click Build and Go icon (green circle with hammer)

    Thanks,

    Tim G
     


    From: M Gagnon <auri...@gmail.com>
    To: wx-u...@googlegroups.com
    Sent: Tue, January 11, 2011 11:32:48 AM
    Subject: Re: Creating a WXWidgets template in XCode
    --
    Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
     
    To unsubscribe, send email to wx-users+u...@googlegroups.com
    or visit http://groups.google.com/group/wx-users

    Tim

    unread,
    Jan 12, 2011, 2:58:19 AM1/12/11
    to wx-u...@googlegroups.com
    Hi,

    On Mac OS X and on Windows XP, I noticed that the compiler and linker flags for the samples are insufficient to use wxXmlDocument.  

    Steps to recreate:
       1) Use wx trunk
       2) Compile the library
       3) Compile samples/config
       4) Edit samples/config/conftest.cpp to add these two lines
           a) #include <wx/xml/xml.h>
           b) wxXmlDocument doc;
       5) Try to recompile
       6) See linker errors for missing symbol wxXmlDocument.

    This can be fixed on Mac OS X by changing the makefile so that these additional flags are used during link:  "-lwx_baseu_xml-2.9  -lexpat"

    There appears to be a similar set of flags missing for Windows XP Visual Studio because it also stops with unresolved external symbols.

    Was this done intentionally, i.e. avoiding using the XML features in the samples?  If wxXmlDocument was added to samples with the correct libraries, would that break something else?

    An older message says don't use wxXmlDocument
      http://tech.groups.yahoo.com/group/vtp/message/4410
    but my setup.h contracts that message with this line
      setup.h has this line:    #define wxUSE_XML 1

    Thanks,

    Tim


    Tim Burgess

    unread,
    Jan 12, 2011, 3:57:33 AM1/12/11
    to wx-u...@googlegroups.com

    OK, I saw that but was made unsure by the lack of the template being referenced, so wanted to check.  I'm new to programming on the Mac and very rusty with c++/c anyway, so I'm doing baby steps and trying to check before I end up in a mess.  Thanks for the response.

     

    Best wishes.

     

    Tim Burgess

    Raised Bar Ltd

    Phone:  +44 (0)1827 719822

     

    Don't forget to vote for improved access to music and music technology at

     

    http://www.raisedbar.net/petition.htm

     

    From: wx-u...@googlegroups.com [mailto:wx-u...@googlegroups.com] On Behalf Of M Gagnon
    Sent: 11 January 2011 19:33
    To: wx-u...@googlegroups.com
    Subject: Re: Creating a WXWidgets template in XCode

     

    Hi Tim,

    --

    Tim Burgess

    unread,
    Jan 12, 2011, 4:00:11 AM1/12/11
    to wx-u...@googlegroups.com

    Many thanks for this - it's much appreciated.  I'll get busy:)

     

    Best wishes.

     

    Tim Burgess

    Raised Bar Ltd

    Phone:  +44 (0)1827 719822

     

    Don't forget to vote for improved access to music and music technology at

     

    http://www.raisedbar.net/petition.htm

     

    Tim Burgess

    unread,
    Jan 12, 2011, 6:20:54 AM1/12/11
    to wx-u...@googlegroups.com

    OK,

     

    I appear to be making some progress, but I’ve got a couple of queries so far with this method:

     

    1 – I get a warning when I make the libraries:

     

    ld: warning: in /System/Library/Frameworks//QuickTime.framework/QuickTime, missing required architecture x86_64 in file      

    SetFile -t APPL wxrc                                                                                                         

     

    I’m developing a MIDI application, so I don’t think that QuickTime is relevant to me, but I could be wrong.  Any advice appreciated on this.

     

    2 – The instructions tell me to:

     

      Click the "info" icon (blue circle with white i)

     

    I should point out that I’m a blind programmer using the built-in VoiceOver speech output to perform these steps.  I can’t get VoiceOver to identify this icon, so can I get to the same place via a menu, or sub-menu from any other item, please?  If not, I’ll have to try and find some sighted help.

    Best wishes.

     

    Tim Burgess

    Raised Bar Ltd

    Phone:  +44 (0)1827 719822

     

    Don't forget to vote for improved access to music and music technology at

     

    http://www.raisedbar.net/petition.htm

     

    From: wx-u...@googlegroups.com [mailto:wx-u...@googlegroups.com] On Behalf Of Tim


    Sent: 12 January 2011 04:56
    To: wx-u...@googlegroups.com

    Tim Burgess

    unread,
    Jan 12, 2011, 7:21:32 AM1/12/11
    to wx-u...@googlegroups.com

    Ok, belay some of what I’ve just submitted.  With respect to the second point, I’ve found a way of interacting with a toolbar to then click on the Info icon.  I’m now trying to figure out how to get text into the flags and product name fields within the settings table, as a copy/paste from a TextEdit window just yields a sound effect.  Just to say that when I ran the ./wx-config commands to generate the flags and libs references, I piped them into text files so that I could try and copy/paste, but it doesn’t appear to work.  Might be another VoiceOver trick that I’m missing.

     

    Best wishes.

     

    Tim Burgess

    Raised Bar Ltd

    Phone:  +44 (0)1827 719822

     

    Don't forget to vote for improved access to music and music technology at

     

    http://www.raisedbar.net/petition.htm

     

    Vadim Zeitlin

    unread,
    Jan 12, 2011, 7:42:13 AM1/12/11
    to wx-u...@googlegroups.com
    On Tue, 11 Jan 2011 23:58:19 -0800 (PST) Tim <tim9...@yahoo.com> wrote:

    T> On Mac OS X and on Windows XP, I noticed that the compiler and linker flags for
    T> the samples are insufficient to use wxXmlDocument.

    That's because it's in a separate library which the samples that don't
    need it don't use.

    T> Steps to recreate:
    T> 1) Use wx trunk
    T> 2) Compile the library
    T> 3) Compile samples/config
    T> 4) Edit samples/config/conftest.cpp to add these two lines
    T> a) #include <wx/xml/xml.h>
    T> b) wxXmlDocument doc;
    T> 5) Try to recompile
    T> 6) See linker errors for missing symbol wxXmlDocument.

    You'd get the same problem if you added something non-core (e.g. wxGrid
    which is in adv library) to the minimal sample.

    T> Was this done intentionally, i.e. avoiding using the XML features in the
    T> samples?

    Yes. The samples that need it should mention "xml" in the list of
    libraries they use in their .bkl file.

    Regards,
    VZ

    --
    TT-Solutions: wxWidgets consultancy and technical support
    http://www.tt-solutions.com/

    Tim Burgess

    unread,
    Jan 12, 2011, 12:02:45 PM1/12/11
    to wx-u...@googlegroups.com

    Hi Tim,

     

    I’ve now been able to put the libs and flags entries into the build configuration within Xcode – it would seem that you have to click on the edit field before you can enter anything into it.  I set my product name to MDRLite (I assume I didn’t have to specify .app) and attempted to build and run, but got a failure.  Since I still haven’t been able to locate the ZeroLink setting, I’m wondering if I’m using a more up-to-date version of Xcode than you and this setting has been removed or renamed.  My version is 3.2.5.  I get 1 build error, G++ 4.2 failed with error code 1.

     

    Best wishes.

     

    Tim Burgess

    Raised Bar Ltd

    Phone:  +44 (0)1827 719822

     

    Don't forget to vote for improved access to music and music technology at

     

    http://www.raisedbar.net/petition.htm

     

    From: wx-u...@googlegroups.com [mailto:wx-u...@googlegroups.com] On Behalf Of Tim


    Sent: 12 January 2011 04:56
    To: wx-u...@googlegroups.com

    iko...@earthlink.net

    unread,
    Jan 12, 2011, 1:41:37 PM1/12/11
    to wx-u...@googlegroups.com
    Tim,
    What error message you are receiving?

    Thank you.

    Tim

    unread,
    Jan 12, 2011, 11:09:21 PM1/12/11
    to wx-u...@googlegroups.com
    Hi Tim B,

    Some answers to your questions:

    I get the same warning and I ignore it:  ld: warning: in /System/Library/Frameworks//QuickTime.framework/QuickTime, missing required architecture x86_64 in file SetFile -t APPL htlbox

    Here's how to hit the blue circle with white i:
       File, Get Info
    It provides info about the highlighted file in the left column.  I think if you highlight the first item in the left column, which is your project name, and then click File, Get Info, you'll always get the right info page.  If you highlight one of your .cpp files, you'll get a different info page.

    Piping the output of wx-config to a file works fine:
       ./wx-config --libs > libfile.txt
    The tricky part is to use the correct wx-config executable.  You must be in your build-cocoa-debug directory and you must have the dot before wx-config.  If you just run wx-config from just anywhere, you will get the version from /usr/bin which is the one Apple installed on your computer, and that is not the one you want.

    Filling in fields in the build configuration:
       Yes I have to click once to select the line and a second time to select the field.
       If you double-click you'll get a new dialog box that separates each parameter on a separate line, but you can't paste into that one easily so I don't double-click

    Zerolink
       This setting has disappeared.  I think it was obsoleted a while back and they finally removed it from the UI.

    Version:  I have 3.2.5, the same as you.

    Build Error G++ 4.2
       You should click Build, Build Results and it will give you more details.

    Thanks,

    Tim G

    Tim

    unread,
    Jan 12, 2011, 11:14:48 PM1/12/11
    to wx-u...@googlegroups.com
    Hi Tim B,

    Sounds like you already found it, but the Build and Go icon (green circle with hammer) is equivalent to clicking Build, Build and Debug.   The keyboard shortcut is to hold down the Apple button and hit enter.

    Tim G.


    From: Tim <tim9...@yahoo.com>
    To: wx-u...@googlegroups.com
    Sent: Wed, January 12, 2011 8:09:21 PM

    Tim Burgess

    unread,
    Jan 20, 2011, 5:57:37 PM1/20/11
    to wx-u...@googlegroups.com

    Hi,

     

    Sorry for the delay in reporting back on this – life got in the way.

     

    I reported earlier that I’d bilt my skeleton project, but got an error.  Here it is:

     

    /Developer/usr/bin/g++-4.2 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -L/Users/tim/Documents/Projects/XCode/MDRLite/MDRLite/build/Debug -F/Users/tim/Documents/Projects/XCode/MDRLite/MDRLite/build/Debug -filelist /Users/tim/Documents/Projects/XCode/MDRLite/MDRLite/build/MDRLite.build/Debug/MDRLite.build/Objects-normal/x86_64/MDRLite.LinkFileList -mmacosx-version-min=10.6 L/wxwidgets-2.9.1/build-cocoa-debug/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -framework QuickTime /wxwidgets-2.9.1/build-cocoa-debug/lib/libwx_osx_cocoau_xrc-2.9.a /wxwidgets-2.9.1/build-cocoa-debug/lib/libwx_osx_cocoau_html-2.9.a /wxwidgets-2.9.1/build-cocoa-debug/lib/libwx_osx_cocoau_qa-2.9.a /wxwidgets-2.9.1/build-cocoa-debug/lib/libwx_osx_cocoau_adv-2.9.a /wxwidgets-2.9.1/build-cocoa-debug/lib/libwx_osx_cocoau_core-2.9.a /wxwidgets-2.9.1/build-cocoa-debug/lib/libwx_baseu_xml-2.9.a /wxwidgets-2.9.1/build-cocoa-debug/lib/libwx_baseu_net-2.9.a /wxwidgets-2.9.1/build-cocoa-debug/lib/libwx_baseu-2.9.a -framework WebKit -lexpat -lwxregexu-2.9 -lwxtiff-2.9 -lwxjpeg-2.9 -lwxpng-2.9 -lz -lpthread -liconv -framework Cocoa -o /Users/tim/Documents/Projects/XCode/MDRLite/MDRLite/build/Debug/MDRLite.app/Contents/MacOS/MDRLite

     

    i686-apple-darwin10-g++-4.2.1: L/wxwidgets-2.9.1/build-cocoa-debug/lib: No such file or directory

    Command /Developer/usr/bin/g++-4.2 failed with exit code 1

     

    I suspect the culprit is the “-L” before the /wxwidgets-2.9.1… in the library path.  This character pair appeared when I piped the output from ./wx-config –libs to a text file.  I spotted it at the time and was curious (I get the same for cxxflags) – should it be there, or this an artifact of some sort?

     

    Thanks for any help.

     

    Best wishes.

     

    Tim Burgess

    Raised Bar Ltd

    Phone:  +44 (0)1827 719822

     

    Don't forget to vote for improved access to music and music technology at

     

    http://www.raisedbar.net/petition.htm

     

    From: wx-u...@googlegroups.com [mailto:wx-u...@googlegroups.com] On Behalf Of Tim


    Sent: 12 January 2011 04:56
    To: wx-u...@googlegroups.com

    Tim

    unread,
    Jan 20, 2011, 8:31:35 PM1/20/11
    to wx-u...@googlegroups.com
    Hi Tim B,

    You lost the first hyphen when you copied the output of ./wx-config --libs.

    It should be -L/wxwidgets-2.9.1/build-cocoa-debug/lib
    and you only have
    L/wxwidgets-2.9.1/build-cocoa-debug/lib

    -L (upper case) indicates to the linker where to find the libraries : example -L/wxwidgets
    -l (lower case) indicates to the linker which library to load: example -lwxjpeg

    Since you have no hyphen, the linker looks for the file L/wxwidgets and hence the error message cannot find file L/wxwidgets.

    Tim G



    From: Tim Burgess <t...@raisedbar.net>
    To: wx-u...@googlegroups.com
    Sent: Thu, January 20, 2011 2:57:37 PM
    Subject: RE: Creating a WXWidgets template in XCode

    Tim Burgess

    unread,
    Jan 21, 2011, 4:41:20 AM1/21/11
    to wx-u...@googlegroups.com

    OK, so XCode needs the -L, even though you're providing the actual path in a field designed to specify additional link libraries?  Should there be a space between the /L and the /wxwidgets...?

    Tim Burgess

    unread,
    Jan 21, 2011, 6:51:13 AM1/21/11
    to wx-u...@googlegroups.com

    Hi,

     

    I’m now up and running.  The lack of the hyphen was one thing, but I also fell foul of having an additional blank entry after pasting in the library flags data.  Re-reading the web article pinned it down and I now having a working skeleton project.

     

    Many thanks for all the help on this.  Now I’m off to read about creating WX dialogs and list boxes.

     

    Best wishes.

     

    Tim Burgess

    Raised Bar Ltd

    Phone:  +44 (0)1827 719822

     

    Don't forget to vote for improved access to music and music technology at

     

    http://www.raisedbar.net/petition.htm

     

    From: wx-u...@googlegroups.com [mailto:wx-u...@googlegroups.com] On Behalf Of Tim


    Sent: 21 January 2011 01:32

    Reply all
    Reply to author
    Forward
    0 new messages