Search code examples
c++cmakefilegist

Lear Gist Descriptor C code used with C++


I am using Lear's implementation of the Gist descriptor for a project which can be found here: http://lear.inrialpes.fr/software.

I am writing an application in c++ and I want to use this library. I am having issues though with the makefile and linking in general.

These commands give me no errors:

g++ -c standalone_image.c -o standalone_image.o
g++ -c gist.c -o gist.o

However, this line

g++ compute_gist.c `pkg-config --cflags --libs opencv`

gives me the following error

Undefined symbols for architecture x86_64:
  "color_gist_scaletab(color_image_t*, int, int, int const*)", referenced from:
      _main in ccMFYbAU.o
  "color_image_delete(color_image_t*)", referenced from:
      _main in ccMFYbAU.o
  "color_image_new(int, int)", referenced from:
      load_ppm(char const*)in ccMFYbAU.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

I have the Mosaic c++ code in a different directory. I also tried to compile gist and standalone_image seperately, copy into the mosaic directory, and compile the Mosaic code. Which gives me the following error:

Undefined symbols for architecture x86_64:
  "color_gist_scaletab(color_image_t*, int, int, int const*)", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [mosaic] Error 1

I really want to use this library in my project, but I can't figure out a way to incorporate it in my c++.

Any help is GREATLY appreciated! Thanks!

Edit: I am using Mac Lion with:

gcc + g++ version: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)

The lear library also uses the FFTW3 library that should work with C and C++.


Solution

  • The problem was that I needed the extern around the gist include, but the linking that was done in the Makefile was also wrong. It works now. :)