From: Ian S. <ian...@st...> - 2009-04-21 09:57:16
|
Doris, These are basic linker problems because you have not got a working makefile. In the first case, you had not linked against libvil - part of VXL; Now you are missing libpng, libjpeg, libtiff (which are provided by your distribution or VXL). There are probably other libraries you also need to link against, e.g. libz. It is unclear how you were able to build all of the other examples in VXL without errors but not add an additional one. Have you been able to run the existing examples and tests? Can I suggest that you read the VXL FAQ http://vxl.sourceforge.net/vxl-users-faq.html and the vxl-users Mailing List Policy http://vxl.sourceforge.net/vxl-users-policy.html. In particular your problems may more easily be solved by a competent local programmer than over that rather low-bandwidth channel of an mailing list. regards, Ian. Xiaowen Pan wrote: > Dear Peter, > Well, I tried both methods you provided, but got the proplem is > still there. > > Sol.1. The same as g++ test2.cpp > > Sol.2 I got even more error messages. Following are the messages: > > > # make > Linking CXX executable test2 > /usr/local/lib/libvil.a(vil_png.o): In function > `vil_png_image::get_copy_view(unsigned int, unsigned int, unsigned int, > unsigned int) const': > vil_png.cxx:(.text+0xca1): undefined reference to `png_get_image_width' > vil_png.cxx:(.text+0xe5f): undefined reference to `png_get_image_width' > /usr/local/lib/libvil.a(vil_png.o): In function > `vil_png_image::write_header()': > vil_png.cxx:(.text+0x1385): undefined reference to `png_set_write_fn' > vil_png.cxx:(.text+0x1427): undefined reference to `png_set_IHDR' > vil_png.cxx:(.text+0x1445): undefined reference to `png_write_info' > vil_png.cxx:(.text+0x1461): undefined reference to `png_set_swap' > /usr/local/lib/libvil.a(vil_png.o): In function > `vil_png_image::read_header()': > vil_png.cxx:(.text+0x1599): undefined reference to `png_sig_cmp' > vil_png.cxx:(.text+0x15e3): undefined reference to `png_set_read_fn' > vil_png.cxx:(.text+0x15fc): undefined reference to `png_set_sig_bytes' > vil_png.cxx:(.text+0x161a): undefined reference to `png_read_info' > vil_png.cxx:(.text+0x1638): undefined reference to `png_get_bit_depth' > vil_png.cxx:(.text+0x1652): undefined reference to `png_set_packing' > vil_png.cxx:(.text+0x1676): undefined reference to `png_get_channels' > vil_png.cxx:(.text+0x169a): undefined reference to `png_get_bit_depth' > vil_png.cxx:(.text+0x16b4): undefined reference to `png_set_swap' > vil_png.cxx:(.text+0x16d2): undefined reference to `png_get_image_width' > vil_png.cxx:(.text+0x16f8): undefined reference to `png_get_image_height' > vil_png.cxx:(.text+0x171e): undefined reference to `png_get_channels' > vil_png.cxx:(.text+0x1745): undefined reference to `png_get_bit_depth' > vil_png.cxx:(.text+0x1773): undefined reference to `png_get_sBIT' > vil_png.cxx:(.text+0x181a): undefined reference to `png_set_shift' > /usr/local/lib/libvil.a(vil_png.o): In function > `pngtopnm_error_handler(png_struct_def*, char const*)': > vil_png.cxx:(.text+0x1e6a): undefined reference to `png_get_error_ptr' > /usr/local/lib/libvil.a(vil_png.o): In function > `user_write_data(png_struct_def*, unsigned char*, unsigned int)': > vil_png.cxx:(.text+0x1eb9): undefined reference to `png_get_io_ptr' > /usr/local/lib/libvil.a(vil_png.o): In function > `user_read_data(png_struct_def*, unsigned char*, unsigned int)': > vil_png.cxx:(.text+0x1ef9): undefined reference to `png_get_io_ptr' > /usr/local/lib/libvil.a(vil_png.o): In function > `vil_png_file_format::make_input_image(vil_stream*)': > vil_png.cxx:(.text+0x209e): undefined reference to `png_sig_cmp' > /usr/local/lib/libvil.a(vil_png.o): In function > `vil_png_structures::alloc_image()': > vil_png.cxx:(.text._ZN18vil_png_structures11alloc_imageEv[vil_png_structures::alloc_image()]+0x67): > undefined reference to `png_get_bit_depth' > vil_png.cxx:(.text._ZN18vil_png_structures11alloc_imageEv[vil_png_structures::alloc_image()]+0xa2): > undefined reference to `png_get_color_type' > vil_png.cxx:(.text._ZN18vil_png_structures11alloc_imageEv[vil_png_structures::alloc_image()]+0xc8): > undefined reference to `png_get_color_type' > vil_png.cxx:(.text._ZN18vil_png_structures11alloc_imageEv[vil_png_structures::alloc_image()]+0xf8): > undefined reference to `png_get_color_type' > vil_png.cxx:(.text._ZN18vil_png_structures11alloc_imageEv[vil_png_structures::alloc_image()]+0x11d): > undefined reference to `png_get_image_height' > /usr/local/lib/libvil.a(vil_png.o): In function > `vil_png_structures::get_rows()': > vil_png.cxx:(.text._ZN18vil_png_structures8get_rowsEv[vil_png_structures::get_rows()]+0x7a): > undefined reference to `png_read_image' > vil_png.cxx:(.text._ZN18vil_png_structures8get_rowsEv[vil_png_structures::get_rows()]+0x92): > undefined reference to `png_read_end' > /usr/local/lib/libvil.a(vil_png.o): In function > `vil_png_structures::~vil_png_structures()': > vil_png.cxx:(.text._ZN18vil_png_structuresD1Ev[vil_png_structures::~vil_png_structures()]+0x56): > undefined reference to `png_destroy_read_struct' > vil_png.cxx:(.text._ZN18vil_png_structuresD1Ev[vil_png_structures::~vil_png_structures()]+0x70): > undefined reference to `png_write_image' > vil_png.cxx:(.text._ZN18vil_png_structuresD1Ev[vil_png_structures::~vil_png_structures()]+0x88): > undefined reference to `png_write_end' > vil_png.cxx:(.text._ZN18vil_png_structuresD1Ev[vil_png_structures::~vil_png_structures()]+0xa0): > undefined reference to `png_destroy_write_struct' > /usr/local/lib/libvil.a(vil_png.o): In function > `vil_png_structures::vil_png_structures(bool)': > vil_png.cxx:(.text._ZN18vil_png_structuresC1Eb[vil_png_structures::vil_png_structures(bool)]+0x97): > undefined reference to `png_create_read_struct' > vil_png.cxx:(.text._ZN18vil_png_structuresC1Eb[vil_png_structures::vil_png_structures(bool)]+0xc5): > undefined reference to `png_create_write_struct' > vil_png.cxx:(.text._ZN18vil_png_structuresC1Eb[vil_png_structures::vil_png_structures(bool)]+0xf3): > undefined reference to `png_create_info_struct' > vil_png.cxx:(.text._ZN18vil_png_structuresC1Eb[vil_png_structures::vil_png_structures(bool)]+0x123): > undefined reference to `png_destroy_read_struct' > /usr/local/lib/libvil.a(vil_jpeg_decompressor.o): In function > `vil_jpeg_decompressor::~vil_jpeg_decompressor()': > vil_jpeg_decompressor.cxx:(.text+0x1af): undefined reference to > `jpeg_destroy_decompress' > /usr/local/lib/libvil.a(vil_jpeg_decompressor.o): In function > `vil_jpeg_decompressor::~vil_jpeg_decompressor()': > vil_jpeg_decompressor.cxx:(.text+0x23f): undefined reference to > `jpeg_destroy_decompress' > /usr/local/lib/libvil.a(vil_jpeg_decompressor.o): In function > `vil_jpeg_decompressor::read_scanline(unsigned int)': > vil_jpeg_decompressor.cxx:(.text+0x2fa): undefined reference to > `jpeg_abort_decompress' > vil_jpeg_decompressor.cxx:(.text+0x355): undefined reference to > `jpeg_read_header' > vil_jpeg_decompressor.cxx:(.text+0x365): undefined reference to > `jpeg_start_decompress' > vil_jpeg_decompressor.cxx:(.text+0x3e1): undefined reference to > `jpeg_read_scanlines' > vil_jpeg_decompressor.cxx:(.text+0x3fb): undefined reference to > `jpeg_abort_decompress' > vil_jpeg_decompressor.cxx:(.text+0x44c): undefined reference to > `jpeg_finish_decompress' > /usr/local/lib/libvil.a(vil_jpeg_decompressor.o): In function > `vil_jpeg_decompressor::vil_jpeg_decompressor(vil_stream*)': > vil_jpeg_decompressor.cxx:(.text+0x4c1): undefined reference to > `jpeg_std_error' > vil_jpeg_decompressor.cxx:(.text+0x4ec): undefined reference to > `jpeg_CreateDecompress' > vil_jpeg_decompressor.cxx:(.text+0x540): undefined reference to > `jpeg_read_header' > vil_jpeg_decompressor.cxx:(.text+0x550): undefined reference to > `jpeg_start_decompress' > vil_jpeg_decompressor.cxx:(.text+0x560): undefined reference to > `jpeg_abort_decompress' > /usr/local/lib/libvil.a(vil_jpeg_decompressor.o): In function > `vil_jpeg_decompressor::vil_jpeg_decompressor(vil_stream*)': > vil_jpeg_decompressor.cxx:(.text+0x5b1): undefined reference to > `jpeg_std_error' > vil_jpeg_decompressor.cxx:(.text+0x5dc): undefined reference to > `jpeg_CreateDecompress' > vil_jpeg_decompressor.cxx:(.text+0x630): undefined reference to > `jpeg_read_header' > vil_jpeg_decompressor.cxx:(.text+0x640): undefined reference to > `jpeg_start_decompress' > vil_jpeg_decompressor.cxx:(.text+0x650): undefined reference to > `jpeg_abort_decompress' > /usr/local/lib/libvil.a(vil_jpeg_compressor.o): In function > `vil_jpeg_compressor::~vil_jpeg_compressor()': > vil_jpeg_compressor.cxx:(.text+0x1bc): undefined reference to > `jpeg_finish_compress' > vil_jpeg_compressor.cxx:(.text+0x1cc): undefined reference to > `jpeg_destroy_compress' > /usr/local/lib/libvil.a(vil_jpeg_compressor.o): In function > `vil_jpeg_compressor::~vil_jpeg_compressor()': > vil_jpeg_compressor.cxx:(.text+0x210): undefined reference to > `jpeg_finish_compress' > vil_jpeg_compressor.cxx:(.text+0x220): undefined reference to > `jpeg_destroy_compress' > /usr/local/lib/libvil.a(vil_jpeg_compressor.o): In function > `vil_jpeg_compressor::write_scanline(unsigned int, unsigned char const*)': > vil_jpeg_compressor.cxx:(.text+0x2ee): undefined reference to > `jpeg_set_defaults' > vil_jpeg_compressor.cxx:(.text+0x314): undefined reference to > `jpeg_set_quality' > vil_jpeg_compressor.cxx:(.text+0x331): undefined reference to > `jpeg_start_compress' > vil_jpeg_compressor.cxx:(.text+0x38c): undefined reference to > `jpeg_write_scanlines' > vil_jpeg_compressor.cxx:(.text+0x3ad): undefined reference to > `jpeg_finish_compress' > /usr/local/lib/libvil.a(vil_jpeg_compressor.o): In function > `vil_jpeg_compressor::vil_jpeg_compressor(vil_stream*)': > vil_jpeg_compressor.cxx:(.text+0x409): undefined reference to > `jpeg_std_error' > vil_jpeg_compressor.cxx:(.text+0x441): undefined reference to > `jpeg_CreateCompress' > /usr/local/lib/libvil.a(vil_jpeg_compressor.o): In function > `vil_jpeg_compressor::vil_jpeg_compressor(vil_stream*)': > vil_jpeg_compressor.cxx:(.text+0x4a7): undefined reference to > `jpeg_std_error' > vil_jpeg_compressor.cxx:(.text+0x4df): undefined reference to > `jpeg_CreateCompress' > /usr/local/lib/libvil.a(vil_tiff.o): In function > `vil_tiff_pyramid_resource::vil_tiff_pyramid_resource(tif_smart_ptr > const&, bool)': > vil_tiff.cxx:(.text+0x13c3): undefined reference to `TIFFReadDirectory' > /usr/local/lib/libvil.a(vil_tiff.o): In function > `vil_tiff_pyramid_resource::vil_tiff_pyramid_resource(tif_smart_ptr > const&, bool)': > vil_tiff.cxx:(.text+0x16ff): undefined reference to `TIFFReadDirectory' > /usr/local/lib/libvil.a(vil_tiff.o): In function `nimg(tiff*)': > vil_tiff.cxx:(.text+0x189c): undefined reference to `TIFFSetDirectory' > vil_tiff.cxx:(.text+0x18b2): undefined reference to `TIFFReadDirectory' > /usr/local/lib/libvil.a(vil_tiff.o): In function > `vil_tiff_image::write_block_to_file(unsigned int, unsigned int, > unsigned int, unsigned char*)': > vil_tiff.cxx:(.text+0x1a2e): undefined reference to `TIFFWriteEncodedTile' > vil_tiff.cxx:(.text+0x1a7a): undefined reference to `TIFFWriteEncodedStrip' > /usr/local/lib/libvil.a(vil_tiff.o): In function > `vil_tiff_image::get_block(unsigned int, unsigned int) const': > vil_tiff.cxx:(.text+0x4e9d): undefined reference to `TIFFSetDirectory' > vil_tiff.cxx:(.text+0x507e): undefined reference to `TIFFReadEncodedTile' > vil_tiff.cxx:(.text+0x5182): undefined reference to `TIFFReadEncodedStrip' > /usr/local/lib/libvil.a(vil_tiff.o): In function > `vil_tiff_pyramid_resource::get_resource(unsigned int) const': > vil_tiff.cxx:(.text+0x57da): undefined reference to `TIFFSetDirectory' > /usr/local/lib/libvil.a(vil_tiff.o): In function > `vil_tiff_pyramid_resource::put_resource(vil_smart_ptr<vil_image_resource> > const&)': > vil_tiff.cxx:(.text+0x5a6b): undefined reference to `TIFFSetField' > vil_tiff.cxx:(.text+0x5ab5): undefined reference to `TIFFSetField' > vil_tiff.cxx:(.text+0x5bb7): undefined reference to `TIFFWriteDirectory' > /usr/local/lib/libvil.a(vil_tiff.o): In function > `vil_tiff_file_format::make_pyramid_output_image(char const*)': > vil_tiff.cxx:(.text+0x5c8c): undefined reference to `TIFFOpen' > /usr/local/lib/libvil.a(vil_tiff.o): In function > `vil_tiff_file_format::make_input_pyramid_image(char const*)': > vil_tiff.cxx:(.text+0x6429): undefined reference to `TIFFOpen' > /usr/local/lib/libvil.a(vil_tiff.o): In function > `open_tiff(tif_stream_structures*, char const*)': > vil_tiff.cxx:(.text+0x660c): undefined reference to `TIFFClientOpen' > /usr/local/lib/libvil.a(vil_tiff.o): In function > `vil_tiff_file_format::make_blocked_output_image(vil_stream*, unsigned > int, unsigned int, unsigned int, unsigned int, unsigned int, > vil_pixel_format)': > vil_tiff.cxx:(.text+0x6772): undefined reference to `TIFFClose' > /usr/local/lib/libvil.a(vil_tiff.o): In function > `vil_tiff_file_format::make_input_image(vil_stream*)': > vil_tiff.cxx:(.text+0x6988): undefined reference to `TIFFClose' > /usr/local/lib/libvil.a(vil_tiff.o): In function `tif_ref_cnt::unref()': > vil_tiff.cxx:(.text._ZN11tif_ref_cnt5unrefEv[tif_ref_cnt::unref()]+0x2d): > undefined reference to `TIFFClose' > /usr/local/lib/libvil.a(vil_tiff_header.o): In function > `vil_tiff_header::n_images()': > vil_tiff_header.cxx:(.text+0xd69): undefined reference to > `TIFFNumberOfDirectories' > /usr/local/lib/libvil.a(vil_tiff_header.o): In function > `vil_tiff_header::bytes_per_tile() const': > vil_tiff_header.cxx:(.text+0xd85): undefined reference to `TIFFTileSize' > /usr/local/lib/libvil.a(vil_tiff_header.o): In function > `vil_tiff_header::actual_bytes_per_line() const': > vil_tiff_header.cxx:(.text+0xdef): undefined reference to `TIFFScanlineSize' > /usr/local/lib/libvil.a(vil_tiff_header.o): In function > `vil_tiff_header::is_GEOTIFF() const': > vil_tiff_header.cxx:(.text+0xe1f): undefined reference to `TIFFGetField' > /usr/local/lib/libvil.a(vil_tiff_header.o): In function > `read_long_tag(tiff*, unsigned int, ulong_tag&, unsigned int)': > vil_tiff_header.cxx:(.text+0xe49): undefined reference to `TIFFGetField' > /usr/local/lib/libvil.a(vil_tiff_header.o): In function > `read_short_tag(tiff*, unsigned int, ushort_tag&, unsigned short)': > vil_tiff_header.cxx:(.text+0xe92): undefined reference to `TIFFGetField' > /usr/local/lib/libvil.a(vil_tiff_header.o): In function > `read_string(tiff*, unsigned int, std::basic_string<char, > std::char_traits<char>, std::allocator<char> >&, std::basic_string<char, > std::char_traits<char>, std::allocator<char> > const&)': > vil_tiff_header.cxx:(.text+0xedf): undefined reference to `TIFFGetField' > /usr/local/lib/libvil.a(vil_tiff_header.o): In function > `vil_tiff_header::read_header()': > vil_tiff_header.cxx:(.text+0xfa3): undefined reference to > `TIFFIsByteSwapped' > vil_tiff_header.cxx:(.text+0x107b): undefined reference to `TIFFIsTiled' > vil_tiff_header.cxx:(.text+0x11e3): undefined reference to `TIFFGetField' > vil_tiff_header.cxx:(.text+0x1532): undefined reference to `TIFFGetField' > vil_tiff_header.cxx:(.text+0x15b8): undefined reference to `TIFFGetField' > vil_tiff_header.cxx:(.text+0x1add): undefined reference to `TIFFGetField' > vil_tiff_header.cxx:(.text+0x1b5f): undefined reference to `TIFFGetField' > /usr/local/lib/libvil.a(vil_tiff_header.o):vil_tiff_header.cxx:(.text+0x1bdb): > more undefined references to `TIFFGetField' follow > /usr/local/lib/libvil.a(vil_tiff_header.o): In function > `write_string(tiff*, unsigned int, std::basic_string<char, > std::char_traits<char>, std::allocator<char> > const&)': > vil_tiff_header.cxx:(.text+0x1cc9): undefined reference to `TIFFSetField' > /usr/local/lib/libvil.a(vil_tiff_header.o): In function > `write_long_tag(tiff*, unsigned int, ulong_tag const&)': > vil_tiff_header.cxx:(.text+0x1cf8): undefined reference to `TIFFSetField' > /usr/local/lib/libvil.a(vil_tiff_header.o): In function > `write_short_tag(tiff*, unsigned int, ushort_tag const&)': > vil_tiff_header.cxx:(.text+0x1d2a): undefined reference to `TIFFSetField' > /usr/local/lib/libvil.a(vil_geotiff_header.o): In function > `vil_geotiff_header::get_key_value(geokey_t, void**, int&, int&, > tagtype_t&)': > vil_geotiff_header.cxx:(.text+0x1a2): undefined reference to `GTIFKeyInfo' > vil_geotiff_header.cxx:(.text+0x239): undefined reference to `GTIFKeyGet' > /usr/local/lib/libvil.a(vil_geotiff_header.o): In function > `vil_geotiff_header::geounits(geounits_t&)': > vil_geotiff_header.cxx:(.text+0x27d): undefined reference to `GTIFKeyGet' > /usr/local/lib/libvil.a(vil_geotiff_header.o): In function > `vil_geotiff_header::gtif_rastertype(rastertype_t&)': > vil_geotiff_header.cxx:(.text+0x2ef): undefined reference to `GTIFKeyGet' > /usr/local/lib/libvil.a(vil_geotiff_header.o): In function > `vil_geotiff_header::gtif_modeltype(modeltype_t&)': > vil_geotiff_header.cxx:(.text+0x361): undefined reference to `GTIFKeyGet' > /usr/local/lib/libvil.a(vil_geotiff_header.o): In function > `vil_geotiff_header::gtif_trans_matrix(double*&)': > vil_geotiff_header.cxx:(.text+0x52e): undefined reference to `TIFFGetField' > /usr/local/lib/libvil.a(vil_geotiff_header.o): In function > `vil_geotiff_header::gtif_pixelscale(double&, double&, double&)': > vil_geotiff_header.cxx:(.text+0x5a4): undefined reference to `TIFFGetField' > /usr/local/lib/libvil.a(vil_geotiff_header.o): In function > `vil_geotiff_header::gtif_tiepoints(std::vector<std::vector<double, > std::allocator<double> >, std::allocator<std::vector<double, > std::allocator<double> > > >&)': > vil_geotiff_header.cxx:(.text+0x646): undefined reference to `TIFFGetField' > /usr/local/lib/libvil.a(vil_geotiff_header.o): In function > `vil_geotiff_header::vil_geotiff_header(tiff*)': > vil_geotiff_header.cxx:(.text+0x8bc): undefined reference to `GTIFNew' > vil_geotiff_header.cxx:(.text+0x8ec): undefined reference to `GTIFPrint' > vil_geotiff_header.cxx:(.text+0x90b): undefined reference to > `GTIFDirectoryInfo' > /usr/local/lib/libvil.a(vil_geotiff_header.o): In function > `vil_geotiff_header::vil_geotiff_header(tiff*)': > vil_geotiff_header.cxx:(.text+0x95c): undefined reference to `GTIFNew' > vil_geotiff_header.cxx:(.text+0x98c): undefined reference to `GTIFPrint' > vil_geotiff_header.cxx:(.text+0x9ab): undefined reference to > `GTIFDirectoryInfo' > /usr/local/lib/libvil.a(vil_geotiff_header.o): In function > `vil_geotiff_header::~vil_geotiff_header()': > vil_geotiff_header.cxx:(.text._ZN18vil_geotiff_headerD0Ev[vil_geotiff_header::~vil_geotiff_header()]+0x1a): > undefined reference to `GTIFFree' > /usr/local/lib/libvil.a(vil_geotiff_header.o): In function > `vil_geotiff_header::~vil_geotiff_header()': > vil_geotiff_header.cxx:(.text._ZN18vil_geotiff_headerD1Ev[vil_geotiff_header::~vil_geotiff_header()]+0x1a): > undefined reference to `GTIFFree' > /usr/local/lib/libvil.a(vil_jpeg_source_mgr.o): In function > `vil_jpeg_stream_src_set(jpeg_decompress_struct*, vil_stream*)': > vil_jpeg_source_mgr.cxx:(.text+0x185): undefined reference to > `jpeg_resync_to_restart' > collect2: ld returned 1 exit status > make[2]: *** [test2] Error 1 > make[1]: *** [CMakeFiles/test2.dir/all] Error 2 > make: *** [all] Error 2 > > > > > Thanks & Regards. > Doris. > > ------------------------------------------------------------------------ > *发件人:* Peter Vanroose <pet...@ya...> > *收件人:* Xiaowen Pan <dor...@ya...> > *抄送:* vxl...@li... > *已发送:* 2009/4/21(周二), 下午3:33:10 > *主题:* Re: [help] Undefined reference to > > > Does the following work? > # g++ -lvil test2.cpp > > All missing references are in the vil library, so you should at least > link with that library, maybe also with vcl. > CMake could simplify your search for libraries required to make an > application compile. > E.g., place your file test2.cpp in the vxl directory core/vil/examples, add > ADD_EXECUTABLE( test2.cpp ) > to the file CMakeLists.txt, then run cmake, then make. > > -- Peter. |