August 7, 2012 0

linker error when using pkg-config

By in c++, C++, Eclipse, gcc

If you are not able to link with a library that is specified via pkg-config then make sure your pkg-config flag is placed in the end of the compiler/linker command

eg:

g++ -o "OpenCV2.3Test"  ./main.o `pkg-config --libs opencv`

instead of
g++ `pkg-config --libs opencv` -o "OpenCV2.3Test"  ./main.o

In Eclipse this is done by going to project properties -> CCC C++ Linker and change the order of the command line pattern so that flags are last, eg.:

${COMMAND} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} ${FLAGS}

Tags: , ,


Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/mgis.dk/about/wp-includes/class-wp-comment-query.php on line 399

Leave a Reply