views:

1166

answers:

2

I'm trying to use libtidy for an iPhone app (since the iPhone 2.2 SDK doesn't include NSXMLDocument which has tidy functionality) but I get a linker error saying "library not found for -ltidy" when I build the app.

As for other framework/library references, I've added the libtidy.dylib to my list of referenced frameworks and I've added the associated libtidy header files to the path listed in my Header Search Paths build setting. Xcode seems to automatically add the -ltidy linker option when I build the app yet it still complains that it can't find the associated libtidy.dylib file even though I can see it on the file system in the specified path and listed in the framework references.

Has anyone else had a similar problem when adding a reference to libtidy in Xcode? I'm using Xcode 3.1.2 with iPhone SDK 2.2.1.

A: 

Is it part of the iPhone OS? If not, you can't add it -- new dylibs are not allowed. You should get the source and build a .a and use that instead if that's the case.

Lou Franco
The libtidy.dylib seems to be part of the iPhone SDK as I can find it in the .../SDKs/iPhoneOS2.2.1.sdk/usr/lib directory but the associated headers aren't in the usr/include directory so I'm not sure what this means.
Oliver GL
I didn't have XCode in front of me, so couldn't check -- was just trying to suggest something to look for.
Lou Franco
I've resorted to just adding the libtidy source directly into the project for now. Will look at creating static libraries for the Intel and ARM builds later.
Oliver GL
+2  A: 

It's a pretty big oversight, but the only way to fix this problem is by manually coping these two files:

/Developer/SDKs/MacOSX10.5.sdk/usr/lib/libtidy.dylib
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/libtidy.A.dylib

...into the different Simulator directories:

/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/usr/lib/
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.1.sdk/usr/lib/
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.sdk/usr/lib/
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/usr/lib/

Not sure why they weren't there in the first place. You can do this from a Terminal:

for directory in $( echo /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator*.sdk/usr/lib/ ); do
  sudo cp /Developer/SDKs/MacOSX10.5.sdk/usr/lib/libtidy.* $directory
done;
Nathan de Vries
I'd use ln instead of cp (saves some space :)
porneL