Question

I am trying to build an application in Xcode 3.2.4 and am getting the following linker error:

Undefined symbols:
  "___block_global_1", referenced from:
      ___block_holder_tmp_1.120 in foobarbaz.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

I'm at a loss to explain what I've done in my source file that might be causing the error. I do have a block that I am defining as a global variable, like so:

typedef void(^error_block_t)(NSError* error);

error_block_t error_handler_s = ^void(NSError* error)
{
    //...
}

This block is defined in an empty namespace in the source (I'm compiling Objective-C++.) Everything compiles without error.

Update: Moving the block to be a local variable for the routine that references it is a viable (though not preferred) workaround.

What gives?

Was it helpful?

Solution 2

At this point I believe this issue to be a bug.

OTHER TIPS

If the error_handler_s is not intended to be exported, you could make it static as another workaround.

namespace {
  ...
  static error_block_t error_handler_s = ^void(NSError* error) { ... };
  ...
}

Otherwise, I believe this is a bug in gcc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top