Skip to content

linking to libopensift from C++ #17

@sprock

Description

@sprock

Hello,
I'm attempting to call libopensift from C++ and running into linker
errors:

clang++ -g -I/opt/OpenSIFT/include -I/usr/local/include/opencv
-I/usr/local/include -I/usr/local/include -I/usr/local/include/glib-2.0
-I/usr/local/lib/glib-2.0/include -I/usr/local/include/libxml2
-I/usr/local/include/libgsf-1 -I/usr/local/include/GraphicsMagick
-I/usr/local/include/orc-0.4 -I/usr/local/include/OpenEXR
-I/usr/local/include/poppler/glib -I/usr/local/include/cairo
-I/usr/local/include/pixman-1 -I/usr/local/include/freetype2
-I/usr/local/include/libdrm -pthread -D_THREAD_SAFE
-I/usr/local/include/libpng16 -I/usr/local/include/poppler
-I/usr/local/include/librsvg-2.0 -I/usr/local/include/gdk-pixbuf-2.0
-pthread -I/usr/local/include/pango-1.0 -I/usr/local/include/harfbuzz
-c Mosaic.cxx -o mosaic.o

clang++ -L/usr/local/lib -lvips-cpp -lvips -lgobject-2.0 -lglib-2.0
-lintl -L/usr/local/lib -lopencv_calib3d -lopencv_contrib -lopencv_core
-lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui
-lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree
-lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching
-lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab -ltbb
-lpthread -lm -L/opt/OpenSIFT/lib -lopensift -o mosaic mosaic.o

mosaic.o: In function dem(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)': /home/rmason/Programming/C/VipsMosaic2/Mosaic.cxx:383: undefined reference to sift_features(_IplImage*, feature**)'
/home/rmason/Programming/C/VipsMosaic2/Mosaic.cxx:384: undefined reference to sift_features(_IplImage*, feature**)' /home/rmason/Programming/C/VipsMosaic2/Mosaic.cxx:389: undefined reference to kdtree_bbf_knn(kd_node*, feature*, int, feature***, int)'
/home/rmason/Programming/C/VipsMosaic2/Mosaic.cxx:392: undefined reference to descr_dist_sq(feature*, feature*)' /home/rmason/Programming/C/VipsMosaic2/Mosaic.cxx:393: undefined reference to descr_dist_sq(feature*, feature*)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

I've tried various versions of the link line, modified sift.h to declare
sift_features extern "C", but to no avail.

If you have suggestions on how to link C++ against libsift I would be
most grateful to hear them.

Thanks,
Roger
FreeBSD 10.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions