3

So I have a .cpp file that uses OpenCV. I've been having some problems with linking the libraries but I think my Makefile is "better" now.

Makefile:

CC=g++
#CC=gcc

# compile flags
CFLAGS=-g -Wall

# OpenCV Related
prefix=/usr/local/opencv

OCVFLAGS=-I${prefix}/include/opencv -I${prefix}/include
OCVLIBS=-L${prefix}/lib -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_flann -lopencv_objdetect -lopencv_calib3d


PROGRAM=extractDescriptorsToFile

OBJECTS=$(PROGRAM).o

program: $(OBJECTS)
    $(CC) $(OBJECTS) -o $(PROGRAM) $(OCVLIBS) -arch i386 

$(PROGRAM).o: $(PROGRAM).cpp
    $(CC) -c $(CFLAGS) $(OCVFLAGS) $(PROGRAM).cpp 

clean:
    rm -f *o
    rm -f $(PROGRAM)
    rm -f *~

However, when I "make", the .o file is generated but I get this error:

ld: warning: ignoring file extractDescriptorsToFile.o, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
make: *** [program] Error 1

This is a similar post " Precompiled headers and compiling universal objects on OSX " but I don't think its quite my problem?

Any help would be appreciated...?

I think this error is sometimes cause by not having a main() but my file does...

Removing "-arch i386" leaves me with:

