Why won't Xcode even try compiling my .cpp files??

Member
Posts: 48
Joined: 2011.03
Post: #1
Hi.. I'm really confused. I have a number of .cpp files in an Xcode project. Some of the will attempt to compile - others will not.

I keep getting unresolved references at link time for the simple reason that Xcode is not even trying to compile a number of my .cpp files. I know they have errors in them but the compiler has made no attempt whatsoever to compile them.

I added them to my project using Add->Existing Files.. and they now live under the Classes group/folder.

Can somebody please tell me why Xcode won't even attempt to compile my files? They are all in the same folder too.

Cheers
Sparky
OK, I found the answer to my problem - it looks as though the file needs to be included under "Compile Sources" under the Targets group. I wonder why some of the files I added are in there and others aren't.. oh well..
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #2
It is somewhat comforting for me to hear that there are more people than me who find Xcode a bit confusing at times. I mean, I am not alone. Smile (It gets a lot more confusing when you go into the menus trying to debug a non-working Xcode project.)
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #3
Not sure if this is your issue, but I've ran into problems where I had to change all of my files to .mm to get them to compile as objective-c++ files, even though in my project/target settings I told it to always compile as objective-c++.
Quote this message in a reply
Member
Posts: 48
Joined: 2011.03
Post: #4
Yeah thanks guys. Jake, see the comment on my first posting at the end - that was my problem. I was lucky enough to be aware of the .mm renaming thanks to my trusty iPod 3D Programming book.

I'm just about to post another query though Ingemar.. Xcode was confusing enough - especially when I had to keep going into Edit Project Settings, changing my SDK target and then having to restart Xcode each time I made a change. This caused me serious grief when wanting to compile third-party code examples. Hehe that was Xcode 3.2.5.. Now that I've "mastered" that version (take that with a bit of humour), I can't compile my own projects on Xcode 4.. So.. I'd better switch on my Mac and submit another posting..LOL
Quote this message in a reply
Member
Posts: 48
Joined: 2011.03
Post: #5
What also doesn't help is the fact that I haven't been able to log in to the Apple Developer Forum for a number of weeks. I've raised an issue with Apple and they haven't responded. I've tried different PCs/Macs/browsers in different places (work/home etc) and I can't get past the first screen with the Login button. Actually I tell a lie - I can now get to the username/password screen but clicking the login button still takes me back to the first page. Thank goodness for thirdparty sites such as iDevGames! :-)
Quote this message in a reply
Moderator
Posts: 452
Joined: 2008.04
Post: #6
(Mar 29, 2011 11:00 AM)SparkyNZ Wrote:  Apple Developer Forum ...... I can now get to the username/password screen but clicking the login button still takes me back to the first page.

I've had that problem a few times before. I think I reset all my cookies and junk and it started working again. I may have also switched browsers.

Howling Moon Software - CrayonBall for Mac and iPhone, Contract Game Dev Work
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #7
(Mar 29, 2011 10:44 AM)SparkyNZ Wrote:  This caused me serious grief when wanting to compile third-party code examples.
Well, that's a problem of its own, and definitely not what Xcode is built to be good at. Xcode is for big projects, working a long time on one code base. Small code examples is something different. Even with Apple's own examples, I often feel that I can save time by just trashing the Xcode project (that is when it won't build, when conversion from an old version fails etc).

There is more than one need in development, different kind of problems.
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #8
(Mar 29, 2011 03:25 AM)Ingemar Wrote:  It is somewhat comforting for me to hear that there are more people than me who find Xcode a bit confusing at times. I mean, I am not alone. Smile (It gets a lot more confusing when you go into the menus trying to debug a non-working Xcode project.)

I gave up and started using make, as per many suggestions here. make was really hard for me to learn how to use, but it doesn't inexplicably refuse to work for various things like Xcode does from time to time. I can do much more complex builds now with make than I could dream of doing with Xcode (e.g. multiple fat binaries, in addition to being able to build with the same project on multiple platforms). I still use Xcode too, because I do like it (as in Stockholm syndrome "like"), but at least I am not stuck with it anymore.
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #9
(Apr 2, 2011 09:36 AM)AnotherJake Wrote:  
(Mar 29, 2011 03:25 AM)Ingemar Wrote:  It is somewhat comforting for me to hear that there are more people than me who find Xcode a bit confusing at times. I mean, I am not alone. Smile (It gets a lot more confusing when you go into the menus trying to debug a non-working Xcode project.)

I gave up and started using make, as per many suggestions here. make was really hard for me to learn how to use, but it doesn't inexplicably refuse to work for various things like Xcode does from time to time. I can do much more complex builds now with make than I could dream of doing with Xcode (e.g. multiple fat binaries, in addition to being able to build with the same project on multiple platforms). I still use Xcode too, because I do like it (as in Stockholm syndrome "like"), but at least I am not stuck with it anymore.
I can't quite agree with you on make. Well, maybe sometimes. It is OK as long as you keep the makefiles short and simple, but many makefiles are huge and twisted. I had one project, a lab for my students, which had worked for a few years. Then they upgraded the Linux in our labs, and it stopped working. I spend lots of time tracking down all the problems, until finally I gave up. The bug was somewhere in the makefile and I didn't have a chance to find it. (There is no debugger for makefiles AFAIK.)

Also, makefiles won't help you navigate to the position of the error. I can't be without that.
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #10
(Apr 3, 2011 07:06 AM)Ingemar Wrote:  (There is no debugger for makefiles AFAIK.)

You are correct, there is no debugger for makefiles. In fact, debugging a makefile can be an absolute nightmare. If I were to describe make in one word, that word would be: esoteric.

make is make. Unfortunately, it is the only good alternative to Xcode. Sometimes Xcode just doesn't work, and/or sometimes it doesn't fit the mission (e.g. cross-platform). In either of those cases you need make.

If you're dealing with a large and possibly complex makefile, the only way to beat it back into submission is just like any other code: you have to study, and sometimes study a lot. As I mentioned, I found make very difficult to learn for what I needed to do (two fat binaries for Apple platforms and one each for Linux and Windows, all in the same makefile). In addition to a wonderful example that ThemsAllTook gave me, and multiple readings of the manual and countless blogs and tutorials, I bought a book on the subject. It took me several weeks, but I finally learned enough to do what I needed.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #11
There are good alternatives; cmake if your project is a straightforward application or library, and SCons regardless of complexity. SCons is vastly nicer than Make in general terms; the downside is that it's not preinstalled anywhere.

And yes, don't hold complex makefiles against make; it's possible to write most things in GNU Make with vastly less complexity than is frequently employed :/
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #12
Oops, yeah, I forgot about SCons.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  C++ with SDL2 Framework: Loading .bmp files in same folder in XCode 5 on Mavericks exitcode 1 1,123 Feb 23, 2014 11:15 PM
Last Post: SethWillits
  Newbie problem XCode Include files BBBert 1 4,373 Mar 17, 2008 03:46 PM
Last Post: OneSadCookie
  .C cplusplus files in XCode? kelvin 2 4,019 Mar 27, 2007 04:18 PM
Last Post: OneSadCookie
  Recompiling header files in Xcode scgames 7 6,510 Jun 30, 2006 07:39 PM
Last Post: ravuya
  XCode project build options + makefiles = compiling fun! Lavareef 2 6,371 Nov 10, 2005 04:30 PM
Last Post: dair