can't link with libcvd

This is a discussion on can't link with libcvd within the C++ Programming forums, part of the General Programming Boards category; I'm a new C++ programmer coming from a Java background. I'm trying to compile a simple test program using libcvd ...

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    3

    can't link with libcvd

    I'm a new C++ programmer coming from a Java background.

    I'm trying to compile a simple test program using libcvd (which I compiled from source), but the linker is giving me an error which I can't figure out how to diagnose:

    Code:
    $ g++ -Wall -g -o testes test.cpp
    /tmp/ccxE5wTV.o: In function `void CVD::Internal::aligned_free<unsigned char>(unsigned char*, unsigned long)':
    /usr/local/include/cvd/internal/aligned_mem.h:109: undefined reference to `CVD::Internal::aligned_free(void*)'
    collect2: error: ld returned 1 exit status
    Here is the test code I'm using:

    test.cpp
    Code:
    #include <cvd/image_io.h>
    using namespace CVD;
    
    int main()
    {          
      try
      {
        Image<byte> in;
    
    
    //    in = img_load("test_image.jpg");
    //    img_save(in, "new_image.png");
      
      }
      catch(Exceptions::All error)
      {
        std::cerr << "Error: " << error.what << std::endl;
      }
      return 0;
    }
    removing all the try/catch and commented junk still gives the same result.

    help is greatly appreciated.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    > #include <cvd/image_io.h>
    Where did you install cvd?

    As well as the .h file(s), you should also have a file like say libcvd.a
    The .h file just describes the interface, and the .a file is the compiled implementation.

    $ g++ -Wall -g -o testes test.cpp -L/path/to/library -lcvd
    Where the full path to the library file is /path/to/library/libcvd.a
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    3
    cvd is installed in /usr/local/lib, and the header is in /usr/local/include I believe.

    I just ran:
    Code:
    $ g++ -Wall -g -o testes test.cpp -L/usr/local/lib -lcvd
    with no errors (thanks!!). But if I run the generated file I get an error:

    Code:
    $ ./testes 
    ./testes: error while loading shared libraries: libcvd.so.0: cannot open shared object file: No such file or directory

  4. #4
    Registered User
    Join Date
    Jan 2013
    Posts
    3
    Figured it out. Apparently I needed to reload the linker config file because I didn't install cvd using a package manager:

    $ sudo ldconfig

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Where should I link?
    By fighter92 in forum C++ Programming
    Replies: 1
    Last Post: 01-22-2007, 11:06 AM
  2. Link .lib
    By fiff in forum Windows Programming
    Replies: 8
    Last Post: 12-28-2006, 02:48 PM
  3. Do you have the link
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-21-2003, 01:46 PM
  4. link in C
    By SuperNewbie in forum C Programming
    Replies: 1
    Last Post: 07-15-2002, 02:36 PM
  5. Link
    By CFRK in forum C Programming
    Replies: 1
    Last Post: 11-29-2001, 09:17 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21