Undefined symbols for architecture x86_64:
  "cv::operator<<(cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      cv::operator<<(cv::FileStorage&, char const*)in extractDescriptorsToFile.o
      extract(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, char**, cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in extractDescriptorsToFile.o
      _main in extractDescriptorsToFile.o
  "cv::Ptr<CvFileStorage>::delete_obj()", referenced from:
      cv::Ptr<CvFileStorage>::release()      in extractDescriptorsToFile.o
  "cv::fastFree(void*)", referenced from:
      cv::Ptr<CvFileStorage>::release()      in extractDescriptorsToFile.o
      cv::Ptr<cv::FeatureDetector>::release()      in extractDescriptorsToFile.o
      cv::Ptr<cv::DescriptorExtractor>::release()      in extractDescriptorsToFile.o
      cv::Mat::~Mat() in extractDescriptorsToFile.o
  "cv::fastMalloc(unsigned long)", referenced from:
      cv::Ptr<cv::FeatureDetector>::Ptr(cv::FeatureDetector*)in extractDescriptorsToFile.o
  "cv::Mat::deallocate()", referenced from:
      cv::Mat::release()    in extractDescriptorsToFile.o
  "cv::Mat::copySize(cv::Mat const&)", referenced from:
      cv::Mat::operator=(cv::Mat const&)in extractDescriptorsToFile.o
  "cv::Exception::Exception(int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)", referenced from:
      cv::FileStorage& cv::operator<< <cv::Mat>(cv::FileStorage&, cv::Mat const&)in extractDescriptorsToFile.o
  "cv::error(cv::Exception const&)", referenced from:
      cv::FileStorage& cv::operator<< <cv::Mat>(cv::FileStorage&, cv::Mat const&)in extractDescriptorsToFile.o
  "cv::Exception::~Exception()", referenced from:
      cv::FileStorage& cv::operator<< <cv::Mat>(cv::FileStorage&, cv::Mat const&)in extractDescriptorsToFile.o
  "cv::write(cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::Mat const&)", referenced from:
      cv::FileStorage& cv::operator<< <cv::Mat>(cv::FileStorage&, cv::Mat const&)in extractDescriptorsToFile.o
  "cv::_OutputArray::_OutputArray(cv::Mat&)", referenced from:
      resizeImage(cv::Mat const&, int)in extractDescriptorsToFile.o
  "cv::_InputArray::_InputArray(cv::Mat const&)", referenced from:
      resizeImage(cv::Mat const&, int)in extractDescriptorsToFile.o
  "cv::resize(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_<int>, double, double, int)", referenced from:
      resizeImage(cv::Mat const&, int)in extractDescriptorsToFile.o
  "cv::OrbFeatureDetector::OrbFeatureDetector(unsigned long, cv::ORB::CommonParams)", referenced from:
      extract(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, char**, cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in extractDescriptorsToFile.o
  "cv::FeatureDetector::create(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      extract(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, char**, cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in extractDescriptorsToFile.o
  "cv::DescriptorExtractor::create(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      extract(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, char**, cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in extractDescriptorsToFile.o
  "cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)", referenced from:
      extract(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, char**, cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in extractDescriptorsToFile.o
  "cv::FeatureDetector::detect(cv::Mat const&, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >&, cv::Mat const&) const", referenced from:
      extract(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, char**, cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in extractDescriptorsToFile.o
  "cv::DescriptorExtractor::compute(cv::Mat const&, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >&, cv::Mat&) const", referenced from:
      extract(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, char**, cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in extractDescriptorsToFile.o
  "cv::write(cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> > const&)", referenced from:
      extract(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, char**, cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in extractDescriptorsToFile.o
  "cv::FileStorage::FileStorage()", referenced from:
      _main in extractDescriptorsToFile.o
  "cv::FileStorage::FileStorage(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      _main in extractDescriptorsToFile.o
  "cv::FileStorage::~FileStorage()", referenced from:
      _main in extractDescriptorsToFile.o
  "cv::FileStorage::isOpened() const", referenced from:
      _main in extractDescriptorsToFile.o
  "cv::FileStorage::release()", referenced from:
      _main in extractDescriptorsToFile.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [program] Error 1

This is what I get when I add -arch i386 to both program and $(PROGRAM).o:

Undefined symbols for architecture i386:
  "_gzputs", referenced from:
      icvPuts(CvFileStorage*, char const*)in libopencv_core.a(persistence.o)
  "_gzgets", referenced from:
      icvGets(CvFileStorage*, char*, int)in libopencv_core.a(persistence.o)
  "_gzeof", referenced from:
      icvEof(CvFileStorage*)      in libopencv_core.a(persistence.o)
  "_gzclose", referenced from:
      _cvReleaseFileStorage in libopencv_core.a(persistence.o)
      _cvOpenFileStorage in libopencv_core.a(persistence.o)
  "_gzopen", referenced from:
      _cvOpenFileStorage in libopencv_core.a(persistence.o)
  "_gzrewind", referenced from:
      _cvOpenFileStorage in libopencv_core.a(persistence.o)
  "cv::Mat::convertTo(cv::Mat&, int, double, double) const", referenced from:
      cv::imencode(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::Mat const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(loadsave.o)
      cv::imwrite_(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::Mat const&, std::vector<int, std::allocator<int> > const&, bool)in libopencv_highgui.a(loadsave.o)
  "cv::flip(cv::Mat const&, cv::Mat&, int)", referenced from:
      _cvEncodeImage in libopencv_highgui.a(loadsave.o)
      cv::imwrite_(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::Mat const&, std::vector<int, std::allocator<int> > const&, bool)in libopencv_highgui.a(loadsave.o)
  "_jpeg_destroy_decompress", referenced from:
      cv::JpegDecoder::close()     in libopencv_highgui.a(grfmt_jpeg.o)
      cv::JpegDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_jpeg.o)
      cv::JpegDecoder::readHeader()      in libopencv_highgui.a(grfmt_jpeg.o)
      cv::JpegDecoder::~JpegDecoder()in libopencv_highgui.a(grfmt_jpeg.o)
      cv::JpegDecoder::~JpegDecoder()in libopencv_highgui.a(grfmt_jpeg.o)
      cv::JpegDecoder::~JpegDecoder()in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_CreateCompress", referenced from:
      cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_std_error", referenced from:
      cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
      cv::JpegDecoder::readHeader()      in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_destroy_compress", referenced from:
      cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_set_defaults", referenced from:
      cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_set_quality", referenced from:
      cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_start_compress", referenced from:
      cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_write_scanlines", referenced from:
      cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_finish_compress", referenced from:
      cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_stdio_dest", referenced from:
      cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_start_decompress", referenced from:
      cv::JpegDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_read_scanlines", referenced from:
      cv::JpegDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_finish_decompress", referenced from:
      cv::JpegDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_alloc_huff_table", referenced from:
      cv::JpegDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_CreateDecompress", referenced from:
      cv::JpegDecoder::readHeader()      in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_read_header", referenced from:
      cv::JpegDecoder::readHeader()      in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_stdio_src", referenced from:
      cv::JpegDecoder::readHeader()      in libopencv_highgui.a(grfmt_jpeg.o)
  "_jpeg_resync_to_restart", referenced from:
      cv::jpeg_buffer_src(jpeg_decompress_struct*, cv::JpegSource*)       in libopencv_highgui.a(grfmt_jpeg.o)
      cv::JpegDecoder::readHeader()      in libopencv_highgui.a(grfmt_jpeg.o)
  "_jas_init", referenced from:
      __static_initialization_and_destruction_0(int, int)in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_jas_cleanup", referenced from:
      ___tcf_0 in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_jas_matrix_create", referenced from:
      cv::Jpeg2KEncoder::writeComponent16u(void*, cv::Mat const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
      cv::Jpeg2KEncoder::writeComponent8u(void*, cv::Mat const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
      cv::Jpeg2KDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_jas_image_writecmpt", referenced from:
      cv::Jpeg2KEncoder::writeComponent16u(void*, cv::Mat const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
      cv::Jpeg2KEncoder::writeComponent8u(void*, cv::Mat const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_jas_matrix_destroy", referenced from:
      cv::Jpeg2KEncoder::writeComponent16u(void*, cv::Mat const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
      cv::Jpeg2KEncoder::writeComponent8u(void*, cv::Mat const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
      cv::Jpeg2KDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_jas_stream_close", referenced from:
      cv::Jpeg2KDecoder::close()     in libopencv_highgui.a(grfmt_jpeg2000.o)
      cv::Jpeg2KEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
      cv::Jpeg2KDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_jpeg2000.o)
      cv::Jpeg2KDecoder::readHeader()      in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_jas_image_destroy", referenced from:
      cv::Jpeg2KDecoder::close()     in libopencv_highgui.a(grfmt_jpeg2000.o)
      cv::Jpeg2KEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
      cv::Jpeg2KDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_jpeg2000.o)
      cv::Jpeg2KDecoder::readHeader()      in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_jas_image_create", referenced from:
      cv::Jpeg2KEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_jas_stream_fopen", referenced from:
      cv::Jpeg2KEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
      cv::Jpeg2KDecoder::readHeader()      in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_jas_image_strtofmt", referenced from:
      cv::Jpeg2KEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_jas_image_encode", referenced from:
      cv::Jpeg2KEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_jas_image_getcmptbytype", referenced from:
      cv::Jpeg2KDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_jas_cmprof_createfromclrspc", referenced from:
      cv::Jpeg2KDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_jas_image_chclrspc", referenced from:
      cv::Jpeg2KDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_jas_cmprof_destroy", referenced from:
      cv::Jpeg2KDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_jas_image_readcmpt", referenced from:
      cv::Jpeg2KDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_jas_image_decode", referenced from:
      cv::Jpeg2KDecoder::readHeader()      in libopencv_highgui.a(grfmt_jpeg2000.o)
  "_png_destroy_read_struct", referenced from:
      cv::PngDecoder::close()     in libopencv_highgui.a(grfmt_png.o)
      cv::PngDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_png.o)
      cv::PngDecoder::readHeader()      in libopencv_highgui.a(grfmt_png.o)
      cv::PngDecoder::~PngDecoder()in libopencv_highgui.a(grfmt_png.o)
      cv::PngDecoder::~PngDecoder()in libopencv_highgui.a(grfmt_png.o)
      cv::PngDecoder::~PngDecoder()in libopencv_highgui.a(grfmt_png.o)
  "_png_create_write_struct", referenced from:
      cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
  "_png_create_info_struct", referenced from:
      cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
      cv::PngDecoder::readHeader()      in libopencv_highgui.a(grfmt_png.o)
  "_png_destroy_write_struct", referenced from:
      cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
  "_png_set_write_fn", referenced from:
      cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
  "_png_set_filter", referenced from:
      cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
  "_png_set_compression_level", referenced from:
      cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
  "_png_set_compression_strategy", referenced from:
      cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
  "_png_set_IHDR", referenced from:
      cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
  "_png_write_info", referenced from:
      cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
  "_png_set_bgr", referenced from:
      cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
      cv::PngDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_png.o)
  "_png_write_image", referenced from:
      cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
  "_png_write_end", referenced from:
      cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
  "_png_set_compression_mem_level", referenced from:
      cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
  "_png_init_io", referenced from:
      cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
      cv::PngDecoder::readHeader()      in libopencv_highgui.a(grfmt_png.o)
  "_png_set_swap", referenced from:
      cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
      cv::PngDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_png.o)
  "_png_set_strip_alpha", referenced from:
      cv::PngDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_png.o)
  "_png_read_update_info", referenced from:
      cv::PngDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_png.o)
  "_png_read_image", referenced from:
      cv::PngDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_png.o)
  "_png_read_end", referenced from:
      cv::PngDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_png.o)
  "_png_set_rgb_to_gray", referenced from:
      cv::PngDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_png.o)
  "_png_set_gray_to_rgb", referenced from:
      cv::PngDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_png.o)
  "_png_set_expand_gray_1_2_4_to_8", referenced from:
      cv::PngDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_png.o)
  "_png_set_palette_to_rgb", referenced from:
      cv::PngDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_png.o)
  "_png_set_strip_16", referenced from:
      cv::PngDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_png.o)
  "_png_create_read_struct", referenced from:
      cv::PngDecoder::readHeader()      in libopencv_highgui.a(grfmt_png.o)
  "_png_set_read_fn", referenced from:
      cv::PngDecoder::readHeader()      in libopencv_highgui.a(grfmt_png.o)
  "_png_read_info", referenced from:
      cv::PngDecoder::readHeader()      in libopencv_highgui.a(grfmt_png.o)
  "_png_get_IHDR", referenced from:
      cv::PngDecoder::readHeader()      in libopencv_highgui.a(grfmt_png.o)
  "_png_error", referenced from:
      cv::PngDecoder::readDataFromBuf(void*, unsigned char*, unsigned long)in libopencv_highgui.a(grfmt_png.o)
  "_TIFFClose", referenced from:
      cv::TiffDecoder::close()     in libopencv_highgui.a(grfmt_tiff.o)
      cv::TiffDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_tiff.o)
      cv::TiffDecoder::readHeader()      in libopencv_highgui.a(grfmt_tiff.o)
      cv::TiffDecoder::~TiffDecoder()in libopencv_highgui.a(grfmt_tiff.o)
      cv::TiffDecoder::~TiffDecoder()in libopencv_highgui.a(grfmt_tiff.o)
      cv::TiffDecoder::~TiffDecoder()in libopencv_highgui.a(grfmt_tiff.o)
  "_TIFFIsTiled", referenced from:
      cv::TiffDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_tiff.o)
  "_TIFFGetField", referenced from:
      cv::TiffDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_tiff.o)
      cv::TiffDecoder::readHeader()      in libopencv_highgui.a(grfmt_tiff.o)
  "_TIFFReadEncodedStrip", referenced from:
      cv::TiffDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_tiff.o)
  "_TIFFReadRGBAStrip", referenced from:
      cv::TiffDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_tiff.o)
  "_TIFFReadEncodedTile", referenced from:
      cv::TiffDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_tiff.o)
  "_TIFFReadRGBATile", referenced from:
      cv::TiffDecoder::readData(cv::Mat&)     in libopencv_highgui.a(grfmt_tiff.o)
  "_TIFFOpen", referenced from:
      cv::TiffDecoder::readHeader()      in libopencv_highgui.a(grfmt_tiff.o)
  "_TIFFRGBAImageOK", referenced from:
      cv::TiffDecoder::readHeader()      in libopencv_highgui.a(grfmt_tiff.o)
  "_TIFFSetErrorHandler", referenced from:
      cv::TiffDecoder::TiffDecoder()in libopencv_highgui.a(grfmt_tiff.o)
      cv::TiffDecoder::TiffDecoder()in libopencv_highgui.a(grfmt_tiff.o)
  "_TIFFSetWarningHandler", referenced from:
      cv::TiffDecoder::TiffDecoder()in libopencv_highgui.a(grfmt_tiff.o)
      cv::TiffDecoder::TiffDecoder()in libopencv_highgui.a(grfmt_tiff.o)
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
make: *** [program] Error 1
Community
  • 1
  • 1
