WaddleDee72
WaddleDee72

Reputation: 63

Integrating wxWidgets into Existing XCode Project

There are many tutorials about setting up a new XCode project for use with wxWidgets, but I need to integrate it with a large existing XCode C++ project.

The wxWidgets setup process is unclear to me. I built wxWidgets in XCode with the included wxcocoa.xcodeproj file. But when I include all the header files and the libwx_osx_cocoa.dylib library to my existing XCode project, I get all these errors within the wxWidgets header files like Use of undeclared identifier 'wxApp' and No matching constructor for initialization of 'wxEvent' as if it's missing files, but I've included all the header files and compiled library. I tried building wxWidgets in the terminal and get the same errors. I tried make install to actually install wxWidgets on my system. I tried running this command wx-config --cxxflags --libs all in the terminal. I tried adding wx-config --cxxflags and wx-config --libs all to the compiler and linker flags in my XCode project. None of these had any effect.

The irony is that I'm trying to use wxWidgets library to make the GUI process easier, but instead I've spent two days pulling my hair out trying to get my C++ XCode project to compile. Does anyone know what I'm doing wrong?

EDIT: The problem seems to be XCode. I've downloaded the wxWidgets Hello World sample program at the bottom of this page. I can build this program without issue in the terminal, but when I put it into a new XCode project, it won't build. How can I get XCode to build this simple program?

cx-config output: cx-config output

XCode project settings: Linked Libraries

C++ Flags

Header Search Paths

EDIT 2: I exported the Build Log out of XCode and saw that the actual build command uses clang. When I successfully compile Hello World in the terminal, I use clang++. When I try the same command with clang, it doesn't work. Perhaps this is the issue, since clang only links C libraries and the errors XCode is giving me relate to not being able to find standard C++ functions.

EDIT 3: Wow I hate XCode. I got my Hello World program to compile by accident. The solution was putting the wxWidgets compiler flags in the Targets Build Settings, whereas before, I had it in the Project Build Settings. I assumed the Targets would inherit the Project settings, but I guess not! Compiler Flags

EDIT 4: I got my complicated XCode project to compile with the wxWidgets libraries by taking all the search paths & flags and moving them from the Project Build Settings to the Targets Build Settings. What a nightmare! Glad it's over

Upvotes: 0

Views: 418

Answers (1)

Igor
Igor

Reputation: 6255

@WaddleDee72

, I suggest doing following:

  1. Delete wxWidgets directory.
  2. Unpack wxWidgets into i.e. ~/wxWidgets.
  3. Open Terminal.
  4. In the Terminal

4a. cd ~/wxWidgets

4b. mkdir buildOSX

4c. cd buildOSX

4d. ../configure --enable-debug

4e. make -j5

After successful build

  1. wx-config --cxxflags
  2. wx-config --libs

Use the output of 2 commands above and put the values where they belong in XCode project.

If you get any issues - let us know.

Thank you.

Upvotes: 1

Related Questions