Specifying .framework search path in Makefile

Discussion in 'Mac Programming' started by RossOliver, Apr 14, 2010.

  1. RossOliver macrumors regular

    Joined:
    Nov 6, 2006
    #1
    Hello,

    I am trying to compile my C program that uses the OpenCV.framework using a Makefile. If I put the OpenCV.framework in the default framework search paths (/Library/Frameworks or /System/Library/Frameworks) and use the -framework OpenCV ld flag then everything works perfectly. However, I want to compile and link from the framework in a specific directory - say /my/Frameworks, for instance. I've tried adding -F/my/Frameworks to the ld flags, but this doesn't seem to have any effect at all.

    If anyone can help me out I would appreciate it :)

    Thanks for your time,

    -Ross
     
  2. mslide macrumors 6502a

    Joined:
    Sep 17, 2007
    #2
    That's how I've done it in the past with C++ code, Makefiles and g++ version 4.0+. For example, my final link command would be something like:

    Code:
    g++ -o program_name foo.o bar.o blah.o -F/my/frameworks -framework MyFramework
    
    It would be more helpful if you could post the exact link command your Makefile is trying to execute. The only other tip I can offer is to take the Makefile out of the picture and try to get the link command right, manually, on the command line. Then work on how to get the Makefile to do the same thing.

    BTW, are you putting the -framework <my framework name> argument after the -F/my/frameworks argument and not before it? -framework needs to go after -F.
     
  3. RossOliver thread starter macrumors regular

    Joined:
    Nov 6, 2006
    #3
    Thanks for your reply - I've converted my makefile to a long-winded gcc call and seem to have gotten a step closer, but I get lots of warnings (the list goes on but I had to shorten it for the word limit in this box):

    Code:
    Ross-Computer:source_code Ross$ gcc -arch i386 -lm -Wall -g -Ilib -Itest -Ilib/CuTest -Ilib/GetOpt -g -std=c99 main.c gmque.c gmutil.c sm.c smbg.c smcon.c cm.c cmmod.c test/tm.c test/tm_gmque.c test/tm_gmutil.c test/tm_smcon.c test/tm_cmmod.c lib/CuTest/CuTest.c lib/GetOpt/getopt.c -o sm -F/Users/Ross/Desktop/Test -framework OpenCV -framework Carbon -framework OpenGL -framework GLUT
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:238: warning: ‘cvFloor’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:253: warning: ‘cvCeil’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:270: warning: ‘cvIsNaN’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:285: warning: ‘cvIsInf’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:304: warning: ‘cvRNG’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:320: warning: ‘cvRandReal’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:622: warning: ‘cvMat’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:652: warning: ‘cvmGet’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:670: warning: ‘cvmSet’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:687: warning: ‘cvCvToIplDepth’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:862: warning: ‘cvRectToROI’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:875: warning: ‘cvROIToRect’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:896: warning: ‘cvTermCriteria’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:918: warning: ‘cvPoint’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:948: warning: ‘cvPointTo32f’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:973: warning: ‘cvPoint3D32f’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:993: warning: ‘cvPoint2D64f’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:1013: warning: ‘cvPoint3D64f’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:1034: warning: ‘cvSize’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:1052: warning: ‘cvSize2D32f’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:1128: warning: ‘cvRealScalar’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:1136: warning: ‘cvScalarAll’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:1648: warning: ‘cvAttrList’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:152: warning: ‘cvDecRefData’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:173: warning: ‘cvIncRefData’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:207: warning: ‘cvGetRow’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:218: warning: ‘cvGetCol’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:247: warning: ‘cvReleaseMatND’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:270: warning: ‘cvGetNextSparseNode’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:521: warning: ‘cvSubS’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:1074: warning: ‘cvCloneSeq’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:1117: warning: ‘cvSetNew’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:1132: warning: ‘cvSetRemoveByPtr’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:1147: warning: ‘cvGetSetElem’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:1314: warning: ‘cvEllipseBox’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:1404: warning: ‘cvFont’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:1662: warning: ‘cvReadIntByName’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:1677: warning: ‘cvReadRealByName’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:1691: warning: ‘cvReadStringByName’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxcore.h:1703: warning: ‘cvReadByName’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cv.h:630: warning: ‘cvCreateSubdivDelaunay2D’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cv.h:665: warning: ‘cvSubdiv2DNextEdge’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cv.h:671: warning: ‘cvSubdiv2DRotateEdge’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cv.h:676: warning: ‘cvSubdiv2DSymEdge’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cv.h:681: warning: ‘cvSubdiv2DGetEdge’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cv.h:689: warning: ‘cvSubdiv2DEdgeOrg’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cv.h:696: warning: ‘cvSubdiv2DEdgeDst’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cv.h:703: warning: ‘cvTriangleArea’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cv.h:887: warning: ‘cvCalcHist’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cv.h:1097: warning: ‘cvSURFPoint’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cv.h:1131: warning: ‘cvStarKeypoint’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cv.h:1155: warning: ‘cvStarDetectorParams’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cvaux.h:262: warning: ‘icvSqDist2D32f’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cvaux.h:861: warning: ‘cv3dTracker2dTrackedObject’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cvaux.h:875: warning: ‘cv3dTrackerTrackedObject’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cvaux.h:1180: warning: ‘cvReleaseBGStatModel’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cvaux.h:1187: warning: ‘cvUpdateBGStatModel’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:238: warning: ‘cvFloor’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:253: warning: ‘cvCeil’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:270: warning: ‘cvIsNaN’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:285: warning: ‘cvIsInf’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:304: warning: ‘cvRNG’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:320: warning: ‘cvRandReal’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:622: warning: ‘cvMat’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:652: warning: ‘cvmGet’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:670: warning: ‘cvmSet’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:687: warning: ‘cvCvToIplDepth’ defined but not used
    /Users/Ross/Desktop/Test/OpenCV.framework/Headers/cxtypes.h:862: warning: ‘cvRectToROI’ defined but not used
    ...
    
    Also, I notice when I run the executable (which does seem to compile despite these warnings) I get:

    Code:
    dyld: Library not loaded: @executable_path/../Frameworks/OpenCV.framework/Versions/A/OpenCV
      Referenced from: /Users/Ross/Documents/...path_to.../source_code/./sm
      Reason: image not found
    Trace/BPT trap
    
    If I move the OpenCV.framework to where it expects it to be (executable_path/../Frameworks) then it executes perfectly. However, I would like it to look in the /Users/Ross/Desktop/Test folder instead...).

    Many thanks,

    -Ross
     
  4. RossOliver thread starter macrumors regular

    Joined:
    Nov 6, 2006
    #4
    Never mind - just had to use the install_name_tool on the framework to get the path right:

    Code:
    install_name_tool -id @executable_path/lib/MacOSX/OpenCV.framework/OpenCV "/path-to/OpenCV.framework/OpenCV"
    
    Hopefully I can put the gcc command back into the Makefile and it will still work :)

    Thanks for your help!

    -Ross
     

Share This Page