user1135469
  • 1,020
  • 11
  • 22
  • 1
    dI have not used make on OSX but Do you really need `-arch i386`? Try getting rid of it and build it – another.anon.coward Jul 14 '12 at 17:16
  • 1
    What is the output of `file extractDescriptorsToFile.o` on terminal? How about adding `-arch i386` option to `$(PROGRAM).o` instead of `program`? – another.anon.coward Jul 14 '12 at 17:39
  • If I add the option to `$(PROGRAM).o` INSTEAD OF `program` I get all the errors that I've shown in my answer when I remove `-arch i386`. So I added the option to both and nothing changes. The output of `file extractDescriptorToFile.o` is `extractDescriptorsToFile.o: Mach-O 64-bit object x86_64`. – user1135469 Jul 14 '12 at 17:50
  • 1
    Hmmm you have specified arch as i386 (32 bit) and you are getting x86_64 (64 bit) object file, seems strange. Can you try `-arch x86_64` instead. You could also try adding `-m32` for in case of `-arch i386` or `-m64` in case of `-arch x86_64`. I am just shooting in the dark here – another.anon.coward Jul 14 '12 at 17:55
  • Thanks for the help, but no luck with that. – user1135469 Jul 14 '12 at 18:02
  • Last swing in the dark :) - Have a look at this [post](http://stackoverflow.com/questions/1754460/apples-gcc-whats-the-difference-between-arch-i386-and-m32) & see if any of those work. Also for trail generate execute from source. Hope someone can shed some light on this issue. Good luck! – another.anon.coward Jul 14 '12 at 18:05

1 Answers1

0

What happens if you remove explicit architecture specification (" -arch i386 ") from line 19? I guess that might help.

EDIT

Well it seems to me that you have a 64-bit OS, and 32-bit OpenCV libraries.

user1135469
  • 1,020
  • 11
  • 22
taketwo
  • 1,211
  • 9
  • 10
  • I only put "-arch i386" in to get rid of some other errors and warnings. I've edited my question to show those errors. – user1135469 Jul 14 '12 at 17:26
  • Just to make it clear, what exactly do you get when you add `-arch i386` to **both** `program` and `$(PROGRAM).o` targets? – taketwo Jul 14 '12 at 18:17
  • I have edited my question to show what happens. It leads me to believe that I have a problem with the libraries or linking them...maybe? – user1135469 Jul 14 '12 at 18:29
  • Well it seems to me that you have a 64-bit OS, and 32-bit OpenCV libraries. How did you obtain these libraries? – taketwo Jul 14 '12 at 18:38
  • You're right. I got the libraries in by 'svn-ing' a project. Any idea where to find 64-bit libraries? – user1135469 Jul 14 '12 at 18:43
  • Can not help you with that, sorry. But you could always consider compiling from source as a last resort :) – taketwo Jul 14 '12 at 18:52