weiliu89 / caffe

Caffe: a fast open framework for deep learning.
http://caffe.berkeleyvision.org/
Other
4.77k stars 1.67k forks source link

Failing to link get_image_size.bin ("symbol(s) not found for architecture x86_64") #514

Open mjohnst opened 7 years ago

mjohnst commented 7 years ago

Issue summary

I am having trouble building this SSD branch (was able to build successfully build the master branch of Caffe).

Any help would be much appreciated!!

Here's my error output:

CXX/LD -o .build_release/tools/get_image_size.bin
Undefined symbols for architecture x86_64:
  "caffe::ReadImageToDatum(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, int, int, int, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, caffe::Datum*)", referenced from:
      _main in convert_imageset.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Undefined symbols for architecture x86_64:
  "caffe::AnnotatedDatum::AnnotatedDatum()", referenced from:
      _main in convert_annoset.o
  "caffe::AnnotatedDatum::~AnnotatedDatum()", referenced from:
      _main in convert_annoset.o
  "caffe::MapNameToLabel(caffe::LabelMap const&, bool, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, int> > >*)", referenced from:
      _main in convert_annoset.o
  "caffe::ReadImageToDatum(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, int, int, int, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, caffe::Datum*)", referenced from:
      _main in convert_annoset.o
make: *** [.build_release/tools/convert_imageset.bin] Error 1
make: *** Waiting for unfinished jobs....
  "caffe::ReadRichImageToAnnotatedDatum(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, int, int, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, caffe::AnnotatedDatum_AnnotationType, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, int> > > const&, caffe::AnnotatedDatum*)", referenced from:
      _main in convert_annoset.o
  "caffe::LabelMap::LabelMap()", referenced from:
      _main in convert_annoset.o
  "caffe::LabelMap::~LabelMap()", referenced from:
      _main in convert_annoset.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [.build_release/tools/convert_annoset.bin] Error 1
clang: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
Undefined symbols for architecture x86_64:
  "caffe::ReadLabelFileToLabelMap(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, caffe::LabelMap*)", referenced from:
      _main in create_label_map.o
  "caffe::LabelMap::LabelMap()", referenced from:
      _main in create_label_map.o
  "caffe::LabelMap::~LabelMap()", referenced from:
      _main in create_label_map.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [.build_release/tools/create_label_map.bin] Error 1
Undefined symbols for architecture x86_64:
  "caffe::GetImageSize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int*, int*)", referenced from:
      _main in get_image_size.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [.build_release/tools/get_image_size.bin] Error 1

My Makefile.config (with all comments removed):

CPU_ONLY := 1
CUDA_DIR := /usr/local/cuda
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
             -gencode arch=compute_20,code=sm_21 \
             -gencode arch=compute_30,code=sm_30 \
             -gencode arch=compute_35,code=sm_35 \
             -gencode arch=compute_50,code=sm_50 \
             -gencode arch=compute_52,code=sm_52 \
             -gencode arch=compute_61,code=sm_61
BLAS := open
BLAS_INCLUDE := $(shell brew --prefix openblas)/include
BLAS_LIB := $(shell brew --prefix openblas)/lib
ANACONDA_HOME := /anaconda
PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
        $(ANACONDA_HOME)/include/python2.7 \
        $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \
PYTHON_LIB := $(ANACONDA_HOME)/lib
PYTHON_LIB += $(shell brew --prefix numpy)/lib
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
BUILD_DIR := build
DISTRIBUTE_DIR := distribute
TEST_GPUID := 0
Q ?= @

Steps to reproduce

ran make -j8

Your system configuration

Operating system: macOS 10.12.4 (16E195) -- MacBook Pro (Retina, 13-inch, Early 2015) Compiler: clang++ CUDA version (if applicable): 8.0.61 (no CUDA GPU on device) CUDNN version (if applicable): n/a BLAS: OpenBLAS 0.2.18_2 (via Homebrew) Python or MATLAB version (for pycaffe and matcaffe respectively): Python 2.7.13 :: Anaconda custom (x86_64)

weiliu89 commented 7 years ago

Looks like a compiler (clang) and c++11 issue to me.

mjohnst commented 7 years ago

I think it may be related to building on macOS with CPU_ONLY flag set. I've since had success building the project on my Ubuntu machine with a GPU.

I was eventually able to fix the linking errors buy manually adding them to the linking steps in the Makefile. Required me to link some objects built from \util, \layers, and \proto. I think the issue might be that the Makefile definitions for choosing what objects to link weren't updated for ssd branch for CPU_ONLY.

Since I've got it working on Ubuntu, I'll probably just use that though :)