Compile error : undefined reference to‘__atomic_fetch_add_4’

前端 未结 3 407
广开言路
广开言路 2021-01-19 14:52
#include 
using namespace cv;

int main()
{
  Mat img=imread(\"cornea.jpg\");
  imshow(\"src\",img);
  waitKey(0);
  return 0;
}

相关标签:
3条回答
  • 2021-01-19 15:16

    You may need to link with atomic library. Try with

    -latomic

    in your GCC compilation command line.

    NOTE: i had to do it compiling with CLang 8 on a ARMv7 device (Android).

    0 讨论(0)
  • 2021-01-19 15:29

    You seem to be mixing Debug and Release versions of the OpenCV libraries. https://github.com/Itseez/opencv/issues/5581 You should only include and link against the normal Release library, or againt a Debug library you built yourself.

    In your case, this may come from the double include -cflags -I /usr/local/include/opencv. I would try remove all the manual paths and just write pkg-config --cflags --libs opencv (to the packaged Release version).

    Note that /usr/local/include is a standard include path and will always be searched. You could try to exclude standard paths with -nostdinc https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html

    Another option is to uninstall one of the two versions, or remove one version away from the standard paths.

    0 讨论(0)
  • 2021-01-19 15:34

    On i386, you need to add -latomic as GCC cannot use assembler instructions but has to fallback on the libatomic library implementation.

    Starting with i586, atomic instructions are available and linking against libatomic is no longer required. That means, the alternative of -latomic is to use -march=i586.

    0 讨论(0)
提交回复
热议问题