[Bug] g++4.6 参数顺序

遇到一个bug, 看起来像是g++-4.6的问题。 问题是这样的。这个源文件用到了OpenCV: //< file: test.cpp #include int main (int argc, char** argv) { cv::Mat image; return 0; } 用这样一行命令编译: g++-4.6 `pkg-config --libs opencv` -o test.bin test.cpp 遇到了错误: /tmp/ccs2MlQz.o: In function `cv::Mat::~Mat()': test.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)' /tmp/ccs2MlQz.o: In function `cv::Mat::release()': test.cpp:(.text._ZN2cv3Mat7releaseEv[cv::Mat::release()]+0x47): undefined reference to `cv::Mat::deallocate()' collect2: ld returned 1 exit status 错误的原因应该是g++没有正确的链接到OpenCV的库。各种尝试之后发现只要调换一下参数的位置就可以正常编译 -_-!! 改用这样一行命令编译就没有问题了。 […]