3

I am trying to port a program that uses GCD (Grand Central Dispatch) from OSX to Ubuntu 11.10. I installed libdispatch but I keep getting the following error:

 undefined reference to dispatch_main() 

The strange thing is that dispatch_main() is declared in a header file that I include and I call other functions declared in that header file and the compiler recognizes them. It is only dispatch_main() that it cannot see and if I call dispatch_main(2) it says that there are too many arguments, so I know the compiler can see the header.

I tried separating the compile and link steps (clang -c...) since that worked for an undefined reference error before, but it doesn't seem to do anything here...

Anybody have any suggestions? I'm pretty stumped on this one...

syzygy
  • 1,356
  • 3
  • 16
  • 28

1 Answers1

4

It sounds like you are missing the library from your link line. When you compile your program into an executable, add the library to the command. I am guessing it should look something like this:

clang x.c y.c z.c -ldispatch
jxh
  • 69,070
  • 8
  • 110
  • 193
  • Actually, now everything is compiling, but dispatch_main() causes the program to stall. The other dispatch commands appear to be working. Any idea what might be missing? (Maybe this should be on its own question?) – syzygy Jul 15 '13 at 19:03
  • @Ganesha1024: Yeah, it's a different question. I don't actually use grand central dispatch myself. – jxh Jul 15 '13 at 19:57
  • Ok thanks. We actually just figured it out (it's supposed to stall, and we are supposed to start another thread to toss stuff onto the dispatch queue). Cheers, amigo – syzygy Jul 15 '13 at 20:01