ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  How to link chartdirector in Xcode on MacOSX
Posted by Morris Moore on Jan-16-2011 04:53
I am on Snow Lep and trying to link dylibs into project.

I have dragged the dylibs into xcode and set a
Runpath Search Path to @executable_path/../Frameworks

Next Compile and it succeeds but when I run I get
[Switching to process 2154]
Running?
dyld: Library not loaded: libchartdir.5.dylib
  Referenced from: /Users/mmoore/Documents/Programming/MacOSX/TestApps/DocBasedTestChartDir/build/Debug/DocBasedTestChartDir.app/Contents/MacOS/DocBasedTestChartDir
  Reason: image not found
sharedlibrary apply-load-rules all
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Cannot call into the loader at present, it is locked.)
(gdb)

Do the examples run from xcode or do you need to buy a developer license to link with xcode.

  Re: How to link chartdirector in Xcode on MacOSX
Posted by Peter Kwan on Jan-17-2011 20:44
Hi Morris,

The ChartDirector libchartdir.5.dylib is just a standard dylib, and can be used in xcode just like any other dylib.

The error message you see means the compiler can find libchartdir.5.dylib (that's why you can compile the code), but the OS cannot find the libchartdir.5.dylib when executing the code.

For the Mac OS X to find a dylib (this is not specific to ChartDirector, but to all dylib), you may need to do one of the followings:

(A) Put the dylib in a directory that would be searched by the system (such as "/usr/lib")

(B) Put the dylib in any directory you like, and use install_name_tool to configure your executable to use the dylib in that directory.

(C) Put the dylib in a directory in the runpath search path, and link the dylib as a run-path dependent library.

Since you mentioned you are using Runpath Search Path, have you "put the dylib in a directory in the runpath search path"? Note that XCode will not do this for you. You would need to do it yourself or by adding a new build phase to ask XCode to put the file in the correct location.

Also, your Runpath Search Path is configured as "@executable_path/../Frameworks". Are you sure where is it when your code is run in XCode? Note that XCode will create a "build" subdirectory and put copies of the executable in some subdirectories inside the "build" subdirectory. When you run the code in XCode, XCode will use the copies inside the "build" subdirectory. So the "@executable_path" refers to a subdirectory deep inside the "build" subdirectory, which is not the applicable bundle put in your project directory.

Finally, have you linked the dylib as a run-path dependent library? XCode by default will not link any library as a run-path dependent library. You must explicitly configure it to do so. See http://developer.apple.com/library/mac/#DOCUMENTATION/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/RunpathDependentLibraries.html

If you are not familiar with how to use "Runpath Search Path", for testing, you may consider to use (A) (just put the libchartdir.5.dylib and libchartdir.dylib in /usr/lib). After you have made it work, you may reconfigure your project to use method (B) or (C).

Hope this can help.

Regards
Peter Kwan