-
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.
-
> #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
-
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
-
Figured it out. Apparently I needed to reload the linker config file because I didn't install cvd using a package manager:
$ sudo ldconfig