I'm writing an ebuild file which used on chromiumOS.
But when i try to compile my code, i found that i can't compile my program by "emerge xxx". It work normal when i use make directly.
I get the following error lines:
smiTransfer.o: In function `lock_guard':
/usr/bin/../include/c++/v1/__mutex_base:91: undefined reference to `std::__1::mutex::lock()'
smiTransfer.o: In function `threadsafe_queue<_RECT_IN_ENCODE_Q>::push(_RECT_IN_ENCODE_Q)':
/var/tmp/portage/app-misc/test-9999/work/test-9999/./ThreadSafeQueue.hpp:35: undefined reference to `std::__1::condition_variable::notify_one()'
smiTransfer.o: In function `~lock_guard':
/usr/bin/../include/c++/v1/__mutex_base:97: undefined reference to `std::__1::mutex::unlock()'
/usr/bin/../include/c++/v1/__mutex_base:97: undefined reference to `std::__1::mutex::unlock()'
/usr/bin/../include/c++/v1/__mutex_base:97: undefined reference to `std::__1::mutex::unlock()'
/usr/bin/../include/c++/v1/__mutex_base:97: undefined reference to `std::__1::mutex::unlock()'
smiTransfer.o: In function `lock_guard':
/usr/bin/../include/c++/v1/__mutex_base:91: undefined reference to `std::__1::mutex::lock()'
smiTransfer.o: In function `~lock_guard':
/usr/bin/../include/c++/v1/__mutex_base:97: undefined reference to `std::__1::mutex::unlock()'
smiTransfer.o: In function `lock_guard':
/usr/bin/../include/c++/v1/__mutex_base:91: undefined reference to `std::__1::mutex::lock()'
smiTransfer.o: In function `~lock_guard':
/usr/bin/../include/c++/v1/__mutex_base:97: undefined reference to `std::__1::mutex::unlock()'
/usr/bin/../include/c++/v1/__mutex_base:97: undefined reference to `std::__1::mutex::unlock()'
...
collect2: error: ld returned 1 exit status
make: *** [Makefile:43: x64/test] Error 1
* ERROR: app-misc/test-9999::chromiumos failed (compile phase):
* emake failed
*
And this is my MAKEFILE:
...
LABRARYS := -lusb-1.0
CC := g++
CFLAGS += -g -Wall -O2
CXXFLAGS := -std=c++11
CPPFLAGS := $(CFLAGS)
CPPFLAGS += $(addprefix -I,$(INCLUDES))
CPPFLAGS += -MMD
...
$(EXECUTABLE) : $(OBJS)
$(CC) -o $(EXECUTABLE) $(OBJS) -L$(LIBSDIR) $(LABRARYS) -lpthread
Thank you.
Related
Am trying to build the example inspired from here
My original intention is to be able to call C++ code from within Python. I'm just running the examples from the Boost documentation in order to achieve this goal.
Here's my makefile
CXX := g++
CXX_FLAGS := -Wall -Wextra -std=c++17 -ggdb
BIN := bin
SRC := src
INCLUDE := inc
LIB := lib
BOOST_ROOT := /home/eicossa/repo/boost_install
BOOST_INCL := ${BOOST_ROOT}/include/
BOOST_LIBS := ${BOOST_ROOT}/libs/
PYTHON_INCL := /usr/include/python3.7m/
PYTHON_LIBS := /usr/lib/python3.7/
LIBFLAGS := -lboost_system
EXECUTABLE := greet
all: $(BIN)/$(EXECUTABLE)
run: clean all
clear
./$(BIN)/$(EXECUTABLE)
$(BIN)/$(EXECUTABLE): $(SRC)/*.cpp
$(CXX) $(CXX_FLAGS) -I$(PYTHON_INCL) -I$(INCLUDE) -I$(BOOST_INCL) -L$(BOOST_LIBS) -L$(PYTHON_LIBS) -L$(LIB$
clean:
-rm $(BIN)/*
This leads to the following errors
/tmp/ccNVjFX3.o: In function boost::python::api::object::object()':
/home/eicossa/repo/boost_install/include/boost/python/object_core.hpp:400:
undefined reference to_Py_NoneStruct' /tmp/ccQNpbxG.o: In function
PyInit_hello_ext':
/home/eicossa/Dropbox/wtcd/license/boost/src/bindings.cpp:3: undefined
reference toboost::python::detail::init_module(PyModuleDef&, void
()())' /tmp/ccQNpbxG.o: In function boost::python::type_info::name()
const':
/home/eicossa/repo/boost_install/include/boost/python/type_id.hpp:160:
undefined reference toboost::python::detail::gcc_demangle(char
const)' /tmp/ccQNpbxG.o: In function
boost::python::to_python_value<char const* const&>::operator()(char
const* const&) const':
/home/eicossa/repo/boost_install/include/boost/python/converter/builtin_converters.hpp:157:
undefined reference to
boost::python::converter::do_return_to_python(char const*)'
/tmp/ccQNpbxG.o: In function boost::python::to_python_value<char
const* const&>::get_pytype() const':
/home/eicossa/repo/boost_install/include/boost/python/converter/builtin_converters.hpp:157:
undefined reference toPyUnicode_Type' /tmp/ccQNpbxG.o: In function
void boost::python::def<char const* (*)()>(char const*, char const*
(*)())':
/home/eicossa/repo/boost_install/include/boost/python/def.hpp:91:
undefined reference toboost::python::detail::scope_setattr_doc(char
const*, boost::python::api::object const&, char const*)'
/tmp/ccQNpbxG.o: In function `boost::python::api::object
boost::python::detail::make_function_aux
(char const* (*)(), boost::python::default_call_policies const&, boost::mpl::vector1 const&)':
/home/eicossa/repo/boost_install/include/boost/python/make_function.hpp:38:
undefined reference to
boost::python::objects::function_object(boost::python::objects::py_function
const&)' /tmp/ccQNpbxG.o: In function
boost::python::objects::py_function_impl_base::py_function_impl_base()':
/home/eicossa/repo/boost_install/include/boost/python/object/py_function.hpp:20:
undefined reference to vtable for
boost::python::objects::py_function_impl_base'
/tmp/ccQNpbxG.o:(.rodata._ZTVN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFPKcvENS0_21default_call_policiesENS_3mpl7vector1IS6_EEEEEE[_ZTVN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFPKcvENS0_21default_call_policiesENS_3mpl7vector1IS6_EEEEEE]+0x30):
undefined reference to
boost::python::objects::py_function_impl_base::max_arity() const'
/tmp/ccQNpbxG.o: In function
boost::python::objects::caller_py_function_impl<boost::python::detail::caller<char
const* (*)(), boost::python::default_call_policies,
boost::mpl::vector1<char const*> > >::~caller_py_function_impl()':
/home/eicossa/repo/boost_install/include/boost/python/object/py_function.hpp:30:
undefined reference to
boost::python::objects::py_function_impl_base::~py_function_impl_base()'
/tmp/ccQNpbxG.o:(.rodata._ZTIN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFPKcvENS0_21default_call_policiesENS_3mpl7vector1IS6_EEEEEE[_ZTIN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFPKcvENS0_21default_call_policiesENS_3mpl7vector1IS6_EEEEEE]+0x10):
undefined reference to typeinfo for
boost::python::objects::py_function_impl_base' /tmp/ccQNpbxG.o: In
functionboost::python::converter::expected_pytype_for_arg::get_pytype()':
/home/eicossa/repo/boost_install/include/boost/python/converter/pytype_function.hpp:69:
undefined reference to
boost::python::converter::registry::query(boost::python::type_info)'
/home/eicossa/repo/boost_install/include/boost/python/converter/pytype_function.hpp:70:
undefined reference to
boost::python::converter::registration::expected_from_python_type()
const' collect2: error: ld returned 1 exit status Makefile:27: recipe
for target 'bin/greet' failed make: *** [bin/greet] Error 1
What am i doing wrong ?
CXX := g++
CXX_FLAGS := -Wall -Wextra -std=c++17 -ggdb
BIN := bin
SRC := src
INCLUDE := inc
LIB := lib
BOOST_ROOT := /home/eicossa/repo/boost_install
BOOST_INCL := ${BOOST_ROOT}/include/
BOOST_LIBS := ${BOOST_ROOT}/libs/
PYTHON_INCL := /usr/include/python3.7m/
PYTHON_LIBS := /usr/lib/python3.7/
LIBFLAGS := -lboost_system -lboost_python37 -lpython3.7m #changes made here
EXECUTABLE := greet
all: $(BIN)/$(EXECUTABLE)
run: clean all
clear
./$(BIN)/$(EXECUTABLE)
$(BIN)/$(EXECUTABLE): $(SRC)/*.cpp
$(CXX) $(CXX_FLAGS) -I$(PYTHON_INCL) -I$(INCLUDE) -I$(BOOST_INCL) -L$(BOOST_LIBS) -L$(PYTHON_LIBS) -L$(LIB$
clean:
-rm $(BIN)/*
Try out these changes in the Makefile
This is probably trivial. I'm using Qt with the Tableau C++ api and I am having a bad time trying to get things to link appropriately.
I have the following directory structure.
allenh1#localhost ~/CS/tableau-api/tableau-qt
$ ls
bin include lib64 share src tableau-qt.pro ui
Here's the .pro file
QT += core gui widgets
CONFIG += c++14
TARGET = qt-tableau-demo
TEMPLATE = app
# Link with the Tableau SDK library files
QMAKE_RPATHDIR += lib64/tableausdk
SOURCES += src/main.cpp \
src/TableauTable.cpp
HEADERS += include/TableauTable.hpp
Note: the UI is not implemented yet, but will be after I get this to compile.
When I try to build it, I get the following:
allenh1#localhost ~/CS/tableau-api/tableau-qt
$ make
g++ -c -pipe -O2 -std=gnu++1y -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../../../../Qt/5.6/gcc_64/include -I../../../../Qt/5.6/gcc_64/include/QtWidgets -I../../../../Qt/5.6/gcc_64/include/QtGui -I../../../../Qt/5.6/gcc_64/include/QtCore -I. -I../../../../Qt/5.6/gcc_64/mkspecs/linux-g++ -o main.o src/main.cpp
In file included from src/../include/tableau-sdk/TableauExtract.hpp:18:0,
from src/../include/TableauTable.hpp:3,
from src/main.cpp:2:
src/../include/tableau-sdk/TableauCommon.hpp:144:38: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
const TAB_RESULT GetResultCode() const { return m_result; }
^
src/main.cpp:14:14: warning: unused parameter 'argc' [-Wunused-parameter]
int main(int argc, char *argv[])
^
src/main.cpp:14:31: warning: unused parameter 'argv' [-Wunused-parameter]
int main(int argc, char *argv[])
^
g++ -c -pipe -O2 -std=gnu++1y -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../../../../Qt/5.6/gcc_64/include -I../../../../Qt/5.6/gcc_64/include/QtWidgets -I../../../../Qt/5.6/gcc_64/include/QtGui -I../../../../Qt/5.6/gcc_64/include/QtCore -I. -I../../../../Qt/5.6/gcc_64/mkspecs/linux-g++ -o TableauTable.o src/TableauTable.cpp
In file included from src/../include/tableau-sdk/TableauExtract.hpp:18:0,
from src/../include/TableauTable.hpp:3,
from src/TableauTable.cpp:1:
src/../include/tableau-sdk/TableauCommon.hpp:144:38: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
const TAB_RESULT GetResultCode() const { return m_result; }
^
g++ -Wl,-O1 -Wl,-z,origin -Wl,-rpath,\$ORIGIN/lib64/tableausdk -Wl,-rpath,/home/allenh1/Qt/5.6/gcc_64/lib -o perscio-tableau-demo main.o TableauTable.o -L/home/allenh1/Qt/5.6/gcc_64/lib -lQt5Widgets -L/usr/lib64 -lQt5Gui -lQt5Core -lGL -lpthread
main.o: In function `fill_table(TableauTable*&)':
main.cpp:(.text+0x88): undefined reference to `bool TableauTable::add_column<std::type_info const&>(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, std::type_info const&)'
main.cpp:(.text+0xc6): undefined reference to `bool TableauTable::add_column<std::type_info const&>(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, std::type_info const&)'
main.cpp:(.text+0xfd): undefined reference to `bool TableauTable::add_column<std::type_info const&>(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, std::type_info const&)'
TableauTable.o: In function `Tableau::(anonymous namespace)::MakeTableauString(wchar_t const*)':
TableauTable.cpp:(.text+0x48): undefined reference to `ToTableauString'
TableauTable.o: In function `TableauTable::TableauTable()':
TableauTable.cpp:(.text+0x1b0): undefined reference to `TabTableDefinitionCreate'
TableauTable.cpp:(.text+0x1ba): undefined reference to `TAB_RESULT_Success'
TableauTable.cpp:(.text+0x1ef): undefined reference to `TabTableDefinitionSetDefaultCollation'
TableauTable.cpp:(.text+0x22d): undefined reference to `TabGetLastErrorMessage'
TableauTable.cpp:(.text+0x2a7): undefined reference to `TabGetLastErrorMessage'
TableauTable.o: In function `TableauTable::init(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >)':
TableauTable.cpp:(.text+0x42b): undefined reference to `TabExtractAPIInitialize'
TableauTable.cpp:(.text+0x434): undefined reference to `TAB_RESULT_Success'
TableauTable.cpp:(.text+0x47f): undefined reference to `TabExtractCreate'
TableauTable.cpp:(.text+0x509): undefined reference to `TabExtractHasTable'
TableauTable.cpp:(.text+0x5ff): undefined reference to `TabTableDefinitionCreate'
TableauTable.cpp:(.text+0x65f): undefined reference to `TabExtractAddTable'
TableauTable.cpp:(.text+0x721): undefined reference to `TabTableDefinitionClose'
TableauTable.cpp:(.text+0x74b): undefined reference to `TabGetLastErrorMessage'
TableauTable.cpp:(.text+0x7f7): undefined reference to `TabExtractOpenTable'
TableauTable.cpp:(.text+0x8b9): undefined reference to `TabTableGetTableDefinition'
TableauTable.cpp:(.text+0x8c2): undefined reference to `TAB_RESULT_Success'
TableauTable.cpp:(.text+0x8df): undefined reference to `TabTableDefinitionCreate'
TableauTable.cpp:(.text+0xd0e): undefined reference to `TabGetLastErrorMessage'
TableauTable.cpp:(.text+0xe09): undefined reference to `TabGetLastErrorMessage'
TableauTable.cpp:(.text+0xe78): undefined reference to `TabGetLastErrorMessage'
TableauTable.cpp:(.text+0xef7): undefined reference to `TabGetLastErrorMessage'
TableauTable.cpp:(.text+0xf97): undefined reference to `TabGetLastErrorMessage'
TableauTable.o:TableauTable.cpp:(.text+0xffa): more undefined references to `TabGetLastErrorMessage' follow
TableauTable.o: In function `std::_Sp_counted_ptr<Tableau::TableDefinition*, (__gnu_cxx::_Lock_policy)2>::_M_dispose()':
TableauTable.cpp:(.text._ZNSt15_Sp_counted_ptrIPN7Tableau15TableDefinitionELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv[_ZNSt15_Sp_counted_ptrIPN7Tableau15TableDefinitionELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv]+0x2a): undefined reference to `TabTableDefinitionClose'
TableauTable.cpp:(.text._ZNSt15_Sp_counted_ptrIPN7Tableau15TableDefinitionELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv[_ZNSt15_Sp_counted_ptrIPN7Tableau15TableDefinitionELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv]+0x33): undefined reference to `TAB_RESULT_Success'
TableauTable.cpp:(.text._ZNSt15_Sp_counted_ptrIPN7Tableau15TableDefinitionELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv[_ZNSt15_Sp_counted_ptrIPN7Tableau15TableDefinitionELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv]+0x76): undefined reference to `TabGetLastErrorMessage'
TableauTable.o: In function `Tableau::TableDefinition::Close()':
TableauTable.cpp:(.text._ZN7Tableau15TableDefinition5CloseEv[_ZN7Tableau15TableDefinition5CloseEv]+0x24): undefined reference to `TabTableDefinitionClose'
TableauTable.cpp:(.text._ZN7Tableau15TableDefinition5CloseEv[_ZN7Tableau15TableDefinition5CloseEv]+0x2d): undefined reference to `TAB_RESULT_Success'
TableauTable.cpp:(.text._ZN7Tableau15TableDefinition5CloseEv[_ZN7Tableau15TableDefinition5CloseEv]+0x68): undefined reference to `TabGetLastErrorMessage'
collect2: error: ld returned 1 exit status
Makefile:200: recipe for target 'qt-tableau-demo' failed
make: *** [qt-tableau-demo] Error 1
The .so files needed (at least to my understanding) are located in the lib64 directory.
allenh1#localhost ~/CS/tableau-api/tableau-qt
$ ls lib64/tableausdk
Java libboost_thread.so libicuuc.so.44
libQt5Core.so.5 libboost_thread.so.1.56.0 libicuuc.so.44.0
libQt5Core.so.5.4.1 libcurl.so libmetrics2.so
libQt5Network.so.5 libcurl.so.4 libtabcrypto.so
libQt5Network.so.5.4.1 libcurl.so.4.4.0 libtabcrypto.so.1.0.0
libTableauCommon.so libexpat.so libtabssl.so
libTableauExtract.so libexpat.so.1 libtabssl.so.1.0.0
libTableauServer.so libexpat.so.1.6.0 libtabsys.so
libboost_chrono.so libicudata.so.44 libtabz.so
libboost_chrono.so.1.56.0 libicudata.so.44.0 libtabz.so.1
libboost_date_time.so libicui18n.so.44 libtabz.so.1.2.8
libboost_date_time.so.1.56.0 libicui18n.so.44.0 libtbb.so.2
libboost_system.so libicuio.so.44 libtbbmalloc.so.2
libboost_system.so.1.56.0 libicuio.so.44.0
I need to include dlib in a c++ project. I have properly linked the library in my Makefile. Here is the Makefile:
EXE = face_frontalization
OBJ_DIR = bin
CFLAGS = -g -w
# CXXFLAGS = -w -Wall -Wextra -g -std=c++0x
# LDFLAGS = -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lSDL2_gfx -lm
dummy_build_folder := $(shell mkdir -p $(OBJ_DIR))
# c++ source files of the project
CXXFILES = $(shell find src -type f -name '*.cpp')
CXXOBJ = $(patsubst src/%.cpp,bin/%.o,$(CXXFILES))
INCLUDE = -I/usr/include/dlib-18.18
LIBS = `pkg-config --libs opencv`
CXXFLAGS = `pkg-config --cflags opencv` -w -Wall -Wextra -g -std=c++0x
LDFLAGS = -lcurl
CFLAGS = `pkg-config --cflags opencv` -g -w
MKDIR = mkdir -p
ifdef V
MUTE =
VTAG = -v
else
MUTE = #
endif
###################################################################
# This is a Makefile progress indicator.
# BUILD is initially undefined
ifndef BUILD
# max equals 256 x's
sixteen := x x x x x x x x x x x x x x x x
MAX := $(foreach x,$(sixteen),$(sixteen))
# T estimates how many targets we are building by replacing BUILD with
# a special string
T := $(shell $(MAKE) -nrRf $(firstword $(MAKEFILE_LIST)) $(MAKECMDGOALS) \
BUILD="COUNTTHIS" | grep -c "COUNTTHIS")
# N is the number of pending targets in base 1, well in fact, base x
# :-)
N := $(wordlist 1,$T,$(MAX))
# auto-decrementing counter that returns the number of pending targets
# in base 10
counter = $(words $N)$(eval N := $(wordlist 2,$(words $N),$N))
# BUILD is now defined to show the progress, this also avoids
# redefining T in loop
BUILD = #echo $(counter) of $(T)
endif
###################################################################
# .PHONY: directories all
#
# directories: ${OUT_DIR}
# ${OUT_DIR}:
# ${MKDIR} ${OUT_DIR}
all: $(EXE)
# build successful
$(EXE): $(CXXOBJ)
$(CXX) $(CXXOBJ) -o $(EXE) $(LIBS) $(LDFLAGS)
$(OBJ_DIR)/%.o: src/%.cpp
$(CXX) $(CXXFLAGS) $(INCLUDE) $< -c -o $#
$(BUILD)
$(OBJ_DIR)/%.o: src/%.c
$(CC) $(CFLAGS) $(INCLUDE) $< -c -o $#
run: all
./$(EXE)
clean:
# Cleaning...
-rm -f $(EXE) $(CXXOBJ)
rmdir bin/
I dont know why but its giving errors on compilation. I have compiled the dlib library itself too and the code examples are running as they should.
The error I am getting is:
bin/fatialfeaturedetect.o: In function `fatial_feature_detector()':
/home/playroom/Desktop/face-frontalization/src/fatialfeaturedetect.cpp:20: undefined reference to `dlib::base_window::wait_until_closed() const'
/home/playroom/Desktop/face-frontalization/src/fatialfeaturedetect.cpp:18: undefined reference to `dlib::image_window::~image_window()'
/home/playroom/Desktop/face-frontalization/src/fatialfeaturedetect.cpp:18: undefined reference to `dlib::image_window::~image_window()'
bin/fatialfeaturedetect.o: In function `dlib::get_serialized_frontal_faces()':
/usr/include/dlib-18.18/dlib/image_processing/frontal_face_detector.h:115: undefined reference to `dlib::base64::base64()'
/usr/include/dlib-18.18/dlib/image_processing/frontal_face_detector.h:2358: undefined reference to `dlib::base64::decode(std::istream&, std::ostream&) const'
/usr/include/dlib-18.18/dlib/image_processing/frontal_face_detector.h:2367: undefined reference to `dlib::base64::~base64()'
/usr/include/dlib-18.18/dlib/image_processing/frontal_face_detector.h:2367: undefined reference to `dlib::base64::~base64()'
bin/fatialfeaturedetect.o: In function `dlib_check_consistent_assert_usage':
/usr/include/dlib-18.18/dlib/gui_widgets/../gui_core/../threads/threads_kernel_shared.h:44: undefined reference to `USER_ERROR__missing_dlib_all_source_cpp_file__OR__inconsistent_use_of_DEBUG_or_ENABLE_ASSERTS_preprocessor_directives_'
bin/fatialfeaturedetect.o: In function `dlib::drawable_window::drawable_window(bool, bool)':
/usr/include/dlib-18.18/dlib/gui_widgets/drawable.h:79: undefined reference to `dlib::base_window::base_window(bool, bool)'
/usr/include/dlib-18.18/dlib/gui_widgets/drawable.h:79: undefined reference to `vtable for dlib::drawable_window'
/usr/include/dlib-18.18/dlib/gui_widgets/drawable.h:79: undefined reference to `dlib::base_window::~base_window()'
bin/fatialfeaturedetect.o: In function `dlib::drawable_window::~drawable_window()':
/usr/include/dlib-18.18/dlib/gui_widgets/drawable.h:195: undefined reference to `vtable for dlib::drawable_window'
/usr/include/dlib-18.18/dlib/gui_widgets/drawable.h:195: undefined reference to `dlib::base_window::close_window()'
/usr/include/dlib-18.18/dlib/gui_widgets/drawable.h:195: undefined reference to `dlib::base_window::~base_window()'
bin/fatialfeaturedetect.o: In function `dlib::scrollable_region_style_default::draw_scrollable_region_border(dlib::canvas const&, dlib::rectangle const&, bool) const':
/usr/include/dlib-18.18/dlib/gui_widgets/style.h:527: undefined reference to `dlib::draw_sunken_rectangle(dlib::canvas const&, dlib::rectangle const&, unsigned char)'
bin/fatialfeaturedetect.o: In function `dlib::image_display::disable_overlay_editing()':
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3485: undefined reference to `dlib::base_window::invalidate_rectangle(dlib::rectangle const&)'
bin/fatialfeaturedetect.o: In function `dlib::compress_stream_kernel_1<dlib::entropy_encoder_model_kernel_5<257ul, dlib::entropy_encoder_kernel_2, 200000ul, 4ul>, dlib::entropy_decoder_model_kernel_5<257ul, dlib::entropy_decoder_kernel_2, 200000ul, 4ul>, dlib::crc32>::decompress(std::istream&, std::ostream&) const':
/usr/include/dlib-18.18/dlib/image_processing/../compress_stream/compress_stream_kernel_1.h:180: undefined reference to `dlib::entropy_decoder_kernel_2::entropy_decoder_kernel_2()'
/usr/include/dlib-18.18/dlib/image_processing/../compress_stream/compress_stream_kernel_1.h:181: undefined reference to `dlib::entropy_decoder_kernel_2::set_stream(std::istream&)'
/usr/include/dlib-18.18/dlib/image_processing/../compress_stream/compress_stream_kernel_1.h:196: undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../compress_stream/compress_stream_kernel_1.h:201: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../compress_stream/compress_stream_kernel_1.h:243: undefined reference to `dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()'
/usr/include/dlib-18.18/dlib/image_processing/../compress_stream/compress_stream_kernel_1.h:243: undefined reference to `dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()'
bin/fatialfeaturedetect.o: In function `void dlib::image_window::add_overlay<dlib::rgb_pixel>(std::vector<dlib::rectangle, std::allocator<dlib::rectangle> > const&, dlib::rgb_pixel)':
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3968: undefined reference to `dlib::image_window::add_overlay(std::vector<dlib::image_display::overlay_rect, std::allocator<dlib::image_display::overlay_rect> > const&)'
bin/fatialfeaturedetect.o: In function `dlib::image_window::image_window<dlib::array2d<dlib::rgb_pixel, dlib::memory_manager_stateless_kernel_1<char> > >(dlib::array2d<dlib::rgb_pixel, dlib::memory_manager_stateless_kernel_1<char> > const&)':
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3883: undefined reference to `vtable for dlib::image_window'
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3883: undefined reference to `dlib::image_display::image_display(dlib::drawable_window&)'
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3885: undefined reference to `dlib::image_window::on_image_clicked(dlib::vector<long, 2l> const&, bool, unsigned long)'
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3888: undefined reference to `dlib::base_window::show()'
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3883: undefined reference to `dlib::image_display::~image_display()'
bin/fatialfeaturedetect.o: In function `dlib::entropy_decoder_model_kernel_5<257ul, dlib::entropy_decoder_kernel_2, 200000ul, 4ul>::decode(unsigned long&)':
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:422: undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:456: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:503: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:551: undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:553: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
bin/fatialfeaturedetect.o: In function `void dlib::image_window::set_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> > const&)':
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3930: undefined reference to `dlib::image_display::get_image_display_rect() const'
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3934: undefined reference to `dlib::base_window::set_size(int, int)'
bin/fatialfeaturedetect.o: In function `void dlib::load_dng<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::istream&)':
/usr/include/dlib-18.18/dlib/image_loader/image_loader.h:585: undefined reference to `dlib::entropy_decoder_kernel_2::entropy_decoder_kernel_2()'
/usr/include/dlib-18.18/dlib/image_loader/image_loader.h:586: undefined reference to `dlib::entropy_decoder_kernel_2::set_stream(std::istream&)'
/usr/include/dlib-18.18/dlib/image_loader/image_loader.h:757: undefined reference to `dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()'
/usr/include/dlib-18.18/dlib/image_loader/image_loader.h:771: undefined reference to `dlib::entropy_decoder_kernel_2::entropy_decoder_kernel_2()'
/usr/include/dlib-18.18/dlib/image_loader/image_loader.h:772: undefined reference to `dlib::entropy_decoder_kernel_2::set_stream(std::istream&)'
/usr/include/dlib-18.18/dlib/image_loader/image_loader.h:771: undefined reference to `dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()'
/usr/include/dlib-18.18/dlib/image_loader/image_loader.h:757: undefined reference to `dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()'
/usr/include/dlib-18.18/dlib/image_loader/image_loader.h:771: undefined reference to `dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()'
bin/fatialfeaturedetect.o: In function `void dlib::image_display::set_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> > const&)':
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3272: undefined reference to `dlib::scrollable_region::set_total_rect_size(unsigned long, unsigned long)'
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3274: undefined reference to `dlib::scrollable_region::set_total_rect_size(unsigned long, unsigned long)'
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3278: undefined reference to `dlib::base_window::invalidate_rectangle(dlib::rectangle const&)'
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3283: undefined reference to `dlib::popup_menu_region::disable()'
bin/fatialfeaturedetect.o: In function `dlib::entropy_decoder_model_kernel_5<256ul, dlib::entropy_decoder_kernel_2, 200000ul, 4ul>::decode(unsigned long&)':
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:422: undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:456: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:503: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:551: undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:553: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
bin/fatialfeaturedetect.o: In function `dlib::entropy_decoder_model_kernel_4<256ul, dlib::entropy_decoder_kernel_2, 200000ul, 4ul>::decode(unsigned long&)':
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_4.h:348: undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_4.h:376: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_4.h:422: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_4.h:469: undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_4.h:471: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
collect2: error: ld returned 1 exit status
make: *** [face_frontalization] Error 1
I cant figure out what I have done in linking the library to the project. Please help.
Dlib is partially header-based and some functions need to have libdlib.a linked to a project
You have two ways how to solve your problem:
link to dlib: LDFLAGS = -ldlib (dlib should be installed or its path provided to linker)
add dlib/all/source.cpp to your project sources list(CXXFILES)
If this error is present during compilation with dLib:
/usr/bin/ld: /tmp/ccps6CPH.o: undefined reference to symbol 'pthread_create##GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status make: *** [face_frontalization] Error 1
There is a good probability that X11 is missing. I dont know what it is so if somebody does, please tell me. Solution is to just add -lX11 to the LDFLAGS in order to link with it. If you dont want it, you can also specify compiler option -DDLIB_NO_GUI_SUPPORT.
(NOTE: I haven't tested it and dont know what X11 does so better include it than exclude it.)
I'm trying to compile and link the following opencv program that I found online:
main.cpp:
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/videoio.hpp>
#include <iostream>
#include <stdio.h>
using namespace std;
using namespace cv;
int main( int argc, const char** argv )
{
VideoCapture capture(0);
while(capture.isOpened() )
{
Mat frame;
if (! capture.read(frame))
continue;
imshow("lalala", frame);
if(waitKey(10) == 27)
break;
}
return 0;
}
My filestructure is as follows:
~/dev/opencv-1
~/dev/opencv-example
The opencv-1 is a git clone of: https://github.com/Itseez/opencv
I followed the instructions located at: http://docs.opencv.org/trunk/doc/tutorials/introduction/linux_install/linux_install.html
My goal was to debug into the opencv code, so I used the CMAKE_BUILD_TYPE=Debug
I was able to get the opencv code to compile sucessfuly. I wrote the following makefile to compile this sample:
INCPATH =-I../opencv-1/modules/objdetect/include \
-I../opencv-1/modules/highgui/include \
-I../opencv-1/modules/imgproc/include \
-I../opencv-1/modules/core/include \
-I../opencv-1/modules/imgcodecs/include \
-I../opencv-1/modules/videoio/include \
LIBPATH =-L../opencv-1/debug/lib
LIBS =-lopencv_core -lopencv_videoio -lopencv_highgui -lopencv_imgproc -lopencv_video -lopencv_objdetect
%:%.cpp
g++ $(INCPATH) $(LIBS) $(LIBPATH) $^ -o $#
To compile I ran: make main
When this happens, I get the following linking errors:
g++ -I../opencv-1/modules/objdetect/include -I../opencv-1/modules/highgui/include -I../opencv-1/module s/imgproc/include -I../opencv-1/modules/core/include -I../opencv-1/modules/imgcodecs/include -I../open cv-1/modules/videoio/include -lopencv_core -lopencv_videoio -lopencv_highgui -lopencv_imgproc -lopenc v_video -lopencv_objdetect -L../opencv-1/debug/lib main.cpp -o main
/tmp/cc0PMDdW.o: In function `main':
main.cpp:(.text+0x29): undefined reference to `cv::VideoCapture::VideoCapture(int)'
main.cpp:(.text+0x69): undefined reference to `cv::VideoCapture::read(cv::_OutputArray const&)'
main.cpp:(.text+0xce): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
main.cpp:(.text+0xf6): undefined reference to `cv::waitKey(int)'
main.cpp:(.text+0x131): undefined reference to `cv::VideoCapture::isOpened() const'
main.cpp:(.text+0x14d): undefined reference to `cv::VideoCapture::~VideoCapture()'
main.cpp:(.text+0x1b0): undefined reference to `cv::VideoCapture::~VideoCapture()'
/tmp/cc0PMDdW.o: In function `cv::String::String(char const*)':
main.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x4f): undefined reference to `cv::String::al locate(unsigned long)'
/tmp/cc0PMDdW.o: In function `cv::String::~String()':
main.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallo cate()'
/tmp/cc0PMDdW.o: In function `cv::_InputArray::_InputArray()':
main.cpp:(.text._ZN2cv11_InputArrayC2Ev[_ZN2cv11_InputArrayC5Ev]+0x13): undefined reference to `vtable for cv::_InputArray'
/tmp/cc0PMDdW.o: In function `cv::_InputArray::_InputArray(cv::Mat const&)':
main.cpp:(.text._ZN2cv11_InputArrayC2ERKNS_3MatE[_ZN2cv11_InputArrayC5ERKNS_3MatE]+0x17): undefined re ference to `vtable for cv::_InputArray'
/tmp/cc0PMDdW.o: In function `cv::_InputArray::~_InputArray()':
main.cpp:(.text._ZN2cv11_InputArrayD2Ev[_ZN2cv11_InputArrayD5Ev]+0x13): undefined reference to `vtable for cv::_InputArray'
/tmp/cc0PMDdW.o: In function `cv::_OutputArray::_OutputArray(cv::Mat&)':
main.cpp:(.text._ZN2cv12_OutputArrayC2ERNS_3MatE[_ZN2cv12_OutputArrayC5ERNS_3MatE]+0x23): undefined re ference to `vtable for cv::_OutputArray'
/tmp/cc0PMDdW.o: In function `cv::_OutputArray::~_OutputArray()':
main.cpp:(.text._ZN2cv12_OutputArrayD2Ev[_ZN2cv12_OutputArrayD5Ev]+0x13): undefined reference to `vtab le for cv::_OutputArray'
/tmp/cc0PMDdW.o: In function `cv::Mat::~Mat()':
main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)'
/tmp/cc0PMDdW.o: In function `cv::Mat::release()':
main.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference to `cv::Mat::dea llocate()'
collect2: error: ld returned 1 exit status
make: *** [main] Error 1
I'm not sure what I'm missing. I've included all of the libraries that this simple program should need to compile. I've searched online for similar errors and all of the answers I've seen suggest adding the libraries that are already in my makefile.
Your problem is that this line:
g++ $(INCPATH) $(LIBS) $(LIBPATH) $^ -o $#
Should be re-written like this:
$(CXX) $(INCPATH) $(LIBPATH) $^ $(LIBS) -o $#
The variable containing -l flags should always go after the .cpp or .o files in the command line.
But you can do better. Your Makefile should ultimately look like this:
CPPFLAGS := -I../opencv-1/modules/objdetect/include \
-I../opencv-1/modules/highgui/include \
-I../opencv-1/modules/imgproc/include \
-I../opencv-1/modules/core/include \
-I../opencv-1/modules/imgcodecs/include \
-I../opencv-1/modules/videoio/include
LDFLAGS := -L../opencv-1/debug/lib
LDLIBS := -lopencv_core -lopencv_videoio -lopencv_highgui \
-lopencv_imgproc -lopencv_video -lopencv_objdetect
Nothing more, nothing less. GNU Make already has an implicit rule to compile a .cpp file into an executable, just rely on it by using the built-in variables.
Note: CPPFLAGS stands for preprocessor flags, not c++ flags. Use CXXFLAGS to provide flags such as -std or -g flags.
After significant bit of searching around, I am still feeling quite clueless as to what is going on.
I have written a OpenCV simple application (more-or-less based on a tutorial), but getting it build has been a challenge. Here's the code:-
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cv.h>
#include <highgui.h>
int main()
{
CvCapture *cam;
cam = cvCaptureFromFile("http://icarus#cocodyn.dynip.net:2002/videostream.cgi");
if (cam == NULL) {
printf("camera is null\n");
}
else {
printf("camera is non-null\n");
}
cvNamedWindow("Mycam", 0);
while (cvWaitKey(10) != atoi("q")) {
double t1 = (double) cvGetTickCount();
IplImage *img = cvQueryFrame(cam);
double t2 = (double) cvGetTickCount();
printf("time: %gms fps: %.2g\n", (t2-t1)/(cvGetTickFrequency() * 1000.), 1000./((t2-t1)/(cvGetTickFrequency() * 1000.)));
cvShowImage("Mycam", img);
}
cvReleaseCapture(&cam);
}
And here's what my Makefile looks like:
ipcamcap: ipcamcap.c
g++ `pkg-config --cflags --libs opencv` -o ipcamcap ipcamcap.c
Finally, here are the errors I get --
/home/icarus/Projects/ipcamcap$ make
g++ `pkg-config --cflags --libs opencv` -o ipcamcap ipcamcap.c
/tmp/ccV5YLqQ.o: In function `main':
ipcamcap.c:(.text+0xf): undefined reference to `cvCreateFileCapture'
ipcamcap.c:(.text+0x41): undefined reference to `cvNamedWindow'
ipcamcap.c:(.text+0x4b): undefined reference to `cvGetTickCount'
ipcamcap.c:(.text+0x61): undefined reference to `cvQueryFrame'
ipcamcap.c:(.text+0x6a): undefined reference to `cvGetTickCount'
ipcamcap.c:(.text+0x8c): undefined reference to `cvGetTickFrequency'
ipcamcap.c:(.text+0xd6): undefined reference to `cvGetTickFrequency'
ipcamcap.c:(.text+0x118): undefined reference to `cvShowImage'
ipcamcap.c:(.text+0x122): undefined reference to `cvWaitKey'
ipcamcap.c:(.text+0x147): undefined reference to `cvReleaseCapture'
collect2: ld returned 1 exit status
make: *** [ipcamcap] Error 1
/home/icarus/Projects/ipcamcap$
On the host, I can see that --
/home/icarus/Projects/ipcamcap$ echo `pkg-config --cflags --libs opencv`
-I/usr/local/include/opencv -I/usr/local/include -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
/home/icarus/Projects/ipcamcap$
And, I do have the libs on this host as well --
/home/icarus/Projects/ipcamcap$ ls -l /usr/local/lib/libopencv_core.so*
lrwxrwxrwx 1 root root 21 2012-02-28 11:44 /usr/local/lib/libopencv_core.so -> libopencv_core.so.2.3
lrwxrwxrwx 1 root root 23 2012-02-28 11:44 /usr/local/lib/libopencv_core.so.2.3 -> libopencv_core.so.2.3.1
-rw-r--r-- 1 root root 2169691 2012-02-28 11:16 /usr/local/lib/libopencv_core.so.2.3.1
of course, apart from all the other OpenCV libraries.
Edited:
Note that I started with compiling the program with "gcc" compiler, but the errors were lot more, like -
gcc `pkg-config --cflags --libs opencv` -o ipcamcap ipcamcap.c
/tmp/cc9zt8fA.o: In function `cvDecRefData':
ipcamcap.c:(.text+0x9f2): undefined reference to `cvFree_'
ipcamcap.c:(.text+0xa7a): undefined reference to `cvFree_'
/tmp/cc9zt8fA.o: In function `cvGetRow':
ipcamcap.c:(.text+0xb91): undefined reference to `cvGetRows'
/tmp/cc9zt8fA.o: In function `cvGetCol':
ipcamcap.c:(.text+0xbbf): undefined reference to `cvGetCols'
/tmp/cc9zt8fA.o: In function `cvReleaseMatND':
ipcamcap.c:(.text+0xbd9): undefined reference to `cvReleaseMat'
/tmp/cc9zt8fA.o: In function `cvSubS':
ipcamcap.c:(.text+0xd35): undefined reference to `cvAddS'
/tmp/cc9zt8fA.o: In function `cvCloneSeq':
ipcamcap.c:(.text+0xd6e): undefined reference to `cvSeqSlice'
/tmp/cc9zt8fA.o: In function `cvSetNew':
ipcamcap.c:(.text+0xddb): undefined reference to `cvSetAdd'
/tmp/cc9zt8fA.o: In function `cvGetSetElem':
ipcamcap.c:(.text+0xe84): undefined reference to `cvGetSeqElem'
/tmp/cc9zt8fA.o: In function `cvEllipseBox':
ipcamcap.c:(.text+0xf69): undefined reference to `cvEllipse'
/tmp/cc9zt8fA.o: In function `cvFont':
ipcamcap.c:(.text+0xfa6): undefined reference to `cvInitFont'
/tmp/cc9zt8fA.o: In function `cvReadIntByName':
ipcamcap.c:(.text+0x1094): undefined reference to `cvGetFileNodeByName'
/tmp/cc9zt8fA.o: In function `cvReadRealByName':
ipcamcap.c:(.text+0x1147): undefined reference to `cvGetFileNodeByName'
/tmp/cc9zt8fA.o: In function `cvReadStringByName':
ipcamcap.c:(.text+0x11bd): undefined reference to `cvGetFileNodeByName'
/tmp/cc9zt8fA.o: In function `cvReadByName':
ipcamcap.c:(.text+0x11fd): undefined reference to `cvGetFileNodeByName'
ipcamcap.c:(.text+0x1213): undefined reference to `cvRead'
/tmp/cc9zt8fA.o: In function `cvCreateSubdivDelaunay2D':
ipcamcap.c:(.text+0x124f): undefined reference to `cvCreateSubdiv2D'
ipcamcap.c:(.text+0x126a): undefined reference to `cvInitSubdivDelaunay2D'
/tmp/cc9zt8fA.o: In function `cvContourPerimeter':
ipcamcap.c:(.text+0x1442): undefined reference to `cvArcLength'
/tmp/cc9zt8fA.o: In function `cvCalcHist':
ipcamcap.c:(.text+0x1472): undefined reference to `cvCalcArrHist'
/tmp/cc9zt8fA.o: In function `main':
ipcamcap.c:(.text+0x15bb): undefined reference to `cvCreateFileCapture'
ipcamcap.c:(.text+0x15ed): undefined reference to `cvNamedWindow'
ipcamcap.c:(.text+0x15f7): undefined reference to `cvGetTickCount'
ipcamcap.c:(.text+0x160d): undefined reference to `cvQueryFrame'
ipcamcap.c:(.text+0x1616): undefined reference to `cvGetTickCount'
ipcamcap.c:(.text+0x1638): undefined reference to `cvGetTickFrequency'
ipcamcap.c:(.text+0x167e): undefined reference to `cvGetTickFrequency'
ipcamcap.c:(.text+0x16bf): undefined reference to `cvShowImage'
ipcamcap.c:(.text+0x16c9): undefined reference to `cvWaitKey'
ipcamcap.c:(.text+0x16e9): undefined reference to `cvReleaseCapture'
collect2: ld returned 1 exit status
make: *** [ipcamcap] Error 1
gcc `pkg-config --cflags --libs opencv` -o ipcamcap ipcamcap.c
The order of flags sometimes matter. Try:
gcc -o ipcamcap ipcamcap.c `pkg-config --cflags --libs opencv`
You can get more information here.
Be sure you are correctly including and linking all library files.
I specified library's search path with the following:
-L/usr/local/lib
-lopencv_core -lopencv_highgui
and obviously included libraries for the compiler:
-I/usr/local/include/opencv
and compiled correctly your code snippet.