문제

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?

도움이 되었습니까?

해결책 2

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top