tags:

views:

17

answers:

0

How do I get the following process to work.

I create a blank new XCode project with a Console target. If I build and debug it now, it prints "Hello World".

I add a new target to my project - I want a dynamic library. Add a .c file that contains at least some function so that building the dylib project produces an output file. I right click on the "TestConsole" target, choose GetInfo, under Direct Dependencies I add "plugin" and under Linked Libraries I add "plugin.dylib". Build and run - it still works.

I right click on the "Plugin" project, choose Get Info and on the Build tab, under Per-Configuration Build Products path I add a /Plugins. I close that screen, click on the TestConsole target and check the "Link Binary with Libraries" folder - it lists the full path to plugin.dylib in the plugin folder. Looking good.

I hit build and get the following error message:

"i686-apple-darwin10-gcc-4.2.1: /Volumes/data/Code/TestDylib/build/Debug/plugin.dylib: No such file or directory Command /Developer/usr/bin/gcc-4.2 failed with exit code 1"

I've seen advice to use otool from the command line, but I can't help but feel there must be a way to do this from inside the XCode ide. What is the correct (least effort) way to get XCode to build executables and dylibs in seperate folders and still link them?


Note: It is important to delete the build folder using Finder between tests otherwise old versions of the plugin dylib are picked up and linked.