That is definitely the incorrect way to do it; linking options must be before targets. As for dependencies inside the libraries themselves - that's why I kept the order given in the Code::Blocks file. I messed with it some more besides after looking for the dependencies inside of OpenCV but I didn't have much luck. The .hpp probably shouldn't be in the compiler invocation, but I really wanted to use $^. It makes no difference.