I try to compile C++ code with OpenCV's DNN module included, but I got linker errors. The project uses a lot of other OpenCV module without any problem so I guess the headers and sources are added fine and it has a problem with the DNN module only. Linker flags are added for sure it has -lopencv_dnn_objdetect and -lopencv_dnn too. OpenCV installed with Homebrew not complied from source if that's matter. I use Xcode 11 beta, other members of my team use Visual Studio with Windows and they don't have any problem with the same code.
The errors I got:
Ld /Users/hordon/Library/Developer/Xcode/DerivedData/project-fmllzddvpyajkjbwntzsyqvmunjx/Build/Products/Debug/OpenCV normal x86_64 (in target: OpenCV)
cd /Users/hordon/Desktop/GreenFox/OpenCV
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target x86_64-apple-macos10.14 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -L/Users/hordon/Library/Developer/Xcode/DerivedData/project-fmllzddvpyajkjbwntzsyqvmunjx/Build/Products/Debug -L/usr/local/Cellar/opencv/4.1.0_2/lib -L/usr/local/Cellar/sqlite/3.28.0/lib -L/usr/local/Cellar/tesseract/4.0.0_1/lib -L/usr/local/Cellar/leptonica/1.78.0/lib -F/Users/hordon/Library/Developer/Xcode/DerivedData/project-fmllzddvpyajkjbwntzsyqvmunjx/Build/Products/Debug -filelist /Users/hordon/Library/Developer/Xcode/DerivedData/project-fmllzddvpyajkjbwntzsyqvmunjx/Build/Intermediates.noindex/project.build/Debug/OpenCV.build/Objects-normal/x86_64/OpenCV.LinkFileList -Xlinker -object_path_lto -Xlinker /Users/hordon/Library/Developer/Xcode/DerivedData/project-fmllzddvpyajkjbwntzsyqvmunjx/Build/Intermediates.noindex/project.build/Debug/OpenCV.build/Objects-normal/x86_64/OpenCV_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -stdlib=libc++ -I/usr/local/Cellar/opencv/4.1.0_2/include/opencv4/opencv -I/usr/local/Cellar/opencv/4.1.0_2/include/opencv4 -L/usr/local/Cellar/opencv/4.1.0_2/lib -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_sfm -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_video -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -ltesseract -lsqlite3 -Xlinker -dependency_info -Xlinker /Users/hordon/Library/Developer/Xcode/DerivedData/project-fmllzddvpyajkjbwntzsyqvmunjx/Build/Intermediates.noindex/project.build/Debug/OpenCV.build/Objects-normal/x86_64/OpenCV_dependency_info.dat -o /Users/hordon/Library/Developer/Xcode/DerivedData/project-fmllzddvpyajkjbwntzsyqvmunjx/Build/Products/Debug/OpenCV
Undefined symbols for architecture x86_64:
"cv::dnn::dnn4_v20180917::blobFromImage(cv::_InputArray const&, cv::_OutputArray const&, double, cv::Size_<int> const&, cv::Scalar_<double> const&, bool, bool, int)", referenced from:
detectText(cv::Mat, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in detectText.o
"cv::dnn::dnn4_v20180917::Net::forward(cv::_OutputArray const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)", referenced from:
detectText(cv::Mat, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in detectText.o
"cv::dnn::dnn4_v20180917::Net::setInput(cv::_InputArray const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, double, cv::Scalar_<double> const&)", referenced from:
detectText(cv::Mat, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in detectText.o
"cv::dnn::dnn4_v20180917::Net::~Net()", referenced from:
detectText(cv::Mat, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in detectText.o
"cv::dnn::dnn4_v20180917::readNet(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&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
detectText(cv::Mat, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in detectText.o
"cv::dnn::dnn4_v20180917::NMSBoxes(std::__1::vector<cv::RotatedRect, std::__1::allocator<cv::RotatedRect> > const&, std::__1::vector<float, std::__1::allocator<float> > const&, float, float, std::__1::vector<int, std::__1::allocator<int> >&, float, int)", referenced from:
detectText(cv::Mat, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in detectText.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Every code I tried throw this linker error if it has the DNN module included, for example, this sample code from OpenCV.
Meanwhile, I found a solution, so I leave it here in case anybody struggles with the same issue. If you installed OpenCV with Homebrew's brew install opencv command the DNN module won't be compiled. You have to rebuild it from source which you can achieve with the
brew reinstall opencv --build-from-source
command. Since at this point my search paths were added correctly I just had to build my project again, which was done without any error.
Related
I am using mac osX. I downloaded llvm from git repo and now I am trying to build examples (chapter 6). I installed llvm:
when running: which llvm-config
I get /usr/local/bin/llvm-config
when running
clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core mcjit native` -O3 -o toy
as suggested by: http://llvm.org/docs/tutorial/LangImpl06.html
I get :
Undefined symbols for architecture x86_64:
"llvm::orc::SimpleCompiler::operator()(llvm::Module&)", referenced from:
llvm::orc::LegacyIRCompileLayer<llvm::orc::LegacyRTDyldObjectLinkingLayer, llvm::orc::SimpleCompiler>::addModule(unsigned long long, std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> >) in toy-e99926.o
"llvm::orc::SymbolResolver::anchor()", referenced from:
vtable for llvm::orc::LegacyLookupFnResolver<llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::'lambda'(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)> in toy-e99926.o
"llvm::orc::SymbolStringPtr::Tombstone", referenced from:
llvm::orc::JITDylib::~JITDylib() in toy-e99926.o
llvm::orc::JITDylib::MaterializingInfo::~MaterializingInfo() in toy-e99926.o
llvm::orc::LegacyLookupFnResolver<llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::'lambda'(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>::getResponsibilitySet(llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr> > const&) in toy-e99926.o
llvm::orc::getResponsibilitySetWithLegacyFn<llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::'lambda'(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>(llvm::Expected<llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr> > >, llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr> > const&, llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::'lambda'(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)) in toy-e99926.o
std::__1::pair<llvm::DenseMapIterator<llvm::orc::SymbolStringPtr, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr>, llvm::detail::DenseSetPair<llvm::orc::SymbolStringPtr>, false>, bool> llvm::DenseMapBase<llvm::DenseMap<llvm::orc::SymbolStringPtr, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr>, llvm::detail::DenseSetPair<llvm::orc::SymbolStringPtr> >, llvm::orc::SymbolStringPtr, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr>, llvm::detail::DenseSetPair<llvm::orc::SymbolStringPtr> >::try_emplace<llvm::detail::DenseSetEmpty&>(llvm::orc::SymbolStringPtr const&, llvm::detail::DenseSetEmpty&&&) in toy-e99926.o
llvm::detail::DenseSetPair<llvm::orc::SymbolStringPtr>* llvm::DenseMapBase<llvm::DenseMap<llvm::orc::SymbolStringPtr, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr>, llvm::detail::DenseSetPair<llvm::orc::SymbolStringPtr> >, llvm::orc::SymbolStringPtr, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr>, llvm::detail::DenseSetPair<llvm::orc::SymbolStringPtr> >::InsertIntoBucketImpl<llvm::orc::SymbolStringPtr>(llvm::orc::SymbolStringPtr const&, llvm::orc::SymbolStringPtr const&, llvm::detail::DenseSetPair<llvm::orc::SymbolStringPtr>*) in toy-e99926.o
llvm::DenseMapBase<llvm::DenseMap<llvm::orc::SymbolStringPtr, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr>, llvm::detail::DenseSetPair<llvm::orc::SymbolStringPtr> >, llvm::orc::SymbolStringPtr, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr>, llvm::detail::DenseSetPair<llvm::orc::SymbolStringPtr> >::moveFromOldBuckets(llvm::detail::DenseSetPair<llvm::orc::SymbolStringPtr>*, llvm::detail::DenseSetPair<llvm::orc::SymbolStringPtr>*) in toy-e99926.o
...
"llvm::orc::ExecutionSession::legacyFailQuery(llvm::orc::AsynchronousSymbolQuery&, llvm::Error)", referenced from:
llvm::orc::lookupWithLegacyFn<llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::'lambda'(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>(llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr> >, llvm::orc::ExecutionSession&, llvm::orc::AsynchronousSymbolQuery&, llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr> > const&, llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::'lambda'(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)) in toy-e99926.o
"llvm::orc::ExecutionSession::ExecutionSession(std::__1::shared_ptr<llvm::orc::SymbolStringPool>)", referenced from:
llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT() in toy-e99926.o
"llvm::orc::AsynchronousSymbolQuery::handleFullyReady()", referenced from:
llvm::orc::lookupWithLegacyFn<llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::'lambda'(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>(llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr> >, llvm::orc::ExecutionSession&, llvm::orc::AsynchronousSymbolQuery&, llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr> > const&, llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::'lambda'(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)) in toy-e99926.o
"llvm::orc::AsynchronousSymbolQuery::notifySymbolReady()", referenced from:
llvm::orc::lookupWithLegacyFn<llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::'lambda'(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>(llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr> >, llvm::orc::ExecutionSession&, llvm::orc::AsynchronousSymbolQuery&, llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr> > const&, llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::'lambda'(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)) in toy-e99926.o
"llvm::orc::AsynchronousSymbolQuery::handleFullyResolved()", referenced from:
llvm::orc::lookupWithLegacyFn<llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::'lambda'(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>(llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr> >, llvm::orc::ExecutionSession&, llvm::orc::AsynchronousSymbolQuery&, llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr> > const&, llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::'lambda'(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)) in toy-e99926.o
"llvm::orc::AsynchronousSymbolQuery::resolve(llvm::orc::SymbolStringPtr const&, llvm::JITEvaluatedSymbol)", referenced from:
llvm::orc::lookupWithLegacyFn<llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::'lambda'(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>(llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr> >, llvm::orc::ExecutionSession&, llvm::orc::AsynchronousSymbolQuery&, llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr> > const&, llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::'lambda'(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)) in toy-e99926.o
"llvm::orc::JITSymbolResolverAdapter::JITSymbolResolverAdapter(llvm::orc::ExecutionSession&, llvm::orc::SymbolResolver&, llvm::orc::MaterializationResponsibility*)", referenced from:
llvm::orc::LegacyRTDyldObjectLinkingLayer::ConcreteLinkedObject<std::__1::shared_ptr<llvm::RuntimeDyld::MemoryManager> >::finalize() in toy-e99926.o
"vtable for llvm::orc::JITSymbolResolverAdapter", referenced from:
llvm::orc::LegacyRTDyldObjectLinkingLayer::ConcreteLinkedObject<std::__1::shared_ptr<llvm::RuntimeDyld::MemoryManager> >::finalize() in toy-e99926.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Does anyone knows how to fix it ?
running like so :
clang++ -g toy.cpp $(llvm-config --cxxflags --ldflags --system-libs --libs) -O3 -o toy
seems to be working
I confirm that all you need to do is follow this steps http://llvm.org/docs/CMake.html in quick start section and then run command the way i presented it above at least it works for chapter 6
AS BONUS
Cmake File for Clion MacOs X and linux (linux not tested) may look something like this.
make sure llvm installed correctly (follow steps above)
cmake_minimum_required(VERSION 3.10)
project(project_name )
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
link_libraries()
execute_process(COMMAND llvm-config --libs OUTPUT_VARIABLE LIBS)
execute_process(COMMAND llvm-config --system-libs OUTPUT_VARIABLE SYS_LIBS)
execute_process(COMMAND llvm-config --ldflags OUTPUT_VARIABLE LDF)
#message(STATUS "Found LLVM" ${LIBS})
string(STRIP ${LIBS} LIBS)
string(STRIP ${SYS_LIBS} SYS_LIBS)
string(STRIP ${LDF} LDF)
link_libraries(${LIBS} ${SYS_LIBS} ${LDF})
execute_process(COMMAND llvm-config --cxxflags OUTPUT_VARIABLE CMAKE_CXX_FLAGS)
string(STRIP ${CMAKE_CXX_FLAGS} CMAKE_CXX_FLAGS)
add_executable(project_name toy.cpp)
OS -> OSX El Captain Version 10.11.6
Tried to install gRPC using the below commands:
git clone-b $(curl -L http://grpc.io/release) https://github.com/grpc/grpc
cd grpc
git submodule update --init
make
I got the below error:
[HOSTCXX] Compiling src/compiler/cpp_plugin.cc
[HOSTLD] Linking /<path>/grpc/bins/opt/grpc_cpp_plugin
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
Undefined symbols for architecture x86_64:
"google::protobuf::io::StringOutputStream::StringOutputStream(std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >*)", referenced from:
ProtoBufFile::CreatePrinter(std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >*) const in cpp_plugin.o
"google::protobuf::io::Printer::Print(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, 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, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > const&, char const*)", referenced from:
ProtoBufPrinter::Print(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, 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, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > const&, char const*) in cpp_plugin.o
"google::protobuf::FileDescriptor::GetSourceLocation(std::__1::vector<int, std::__1::allocator<int> > const&, google::protobuf::SourceLocation*) const", referenced from:
void grpc_generator::GetComment<google::protobuf::FileDescriptor>(google::protobuf::FileDescriptor const*, grpc_generator::CommentType, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >*) in cpp_plugin.o
"google::protobuf::compiler::CodeGenerator::GenerateAll(std::__1::vector<google::protobuf::FileDescriptor const*, std::__1::allocator<google::protobuf::FileDescriptor const*> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, google::protobuf::compiler::GeneratorContext*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) const", referenced from:
vtable for CppGrpcGenerator in cpp_plugin.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: *** [/<path>/grpc/bins/opt/grpc_cpp_plugin] Error 1
This is what I have in
/<path>/grpc/libs/opt/ directory :
- libares.a
- libgpr.a
- libgrpc_cronet.a
- libgrpc_unsecure.a
- libboringssl.a
- libgrpc.a
- libgrpc_plugin_support.a
- pkgconfig
[EDIT]
After uninstalling protobuf and running make again I get the below warnings :
[LD] Linking /<path>/grpc/libs/opt/libgpr.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
[LD] Linking /<path>/grpc/libs/opt/libgrpc.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
[LD] Linking /<path>/grpc/libs/opt/libgrpc_cronet.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
[LD] Linking /<path>/grpc/libs/opt/libgrpc_unsecure.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
[LD] Linking /<path>/grpc/libs/opt/libgrpc++.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
[LD] Linking /<path>/grpc/libs/opt/libgrpc++_cronet.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
[LD] Linking /<path>/grpc/libs/opt/libgrpc++_error_details.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
[LD] Linking /<path>/grpc/libs/opt/libgrpc++_reflection.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
[LD] Linking /<path>/grpc/libs/opt/libgrpc++_unsecure.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
If I proceed with the installation by executing 'sudo make install', protobuf doesn't get installed and grpc_cpp_plugin doesn't work (gives the below error).
grpc_cpp_plugin: program not found or is not executable
--grpc_out: protoc-gen-grpc: Plugin failed with status code 1.
[EDIT]
For the c-ares problem, i installed it using homebrew brew install c-ares. Then installed grpc grpc-1.3.0.tar.gz and protobuf libprotoc 3.2.0 without errors. But when i run make in the helloworld example, i'm getting the below error :
protoc -I ../../protos --cpp_out=. ../../protos/helloworld.proto
g++ -std=c++11 -I/usr/local/include -pthread -c -o helloworld.pb.o helloworld.pb.cc
protoc -I ../../protos --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ../../protos/helloworld.proto
g++ -std=c++11 -I/usr/local/include -pthread -c -o helloworld.grpc.pb.o helloworld.grpc.pb.cc
g++ -std=c++11 -I/usr/local/include -pthread -c -o greeter_client.o greeter_client.cc
g++ helloworld.pb.o helloworld.grpc.pb.o greeter_client.o -L/usr/local/lib `pkg-config --libs grpc++ grpc` -lgrpc++_reflection -lprotobuf -lpthread -ldl -o greeter_client
Undefined symbols for architecture x86_64:
"grpc::CreateChannel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<grpc::ChannelCredentials> const&)", referenced from:
_main in greeter_client.o
"google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))", referenced from:
helloworld::protobuf_helloworld_2eproto::AddDescriptorsImpl() in helloworld.pb.o
"google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)", referenced from:
google::protobuf::internal::WireFormatLite::WriteStringToArray(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*) in helloworld.pb.o
"google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, google::protobuf::internal::ArenaStringPtr)", referenced from:
helloworld::HelloRequest::HelloRequest(helloworld::HelloRequest const&) in helloworld.pb.o
helloworld::HelloRequest::HelloRequest(helloworld::HelloRequest const&) in helloworld.pb.o
helloworld::HelloRequest::MergeFrom(helloworld::HelloRequest const&) in helloworld.pb.o
helloworld::HelloReply::HelloReply(helloworld::HelloReply const&) in helloworld.pb.o
helloworld::HelloReply::HelloReply(helloworld::HelloReply const&) in helloworld.pb.o
helloworld::HelloReply::MergeFrom(helloworld::HelloReply const&) in helloworld.pb.o
"google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::io::CodedOutputStream*)", referenced from:
helloworld::HelloRequest::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in helloworld.pb.o
helloworld::HelloReply::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in helloworld.pb.o
"google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)", referenced from:
google::protobuf::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) in helloworld.pb.o
"google::protobuf::internal::AssignDescriptors(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::internal::MigrationSchema const*, google::protobuf::Message const* const*, unsigned int const*, google::protobuf::MessageFactory*, google::protobuf::Metadata*, google::protobuf::EnumDescriptor const**, google::protobuf::ServiceDescriptor const**)", referenced from:
helloworld::protobuf_helloworld_2eproto::(anonymous namespace)::protobuf_AssignDescriptors() in helloworld.pb.o
"google::protobuf::internal::fixed_address_empty_string[abi:cxx11]", referenced from:
google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]() in helloworld.pb.o
google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]() in greeter_client.o
"google::protobuf::Message::GetTypeName[abi:cxx11]() const", referenced from:
vtable for helloworld::HelloReply in helloworld.pb.o
vtable for helloworld::HelloRequest in helloworld.pb.o
"google::protobuf::Message::InitializationErrorString[abi:cxx11]() const", referenced from:
vtable for helloworld::HelloReply in helloworld.pb.o
vtable for helloworld::HelloRequest in helloworld.pb.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [greeter_client] Error 1
Thanks
It could be related with wrong or corrupted version of installed ProtoBuf, because if protobuf is installed and has version more than 3.0, than gRPC building system uses system's protobuf, instread thrird-party-protobuf from subrepo. Try to remove or fix protobuf in your system.
UPDATE:
For new issues try to run "readelf -s lib???.so" for each grpc and protobuf library, and try to find this symbols in libraries. If in some library is specified "UND", than it is wrong library.
Second things that you should do, run "file lib???.so" for each grpc and protobuf library for check binary type: x86_64 or not.
I've recently installed OpenCV 3.0 from source. I then installed Dlib through Homebrew on macOS Sierra 10.12 since I want to learn more about computer vision.
I was trying to compile the facial landmark detection program found on Dlib's website and I am getting the following linker error and I have been unsuccessful in finding the right compiler flags to fix this. I'm also not sure if I actually have the required software installed.
The linker error I'm getting is:
Undefined symbols for architecture x86_64:
"_DGifCloseFile", referenced from:
void dlib::load_image<dlib::array2d<dlib::rgb_pixel, dlib::memory_manager_stateless_kernel_1<char> > >(dlib::array2d<dlib::rgb_pixel, dlib::memory_manager_stateless_kernel_1<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in face_landmark_detection-7a9d91.o
"_DGifOpenFileName", referenced from:
void dlib::load_image<dlib::array2d<dlib::rgb_pixel, dlib::memory_manager_stateless_kernel_1<char> > >(dlib::array2d<dlib::rgb_pixel, dlib::memory_manager_stateless_kernel_1<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in face_landmark_detection-7a9d91.o
"_DGifSlurp", referenced from:
void dlib::load_image<dlib::array2d<dlib::rgb_pixel, dlib::memory_manager_stateless_kernel_1<char> > >(dlib::array2d<dlib::rgb_pixel, dlib::memory_manager_stateless_kernel_1<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in face_landmark_detection-7a9d91.o
"_cblas_dgemm", referenced from:
dlib::blas_bindings::cblas_gemm(dlib::blas_bindings::CBLAS_ORDER, dlib::blas_bindings::CBLAS_TRANSPOSE, dlib::blas_bindings::CBLAS_TRANSPOSE, int, int, int, double, double const*, int, double const*, int, double, double*, int) in face_landmark_detection-7a9d91.o
"_cblas_saxpy", referenced from:
dlib::blas_bindings::cblas_axpy(int, float, float const*, int, float*, int) in face_landmark_detection-7a9d91.o
"_cblas_sscal", referenced from:
dlib::blas_bindings::cblas_scal(int, float, float*) in face_landmark_detection-7a9d91.o
"_dgesvd_", referenced from:
dlib::lapack::binding::gesvd(char, char, int, int, double*, int, double*, double*, int, double*, int, double*, int) in face_landmark_detection-7a9d91.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(I installed with --HEAD because brew install opencv3 would not work for me)
Homebrew installed OpenCV: brew tap homebrew/science; brew install --HEAD opencv3
Homebrew installed Dlib: brew install dlib
Compile flags:
g++ -std=c++11 face_landmark_detection.cpp 'pkg-config --cflags --libs opencv dlib-1'
Output of pkg-config --cflags --libs opencv dlib-1:
-I/usr/local/Cellar/opencv3/HEAD-de35c59_4/include/opencv -I/usr/local/Cellar/opencv3/HEAD-de35c59_4/include -I/usr/local/Cellar/dlib/19.1_2/include -I/usr/local/Cellar/libpng/1.6.25/include/libpng16 -L/usr/local/Cellar/opencv3/HEAD-de35c59_4/lib -L/usr/local/Cellar/dlib/19.1_2/lib -L/usr/local/Cellar/libpng/1.6.25/lib -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core -ldlib -lpng16
Can anyone please tell me which files need to be linked?
I'm trying to get OpenCV to work on my computer - for simple programs I can get it to work but for this certain program I'm unable to. The error I am getting is as follow:
Undefined symbols for architecture x86_64:
"cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)", referenced from:
_main in ccuX28GE.o
"cv::split(cv::Mat const&, std::vector<cv::Mat, std::allocator<cv::Mat> >&)", referenced from:
computeFocusDPC(std::vector<R_image, std::allocator<R_image> >, int, float, int, int, int, int, cv::Mat*) in ccuX28GE.o
qDPC_loop(std::vector<cv::Mat, std::allocator<cv::Mat> >, std::vector<cv::Mat, std::allocator<cv::Mat> >, double) in ccuX28GE.o
"cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)", referenced from:
_main in ccuX28GE.o
"cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)", referenced from:
_main in ccuX28GE.o
ld: symbol(s) not found for architecture x86_64
I'm trying to compile the file with the command line
g++-5.1.0 -o qDPC_desktop qDPC.cpp -I. -std=c++11 -ggdb -fopenmp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_stitching
I know that this error is not in the code of qDPC.cpp since it can compile on my friend's Ubuntu (I'm working on a Mac) - so I was wondering if there's something wrong with my OpenCV? I've read online online that it might be a linker problem but can't for the life of me figure this problem out. The version of OpenCV I have is 2.4.11, and the version my friend is able to compile with is 2.4.9.
All help is appreciated!
I just downloaded assimp 3.0 library and build the required make files with cmake, then compiled and build the library itself the process was successfull (with little modification to StepFile.h),
my assimp header folder is located in:
/usr/local/include
and my libassimp.a is located in:
/usr/local/lib
however when i specify library and header files in my command line project and try to test my project i get the following error:
Undefined symbols for architecture x86_64:
"Assimp::Importer::Importer()", referenced from:
_main in main.o
"Assimp::Importer::~Importer()", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
and when i add -lassimp to Other Linker Flags i get the following errors:
Undefined symbols for architecture x86_64:
"_crc32", referenced from:
_unzReadCurrentFile in libassimp.a(unzip.c.o)
"_get_crc_table", referenced from:
_unzOpenCurrentFile3 in libassimp.a(unzip.c.o)
"_inflate", referenced from:
Assimp::XGLImporter::InternReadFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, aiScene*, Assimp::IOSystem*) in libassimp.a(XGLLoader.cpp.o)
Assimp::BlenderImporter::InternReadFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, aiScene*, Assimp::IOSystem*) in libassimp.a(BlenderLoader.cpp.o)
Assimp::XFileParser::XFileParser(std::__1::vector<char, std::__1::allocator<char> > const&) in libassimp.a(XFileParser.cpp.o)
_unzReadCurrentFile in libassimp.a(unzip.c.o)
"_inflateEnd", referenced from:
Assimp::XGLImporter::InternReadFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, aiScene*, Assimp::IOSystem*) in libassimp.a(XGLLoader.cpp.o)
Assimp::BlenderImporter::InternReadFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, aiScene*, Assimp::IOSystem*) in libassimp.a(BlenderLoader.cpp.o)
Assimp::XFileParser::XFileParser(std::__1::vector<char, std::__1::allocator<char> > const&) in libassimp.a(XFileParser.cpp.o)
_unzCloseCurrentFile in libassimp.a(unzip.c.o)
"_inflateInit2_", referenced from:
Assimp::XGLImporter::InternReadFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, aiScene*, Assimp::IOSystem*) in libassimp.a(XGLLoader.cpp.o)
Assimp::BlenderImporter::InternReadFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, aiScene*, Assimp::IOSystem*) in libassimp.a(BlenderLoader.cpp.o)
Assimp::XFileParser::XFileParser(std::__1::vector<char, std::__1::allocator<char> > const&) in libassimp.a(XFileParser.cpp.o)
_unzOpenCurrentFile3 in libassimp.a(unzip.c.o)
"_inflateReset", referenced from:
Assimp::XFileParser::XFileParser(std::__1::vector<char, std::__1::allocator<char> > const&) in libassimp.a(XFileParser.cpp.o)
"_inflateSetDictionary", referenced from:
Assimp::XFileParser::XFileParser(std::__1::vector<char, std::__1::allocator<char> > const&) in libassimp.a(XFileParser.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I had the same issue recently. The actual solution for me was to ensure that the project where I was using the compiled libassimp.a also linked to libz.dylib rather than turn assimp into a .dylib.
i rebuild assimp so that the makefile yields three library files namely libassimp.3.0.255.dylib libassimp.3.dylib libassimp.dylib, i included them in my project and it worked.