usnistgov / NFIQ2

Optical live-scan and ink fingerprint image quality assessment tool
https://www.nist.gov/services-resources/software/development-nfiq-20
Other
129 stars 57 forks source link

Failed to link opencv using g++ on LINUX #374

Closed indianscorpion closed 10 months ago

indianscorpion commented 10 months ago

Failed to link opencv using g++ on LINUX

Trying to link the library using g++ as below, it gave tons of errors. (cmake on examples works) -lnfiq2 -lFRFXLL_static -lopencv_core -lopencv_imgproc -lopencv_ml

errors: undefined reference to `cv::softdouble::operator*(cv::softdouble const&) const'

gfiumara commented 10 months ago

If the CMake in the example works, then the issue would be in your code, no? You are likely not linking all the OpenCV libraries you need for your project.

indianscorpion commented 10 months ago

I linked all the libraries in your release package as below, which one am I missing? -lnfiq2 -lFRFXLL_static -lopencv_core -lopencv_imgproc -lopencv_ml your lib64: libFRFXLL_static.a libnfiq2.a libnfir.a libopencv_imgproc.a libopencv_ml.a libopencv_core.a libNfiq2Api.so libFRFXLL.so

gfiumara commented 10 months ago

softdouble appears to be defined in core: https://docs.opencv.org/4.6.0/d7/dcc/group__core__utils__softfloat.html#gac2116f5bce2914d578953c6ac8c0da16

indianscorpion commented 10 months ago

it is using CV_EXPORTS softdouble cos( const softdouble& a ); should I include any link options?

indianscorpion commented 10 months ago

in /usr/local/nfiq2/include/opencv4/opencv2/core/softfloat.hpp

struct softfloat; struct softdouble;

struct CV_EXPORTS softfloat { public: /* @brief Default constructor / softfloat() { v = 0; }

struct CV_EXPORTS softdouble { public: /* @brief Default constructor / softdouble() : v(0) { } /* @brief Copy constructor / softdouble( const softdouble& c) { v = c.v; }

gfiumara commented 10 months ago

It's in opencv_core. You are likely not linking in an appropriate order. This is not an NFIQ 2 issue.

$ nm -C libopencv_core.a | grep 'T cv::softdouble::operator\*'
0000000000000000 T cv::softdouble::operator*(cv::softdouble const&) const
indianscorpion commented 10 months ago

yes, the correct linking order is as below: -lnfiq2 -lFRFXLL_static -lopencv_ml -lopencv_imgproc -lopencv_core