Setting private framework search path in makefile

Hello,

I have a makefile that compiles using the OpenCV.framework package. This works fine if the framework is in the default framework search path, however I would like to bundle the framework with my application so that users don't need to install it. I found the -F flag for specifying additional search paths, but this doesn't seem to work.

Here is a snippet from my makefile:

# Mac OS X ifeq "$(OS)" "MacOSX"      LDFLAGS          += -framework OpenCV -arch i386      CFLAGS          += -arch i386 endif


I tried adding -F/absolute/path/to/framework and -F./relative/path/to/framework to the LDFLAGS with no success. I was able to include the framework as part of the application using XCode, but I'm just not sure how to do the same thing with make. If anyone has any idea of how to specify the framework search path in a makefile using gcc I would appreciate your help!

Thanks for your time,

-Ross

Mac Pro, Mac OS X (10.6.3)

Posted on Apr 6, 2010 4:18 AM

Reply
4 replies

Apr 6, 2010 5:42 AM in response to RossOliver

While you are building your application, use your framework from wherever it happens to live on your machine. Your application will only need to use the framework as a dynamic library while running. Add the framework to your application's resources so that it gets bundled with the application. Finally, add a new build script to run the "install nametool" to change the dynamic link path from /path/to/framework to @executable_path (I think that is correct).

If you need more out of the framework that the dynamic library, you know where it will live in your application and you can use standard NSBundle routines to find it.

Apr 6, 2010 6:29 AM in response to etresoft

Hi,

Thanks for the reply. If I am understanding your solution correctly it still poses a problem; your description is for building in the XCode environment only - is that correct? I was able to get the private framework bundled successfully this way, however I require the project to be built using a makefile. It is actually written completely in C and designed to be platform-independent. The problem is I want to ditch XCode and only use make for compilation - so I need to manually bundle the private framework with the source code and somehow set the search path during complication. I tried the -F flag during the linker stage as described here:

http://developer.apple.com/mac/library/DOCUMENTATION/Darwin/Reference/ManPages/m an1/ld.1.html

"ld maintains a list of directories to search for a library or framework to use. The default library search path is /usr/lib then /usr/local/lib. The -L option will add a new library search path. The default framework search path is /Library/Frameworks then /System/Library/Frameworks. (Note: previ-ously, previously,ously, /Network/Library/Frameworks was at the end of the default path. If you need that functionality, you need to explicitly add -F/Network/Library/Frameworks). The -F option will add a new framework search path. The -Z option will remove the standard search paths. The -syslibroot option will prepend a pre-fix prefixfix to all search paths."

I haven't been successful with this method though...

Thanks again,

-Ross

Apr 6, 2010 5:20 PM in response to RossOliver

RossOliver wrote:
If I am understanding your solution correctly it still poses a problem; your description is for building in the XCode environment only - is that correct?


No.

You can use anything you want to build it. You still have to do the same actions. Use "-framework" to build against a framework. Use "install nametool" to bind the executable to relative dynamic library path.

Apr 7, 2010 4:00 PM in response to RossOliver

Typically private frameworks are put in @executable_path/../Frameworks, so use that when you use the install nametool as Etre suggested.

Or you can just install the framework in an Apple recommended location, assuming you are going to have an installer.

http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPFramewo rks/Tasks/InstallingFrameworks.html#//apple_ref/doc/uid/20002261-BBCCFBJA

Theres nothing stopping you from doing a cp on the framework (to put it in the bundle) and running install nametool from within your Makefile btw. Do it manually once, then when you understand what's happening just add the commands to your Makefile.

Eric

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Setting private framework search path in makefile

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.