Ubuntu library distribution
I’m 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()
Oddly enough, dispatch_main() is declared in the header file I included, and I call other functions declared in that header file, and the compiler can recognize them. Only dispatch_main() it doesn’t see, and if I call dispatch_main(2) it says too many arguments, so I know the compiler can see the header.
I tried separating the compile and linking steps (clang -c…) because it worked for the undefined reference error before, but it doesn’t seem to be doing anything here….
Does anyone have any suggestions? I’m confused about this….
Solution
Sounds like a library is missing in your link line. When compiling the program into an executable file, add the library to the command. I guess it should look like this :
clang x.c y.c z.c -ldispatch