liuliu / ccv

C-based/Cached/Core Computer Vision Library, A Modern Computer Vision Library
http://libccv.org
Other
7.1k stars 1.71k forks source link

Linker fails on ubuntu #215

Closed nithinivi closed 5 years ago

nithinivi commented 5 years ago

I am using Ubuntu 16.04 , I was trying to compile using clang -L"~/ccv/lib" -I"~/ccv/lib" test.c -lccv for

#include <ccv.h

int main(int argc, char** argv)
{
  ccv_dense_matrix_t* image = 0;
  ccv_read(argv[1], &image, CCV_IO_GRAY | CCV_IO_ANY_FILE);
  return 0;
}

I got the following build error

_ /usr/bin/../lib/gcc/x86_64-linux-gnu/5.5.0/../../../libccv.a(ccv_io.o): In function _ccv_write_jpeg_fd': ccv_io.c:(.text+0x188e): undefined reference tojpeg_CreateCompress' ccv_io.c:(.text+0x1898): undefined reference to jpeg_std_error' ccv_io.c:(.text+0x18b4): undefined reference tojpeg_stdio_dest' ccv_io.c:(.text+0x1917): undefined reference to jpeg_set_defaults' ccv_io.c:(.text+0x1940): undefined reference tojpeg_set_quality' ccv_io.c:(.text+0x1952): undefined reference to jpeg_start_compress' ccv_io.c:(.text+0x198c): undefined reference tojpeg_write_scanlines' ccv_io.c:(.text+0x19ab): undefined reference to jpeg_finish_compress' ccv_io.c:(.text+0x19b3): undefined reference tojpeg_destroy_compress' /usr/bin/../lib/gcc/x86_64-linux-gnu/5.5.0/../../../libccv.a(ccv_io.o): In function _ccv_write_png_fd': ccv_io.c:(.text+0x19f4): undefined reference topng_create_write_struct' ccv_io.c:(.text+0x1a03): undefined reference to png_create_info_struct' ccv_io.c:(.text+0x1a22): undefined reference topng_init_io' ccv_io.c:(.text+0x1a42): undefined reference to png_set_compression_mem_level' ccv_io.c:(.text+0x1a54): undefined reference topng_set_filter' ccv_io.c:(.text+0x1a62): undefined reference to png_set_compression_level' ccv_io.c:(.text+0x1a71): undefined reference topng_set_compression_mem_level' ccv_io.c:(.text+0x1a7f): undefined reference to png_set_compression_strategy' ccv_io.c:(.text+0x1ad6): undefined reference topng_set_IHDR' ccv_io.c:(.text+0x1ba2): undefined reference to png_write_info' ccv_io.c:(.text+0x1bae): undefined reference topng_write_image' ccv_io.c:(.text+0x1bbb): undefined reference to png_write_end' ccv_io.c:(.text+0x1bc8): undefined reference topng_destroy_write_struct' /usr/bin/../lib/gcc/x86_64-linux-gnu/5.5.0/../../../libccv.a(ccv_io.o): In function _ccv_read_jpeg_fd': ccv_io.c:(.text+0x1c00): undefined reference tojpeg_std_error' ccv_io.c:(.text+0x1c49): undefined reference to jpeg_CreateDecompress' ccv_io.c:(.text+0x1c54): undefined reference tojpeg_stdio_src' ccv_io.c:(.text+0x1c61): undefined reference to jpeg_read_header' ccv_io.c:(.text+0x2048): undefined reference tojpeg_alloc_huff_table' ccv_io.c:(.text+0x2153): undefined reference to jpeg_start_decompress' ccv_io.c:(.text+0x21dc): undefined reference tojpeg_read_scanlines' ccv_io.c:(.text+0x22cc): undefined reference to jpeg_read_scanlines' ccv_io.c:(.text+0x233c): undefined reference tojpeg_read_scanlines' ccv_io.c:(.text+0x239c): undefined reference to jpeg_read_scanlines' ccv_io.c:(.text+0x24cc): undefined reference tojpeg_read_scanlines' /usr/bin/../lib/gcc/x86_64-linux-gnu/5.5.0/../../../libccv.a(ccv_io.o):ccv_io.c:(.text+0x2561): more undefined references to jpeg_read_scanlines' follow /usr/bin/../lib/gcc/x86_64-linux-gnu/5.5.0/../../../libccv.a(ccv_io.o): In function_ccv_read_jpeg_fd': ccv_io.c:(.text+0x2608): undefined reference to jpeg_finish_decompress' ccv_io.c:(.text+0x2610): undefined reference tojpeg_destroy_decompress' /usr/bin/../lib/gcc/x86_64-linux-gnu/5.5.0/../../../libccv.a(ccv_io.o): In function _ccv_read_png_fd': ccv_io.c:(.text+0x2656): undefined reference topng_create_read_struct' ccv_io.c:(.text+0x2665): undefined reference to png_create_info_struct' ccv_io.c:(.text+0x2684): undefined reference topng_init_io' ccv_io.c:(.text+0x2691): undefined reference to png_read_info' ccv_io.c:(.text+0x26cc): undefined reference topng_get_IHDR' ccv_io.c:(.text+0x270e): undefined reference to png_set_strip_16' ccv_io.c:(.text+0x2717): undefined reference topng_set_strip_alpha' ccv_io.c:(.text+0x2728): undefined reference to png_set_palette_to_rgb' ccv_io.c:(.text+0x273e): undefined reference topng_set_expand_gray_1_2_4_to_8' ccv_io.c:(.text+0x275a): undefined reference to png_set_gray_to_rgb' ccv_io.c:(.text+0x2776): undefined reference topng_set_rgb_to_gray' ccv_io.c:(.text+0x2783): undefined reference to png_read_update_info' ccv_io.c:(.text+0x2877): undefined reference topng_read_image' ccv_io.c:(.text+0x2882): undefined reference to png_read_end' ccv_io.c:(.text+0x28e7): undefined reference topng_destroy_readstruct' clang: error: linker command failed with exit code 1 (use -v to see invocation)

Thanks in advance for the time.

liuliu commented 5 years ago

It seems you compiled the library with libjpeg and libpng but when create the binary, didn't link to it (passing -ljpeg -lpng). You can check the flag you used to compile the library in lib/config.mk file.