libxml2 errors. no such file or directory

2019-04-11 23:23发布

问题:

I am having this problem with the libxml2 framework for at least 2 days. Even though there are plenty solutions on the web, none of them seem to work for me. This is what I have attempted so far.

1) Right click Frameworks and add existing Frameworks. Located the libxml2/libxml2.2 and added it into the Frameworks.

2) Clicked Projects -> Edit Project Settings and locate 2 sections: Search Paths and Linking.

3) In Search Paths I typed this in the following line: Header Search Paths: $(SDKROOT)/usr/include/libxml2

4) In Linking I typed this in the following line: Other Linker Flags: -lxml2

I have done all these steps as seen online. I am still getting errors. My Xcode version is 3.2.6. Do you think I have to re-install Xcode again and try again?

Thanks in advance!

回答1:

Header Search Paths: $(SDKROOT)/usr/include/libxml2

Other Linker Flags: -lxml2

Add libxml2.2.dylib in the Build Phases tab

If you did it exactly like this there may be an issue with your XCode, because that's all you need for XCode 4, 4.2 (I just tried just in case I was missing something), and if I recall correctly also for XCode 3.



回答2:

It seems that what solved this problem for me was making sure that XCode 4.0.2 is installed in the default Developer directory (hat tip to Melvin!)

I only needed to do the following:

  • Uninstall XCode 3.x from the default Developer folder
  • Uninstall XCode 4.0.2 from a custom folder location (it was installed at "Developer 4.0.2")
  • Restart
  • Install XCode 4.0.2 into the default Developer folder

I'm not certain that the restart was necessary but I threw it in for good measure.

My experience differs from Melvin's in that:

  • I did not need to uninstall all of my XCode 3 SDKs (I kept XCode 3.2.5 in my "Developer 3.2.5" folder)
  • I did not need to reinstall Mac OS X (I was already updated to the current version - 10.6.8 as of this writing)


回答3:

Try using this instead:

"$(SDK_DIR)"/usr/include/libxml2

Or try setting the individual target settings instead of the project-wide settings.. You can set header search paths both project-wide and for individual targets. Try doing it for the target instead if you haven't tried it. (Project -> Edit Active Target). Also make sure you set it for the current build configuration (or for all configurations)



回答4:

Ok guys, I solved this problem already partly thanks to Jano as well.

So this is what I did.

  1. Uninstalled all existing Xcode 3 SDKs
  2. Reinstall MAC OS X
  3. Update MAC OS X to 10.6.7
  4. Install Xcode 4 in the default folder (Developer)

And it is solved! The weird experiment I tried again was to install Xcode 3.2.6 only to find the same 16 errors on the libxml2.2.dylib. So Xcode 4 works, Xcode 3 failed. Therefore, time to get use to Xcode 4!