Manually linking app

Hi,

I'm getting a linker error:

/usr/bin/c++ -o app -g -O0 -Wall -Wpointer-arith -L/opt/local/lib osx.o -lpthread

Undefined symbols for architecture x86_64:

"_CFRunLoopAddSource", referenced from: osx.o

"_CFRunLoopGetCurrent", referenced from: osx.o

"_CFRunLoopRemoveSource", referenced from: osx.o

ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [madchat] Error 1

I can't find where in the documentation the name of the library I must include in the linker command.

Is there a reference somewhere that details WHICH .lib or .a file a function comes from?

Thank you

Replies

Those symbols come from the CoreFoundation framework.

IMPORTANT This is a framework, not a library, so you’ll need to link to it using -framework.

I can't find where in the documentation the name of the library I must include in the linker command.

A good way to work this out is to search the documentation for the symbol and then look at the breadcrumb trail at the top to find the framework. In this case, the documentation page for CFRunLoopGetCurrent is here and the breadcrumb trail is Documentation > Core Foundation > CFRunLoop > CFRunLoopGetCurrent.

Alternatively, and honestly this is my preferred option, create a dummy project in Xcode, use the symbol there, build your project, and then look at the build log to see what it did.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thank you, eskimo

Where is the build-log located? It doesn't seem to create one in the project's home folder

Try this:

  1. Choose View > Navigators > Reports.

  2. Build your project.

  3. On the left, select the most newly created build.

  4. At the top right, click Export; this will prompt you to save the build transcript as a text file.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"