Xcode compile switches

Discussion in 'Mac Programming' started by farmerdoug, Mar 5, 2010.

  1. farmerdoug macrumors 6502a

    Joined:
    Sep 16, 2008
    #1
    I looked for a way to add a switch to Xcode compile instructions but couldn't find out if it could be done. Can it? How?
     
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    Project -> Edit Active Target -> Add User Defined Settings
     
  3. farmerdoug thread starter macrumors 6502a

    Joined:
    Sep 16, 2008
    #3
    Where do I add this.

    "-arch i386" ?

    Instead of shooting the younger trespassers, you might want to consider selling them.

    thanks
     
  4. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #4
    Did you look at that window? It is the second line down - in the Architectures subsection oddly enough.
     
  5. farmerdoug thread starter macrumors 6502a

    Joined:
    Sep 16, 2008
    #5
    found it.
    both i386 and x86_64 are there. My problem may lie else where.
    Thanks
     
  6. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #6
    What is your problem?

    A guess based on what you have said suggests that you are trying to link against a library which not compiled for a specific architecture. Because it appears that you are compiling your app for i386 and x86_64 you need all the libraries that the app links against to built for the same architectures as well.

    Of course I might be wrong as you haven't said anything at all but its a hunch.
     
  7. farmerdoug thread starter macrumors 6502a

    Joined:
    Sep 16, 2008
    #7
    In another post, I talked about not being able to link my cfitsio (an external) lib in Xcode. NASA suggested the flags which it turns out are already there.
     
  8. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #8
    It sounds exactly like the problem I mentioned above then. You have built the library as either i386 or x86_64 but not both and are building your application for both targets resulting in a compile error.
     
  9. farmerdoug thread starter macrumors 6502a

    Joined:
    Sep 16, 2008
    #9
    I tried eliminating onne then the other, it didn't help. Here is what my makefile uses.


    CC = gcc
    CFLAGS = -Wall -g
    IDIR = /cfitsio/include
    LIBS = -lm
    CFITSIOLIB = /cfitsio/lib/libcfitsio.a
     
  10. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #10
    What is that makefile for? Is it for the cfitsio library, or for the program that uses the cfitsio library?


    Does your Xcode project perform a build using a makefile, or does it build using Xcode's builtin rules?

    An Xcode project that's built using a makefile will not use anything from Target Settings.


    I have no clear sense of what tool (Xcode, make) you're using to build each of your components. If you could clarify which component is being built with what tool, it might help others to help you. Otherwise all anyone can do is guess at what you're doing.
     
  11. farmerdoug thread starter macrumors 6502a

    Joined:
    Sep 16, 2008
    #11
    Here is an example of a make file that I use.

    Code:
    CC = gcc
    CFLAGS = -Wall  -g 
    IDIR = /cfitsio/include
    LIBS = -lm
    CFITSIOLIB = /cfitsio/lib/libcfitsio.a
    OBJS = matrix.o
    
    clean:
    		rm -f ${OBJS} ${EXECS}
    
    EXECS	= 	getline2
    
    OBJS	= 	getline2.o 
    
    getline2:	getline2.c
    		${CC} -DMAIN ${CFLAGS}  -I${IDIR}  p1640.h  getline2.c  ${CFITSIOLIB}  ${LIBS}  -o getline2
    
    all:		${EXECS} ${OBJS}
    
    
    
    I have no idea what Xcode uses. It compiles but does not link the library. The make file does.
     
  12. farmerdoug thread starter macrumors 6502a

    Joined:
    Sep 16, 2008
    #12
    switches in Xcode

    Where would switches like these -DMEMWATCH -NMEMWATHCH_STUDIO be put in Xcode?
    Thanks.
     
  13. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #13
    Same place you'd put any other compiler settings: in the appropriate place having double clicked on the target.
     
  14. farmerdoug thread starter macrumors 6502a

    Joined:
    Sep 16, 2008
    #14
    That much I figured out but I don't know where in that window to put it.
     
  15. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #15
    Well, what have you tried? I'm not on my Mac right now so can't look at the available options but iirc it's pretty obvious. 2 seconds with Google suggests that "Other C Flags" might be a good starting place...
     
  16. farmerdoug thread starter macrumors 6502a

    Joined:
    Sep 16, 2008
    #16
    Do you mean OTHER_CODE_SIGN_FLAGS =
    I was looking for CFlags but didn't find it.
    Will try.
     
  17. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #17
    No. Given the name I would guess that OTHER_CODE_SIGN_FLAGS is for code signing. Which is not what you are doing.

    As I said: I'm not on a Mac and don't have access to XCode right now. Did you try reading the XCode documentation? I'm pretty sure it covers this. Also did you search on Google before asking this? If so what did you search for?

    Edit: OTHER_CFLAGS is in the Build Settings List You may have to add it as a user-defined setting:

    [​IMG]
     
  18. farmerdoug thread starter macrumors 6502a

    Joined:
    Sep 16, 2008
    #18
    To be honest, I don't remember. I may have a few days ago. I find the Xcode documentation very difficult to find anything in. Sometimes its just easier to ask someone who knows.
     
  19. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #19
    I don't know this: I found all this out using a very small amount of time and Google.
     

Share This Page