xcode4: Linker error: Directory not found for opti

2019-01-21 15:56发布

问题:

I'm getting this error for my profile build (debug build was OK).

{Directory not found for option '-L../../../Mac/Profile/lib [full path of that directory]

Library not found for -lMyLib}

When I check the path, the directory exists and the lib file libMyLib.a exists as well. My library search path for the Profile build includes that directory $(SRCROOT)/../../../Mac/Profile/lib. I also made sure that the library was built under profile setting.

This only happens with profile build.

I'd really love to have some help although it may well be a no-brainer question.

Thank you!

EDIT: Found the solution myself Solved the problem: In my linker path, there were two directory entries. The second one was surrounded by double quotes while the first one wasn't. Xcode4 seems to have concatenated them into a single directory entry and apparently that was garbage. After I removed the quotation marks, the linker error was gone.

回答1:

Go to "Get Info" on the target. Click the "Build Settings" tab (i'm using Xcode4), and scroll down to "Search Paths", Where You delete all the values in "Library Search Paths".

Hope that helps...



回答2:

There are two errors that people seem to have confused

If it is a "directory not found for option '-L/..." That means it's a Library Error, and you might want to try:

  • Click on your project (targets)
  • Click on Build Settings
  • Under Library Search Paths, delete the paths

If it is a "directory not found for option '-F/..." That means it's a Framework Error, and you might want to try:

  • Click on your project (targets)
  • Click on Build Settings
  • Under Framework Search Paths, delete the paths

This might happen when you move referenced files around or change the project folder name.



回答3:

It was similar as above in the Library Search Paths. I found that one of my paths was missing quotes around it...

// Old path
$(PROJECT_DIR)/Google Analytics

// New path
"$(PROJECT_DIR)/Google Analytics"


回答4:

I came across this error in seemingly a completely different scenario from those answers above. Hopefully some people will do what I did and find this useful even if it is a rare occurence.

I managed to get this error after having just added a new viewController to my project. As normal I added a tableview and constrained it then added and linked the delegate and datasource. I also created a property.

The weird thing that I then noticed was that as soon as I finished creating the property it was immediately linked, as if I had linked it, but before I linked it. When I clicked on the xib file and checked the links it wasn't in fact linked to the table view.

(This link appeared automatically without me needing to create it myself)

I don't know why this happened. I deleted the file and remade it with the same name but it just happened again. Giving me this error above.

The way I solved it was to create a new file, different name, and added and created the links in a different order checking at each step that this hadn't occurred. After doing this no linked created themselves and it worked.

TL DR: If you are getting this error and have recently added new view controller then check if deleting it works and if so they remake it being careful about any automatic links.