Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 5, 2012, 03:35 PM   #1
cfshelor
macrumors newbie
 
Join Date: Nov 2011
-ll linker flag not working

Hello everyone! I am a casual Xcode user, mostly version 3, but switched to version 4 in December. I am taking a compiler writing course and our initial homework uses lex and yacc.

From a terminal window I can compile the lex output file and execute it using:

gcc lex.yy.c -ll

The gcc being used is from: /Developer/usr/bin and is version

i686-apple-darwin11-llvm-gcc-4.2

Putting the same file into an Xcode project and trying to compile it returns an Apple Mach-O Linker (ld) Error:
ld: library not found for -ll
Command /Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1

I added the -ll link flag in the "Linking" area of the "Build Settings" under the "Other Linker Flags" option line and see it getting included in the gcc command line. I tried using both LLVM GCC 4.2 and Apple LLVM compiler 3.0 as the selected compiler in the "Build Options->Compiler" field. I also tried using -llibl rather than -ll, but that did not work either.

I really want to be able to use Xcode for the assignments later in the course so I don't have to work directly with gdb. Any suggestions as to how to get Xcode to locate the lex and yacc libraries will be greatly appreciated!!!
cfshelor is offline   0 Reply With Quote
Old Feb 5, 2012, 03:54 PM   #2
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
Instead of trying to add an explicit library flag, try telling XCode to link to the library instead.
  1. Remove the -ll from Other Linker Flags
  2. Click on the project node at the top of the project navigator
  3. Click on your target in the project editor
  4. Click on the Build Phases tab
  5. Expand Link Binary With Libraries
  6. Click the + button at the bottom of Link Binary With Libraries
  7. Click the Add Other button
  8. Press Shift+Command+G
  9. Enter /usr/lib and click the Go button
  10. Select libl.a
  11. Click the Open button

Notice that it's not libl.a that actually gets linked in, it's libfl.a. This is because libl.a is a symlink to libfl.a. You've not actually been using lex, but the rewritten and extended flex.
jiminaus is offline   0 Reply With Quote
Old Feb 7, 2012, 02:35 PM   #3
cfshelor
Thread Starter
macrumors newbie
 
Join Date: Nov 2011
Perfect!

Thanks for your help jiminaus! It worked perfectly and this should also help with OpenMP and OpenMPI library issues I had been having as well after switching to Xcode 4.x.
cfshelor is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Mach-O Linker Error: Duplicate Symbols moonman239 iPhone/iPad Programming 5 Oct 21, 2013 09:08 PM
Linker command failed with exit code 1 adildacoolset iPhone/iPad Programming 2 Feb 15, 2013 06:00 AM
Linker Command Failed Error, Please Help loon3y iPhone/iPad Programming 2 Sep 26, 2012 05:20 PM
Linker Command Failed With Exit Code 1? loon3y iPhone/iPad Programming 2 Sep 5, 2012 06:10 PM

Forum Jump

All times are GMT -5. The time now is 02:04 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC