Linking error with Boost.python while compiling - c++

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

Related

chromiumOS emerge undefined reference to `std::__1::mutex::unlock()'

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.

Getting lots of error messages like "undefined reference to..." using FLTK with g++

I learn c++ following The Stroustroup's book (Programming: Principles and Practice), so I've been trying to run an example using FLTK libraries (I use Ubuntu 14.04).
Actually, when I compiled the programm with Code::Blocks IDE everything worked fine. But then, sort of for learning purposes, I decided to write a makefile, which causes many errors when trying to start it:
> g++ main.o Graph.o GUI.o Simple_window.o Window.o -o hello main.o: In function `fl_color()':
> main.cpp:(.text._Z8fl_colorv[_Z8fl_colorv]+0x7): undefined reference
> to `fl_graphics_driver' main.o: In function
> `Graph_lib::Window::~Window()':
> main.cpp: (.text._ZN9Graph_lib6WindowD2Ev[_ZN9Graph_lib6WindowD5Ev]+0x31):
> undefined reference to `Fl_Window::~Fl_Window()'
> main.o:(.rodata._ZTV13Simple_window[_ZTV13Simple_window]+0x28):
> undefined reference to `Fl_Window::handle(int)'
> main.o:(.rodata._ZTV13Simple_window[_ZTV13Simple_window]+0x30):
> undefined reference to `Fl_Window::resize(int, int, int, int)'
> main.o:(.rodata._ZTV13Simple_window[_ZTV13Simple_window]+0x38):
> undefined reference to `Fl_Window::show()'
> main.o:(.rodata._ZTV13Simple_window[_ZTV13Simple_window]+0x40):
> undefined reference to `Fl_Window::hide()'
> main.o:(.rodata._ZTV13Simple_window[_ZTV13Simple_window]+0x60):
> undefined reference to `Fl_Window::flush()' Graph.o: In function
> `Graph_lib::Text::draw_lines() const': Graph.cpp:(.text+0x9e5):
> undefined reference to `fl_draw(char const*, int, int)' Graph.o: In
> function `Graph_lib::draw_mark(Graph_lib::Point, char)':
> Graph.cpp:(.text+0x16e2): undefined reference to `fl_draw(char const*,
> int, int)' Graph.o: In function
> `Graph_lib::Image::Image(Graph_lib::Point, std::string,
> Graph_lib::Suffix::Encoding)': Graph.cpp:(.text+0x1f95): undefined
> reference to `Fl_JPEG_Image::Fl_JPEG_Image(char const*)'
> Graph.cpp:(.text+0x1fc9): undefined reference to
> `Fl_GIF_Image::Fl_GIF_Image(char const*)' Graph.cpp:(.text+0x1ffd):
> undefined reference to `Fl_BMP_Image::Fl_BMP_Image(char const*)'
> Graph.o: In function `Fl_Image::Fl_Image(int, int, int)':
> Graph.cpp:(.text._ZN8Fl_ImageC2Eiii[_ZN8Fl_ImageC5Eiii]+0x18):
> undefined reference to `vtable for Fl_Image' Graph.o: In function
> `fl_color(unsigned int)':
> Graph.cpp:(.text._Z8fl_colorj[_Z8fl_colorj]+0xe): undefined reference
> to `fl_graphics_driver'
> Graph.cpp:(.text._Z8fl_colorj[_Z8fl_colorj]+0x21): undefined reference
> to `fl_graphics_driver' Graph.o: In function `fl_line_style(int, int,
> char*)':
> Graph.cpp:(.text._Z13fl_line_styleiiPc[_Z13fl_line_styleiiPc]+0x15):
> undefined reference to `fl_graphics_driver'
> Graph.cpp:(.text._Z13fl_line_styleiiPc[_Z13fl_line_styleiiPc]+0x26):
> undefined reference to `fl_graphics_driver' Graph.o: In function
> `fl_rect(int, int, int, int)':
> Graph.cpp:(.text._Z7fl_rectiiii[_Z7fl_rectiiii]+0x17): undefined
> reference to `fl_graphics_driver'
> Graph.o:Graph.cpp:(.text._Z7fl_rectiiii[_Z7fl_rectiiii]+0x28): more
> undefined references to `fl_graphics_driver' follow Graph.o: In
> function `Graph_lib::Bad_image::draw(int, int, int, int, int, int)':
> Graph.cpp:(.text._ZN9Graph_lib9Bad_image4drawEiiiiii[_ZN9Graph_lib9Bad_image4drawEiiiiii]+0x2d): undefined reference to `Fl_Image::draw_empty(int, int)'
> Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x20):
> undefined reference to `Fl_Image::copy(int, int)'
> Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x28):
> undefined reference to `Fl_Image::color_average(unsigned int, float)'
> Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x30):
> undefined reference to `Fl_Image::desaturate()'
> Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x38):
> undefined reference to `Fl_Image::label(Fl_Widget*)'
> Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x40):
> undefined reference to `Fl_Image::label(Fl_Menu_Item*)'
> Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x50):
> undefined reference to `Fl_Image::uncache()' Graph.o: In function
> `Graph_lib::Bad_image::~Bad_image()':
> Graph.cpp:(.text._ZN9Graph_lib9Bad_imageD2Ev[_ZN9Graph_lib9Bad_imageD5Ev]+0x1f):
> undefined reference to `Fl_Image::~Fl_Image()'
> Graph.o:(.rodata._ZTIN9Graph_lib9Bad_imageE[_ZTIN9Graph_lib9Bad_imageE]+0x10):
> undefined reference to `typeinfo for Fl_Image' GUI.o: In function
> `Graph_lib::Button::attach(Graph_lib::Window&)': GUI.cpp:(.text+0x5b):
> undefined reference to `Fl_Button::Fl_Button(int, int, int, int, char
> const*)' GUI.o: In function
> `Graph_lib::In_box::attach(Graph_lib::Window&)':
> GUI.cpp:(.text+0x1ed): undefined reference to `Fl_Input::Fl_Input(int,
> int, int, int, char const*)' GUI.o: In function
> `Graph_lib::Out_box::put(int)': GUI.cpp:(.text+0x2cf): undefined
> reference to `Fl_Input_::value(char const*)' GUI.o: In function
> `Graph_lib::Out_box::put(std::string const&)': GUI.cpp:(.text+0x365):
> undefined reference to `Fl_Input_::value(char const*)' GUI.o: In
> function `Graph_lib::Out_box::attach(Graph_lib::Window&)':
> GUI.cpp:(.text+0x3cb): undefined reference to
> `Fl_Output::Fl_Output(int, int, int, int, char const*)'
> Simple_window.o: In function `Simple_window::wait_for_button()':
> Simple_window.cpp:(.text+0x31): undefined reference to `Fl::wait()'
> Simple_window.cpp:(.text+0x48): undefined reference to `Fl::redraw()'
> Window.o: In function `Graph_lib::Window::Window(int, int, std::string
> const&)': Window.cpp:(.text+0x34): undefined reference to
> `Fl_Window::Fl_Window(int, int, char const*)' Window.cpp:(.text+0x9f):
> undefined reference to `Fl_Window::~Fl_Window()' Window.o: In function
> `Graph_lib::Window::Window(Graph_lib::Point, int, int, std::string
> const&)': Window.cpp:(.text+0xf8): undefined reference to
> `Fl_Window::Fl_Window(int, int, int, int, char const*)'
> Window.cpp:(.text+0x163): undefined reference to
> `Fl_Window::~Fl_Window()' Window.o: In function
> `Graph_lib::Window::draw()': Window.cpp:(.text+0x1c7): undefined
> reference to `Fl_Window::draw()' Window.o: In function
> `Graph_lib::Window::attach(Graph_lib::Widget&)':
> Window.cpp:(.text+0x23a): undefined reference to `Fl_Group::begin()'
> Window.cpp:(.text+0x264): undefined reference to `Fl_Group::end()'
> Window.o: In function `Graph_lib::gui_main()':
> Window.cpp:(.text+0x485): undefined reference to `Fl::run()'
> Window.o:(.rodata._ZTVN9Graph_lib6WindowE[_ZTVN9Graph_lib6WindowE]+0x28):
> undefined reference to `Fl_Window::handle(int)'
> Window.o:(.rodata._ZTVN9Graph_lib6WindowE[_ZTVN9Graph_lib6WindowE]+0x30):
> undefined reference to `Fl_Window::resize(int, int, int, int)'
> Window.o:(.rodata._ZTVN9Graph_lib6WindowE[_ZTVN9Graph_lib6WindowE]+0x38):
> undefined reference to `Fl_Window::show()'
> Window.o:(.rodata._ZTVN9Graph_lib6WindowE[_ZTVN9Graph_lib6WindowE]+0x40):
> undefined reference to `Fl_Window::hide()'
> Window.o:(.rodata._ZTVN9Graph_lib6WindowE[_ZTVN9Graph_lib6WindowE]+0x60):
> undefined reference to `Fl_Window::flush()'
> Window.o:(.rodata._ZTIN9Graph_lib6WindowE[_ZTIN9Graph_lib6WindowE]+0x10):
> undefined reference to `typeinfo for Fl_Window' collect2: error: ld
> returned 1 exit status make: *** [hello] error 1
And here is my makefile:
CC=g++
CFLAGS=-c -Wall -std=c++11 `fltk-config --cxxflags --use-images`
LIBS=`fltk-config --ldflags` -lfltk -lfltk_images -ljpeg -lstdc++ -lXfixes -lXext -lpthread -ldl -lm -lX11
all: hello
hello: main.o Graph.o GUI.o Simple_window.o Window.o
$(CC) main.o Graph.o GUI.o Simple_window.o Window.o -o hello
main.o: main.cpp
$(CC) $(CFLAGS) main.cpp $(LIBS)
Graph.o: Graph.cpp
$(CC) $(CFLAGS) Graph.cpp $(LIBS)
GUI.o: GUI.cpp
$(CC) $(CFLAGS) GUI.cpp $(LIBS)
Simple_window.o: Simple_window.cpp
$(CC) $(CFLAGS) Simple_window.cpp $(LIBS)
Window.o: Window.cpp
$(CC) $(CFLAGS) Window.cpp $(LIBS)
clean:
rm -rf *.o hello
Could anyone tell me what I'm doing wrong? I saw in the Web many similar topics, but no answer from them seems to help me.
Thanks so much in advance!
You need to pass LIBS to linker instead of compiler, this would be your makefile:
CC=g++
CFLAGS=-c -Wall -std=c++11 `fltk-config --cxxflags --use-images`
LIBS=`fltk-config --ldflags` -lfltk -lfltk_images -ljpeg -lstdc++ -lXfixes -lXext -lpthread -ldl -lm -lX11
all: hello
hello: main.o Graph.o GUI.o Simple_window.o Window.o
$(CC) main.o Graph.o GUI.o Simple_window.o Window.o -o hello $(LIBS)
main.o: main.cpp
$(CC) $(CFLAGS) main.cpp
Graph.o: Graph.cpp
$(CC) $(CFLAGS) Graph.cpp
GUI.o: GUI.cpp
$(CC) $(CFLAGS) GUI.cpp
Simple_window.o: Simple_window.cpp
$(CC) $(CFLAGS) Simple_window.cpp
Window.o: Window.cpp
$(CC) $(CFLAGS) Window.cpp
clean:
rm -rf *.o hello

Error including dlib library in c++ project

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.)

How to link to opencv 3.0 when compiled from source on Ubuntu 14.04?

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.

How to create the executable from multiple .o files that require external dependencies?

I need to compile a C++ project which is going to use external libraries and headers from the project for linear programming COIN-OR. It contains three .cpp files that I have successfully compiled into .o files. The main problem I have is what to do next. As all the files are compiled without error, I assume they should at least give me some result.
How can I create the executable files for linux?
I have tried
gcc myfile.o -o main
It doesn't work, it outputs a very large block of error text.
In case it is needed, this is the Makefile:
#
P=farmer
#
EXE=$(P)
OBJS=main-farmer.o model-farmer.o param-farmer.o pm.h
ADDLIBS=-D.
ADDINCFLAGS=-I.
SRCDIR=~/coin-projects
##########
CXX=g++
CXXFLAGS=-O3 -fomit-frame-pointer -pipe -DNDEBUG -pedantic-errors -Wimplicit -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion
CXXLINKFLAGS=-Wl,--rpath -Wl,/installed/CoinAll/lib
CC=gcc
CFLAGS=-03 -fomit-frame-pointer -pipe -DNDEBUG -pedantic-errors -Wimplicit -Wparentheses -Wsequence-point -Wreturn-type -Wcast-qual -Wall
COININCDIR=/installed/CoinAll/include/coin
# COIN-OR libs
COINLIBDIR=/installed/CoinAll/lib
# Clp
LIBS=-L$(COINLIBDIR) -lCbc -lCgl -lOsiClp -lOsi -lClp -lCoinUtils -lm \
`cat $(COINLIBDIR)/cgl_addlibs.txt` \
`cat $(COINLIBDIR)/clp_addlibs.txt` \
`cat $(COINLIBDIR)/coinutils_addlibs.txt`
CLEANFILES=\
addBits.o addBits \
addColumns.o addColumns \
addRows.o addRows \
decompose.o decompose \
defaults.o defaults \
driver2.o driver2 \
driver.o driver \
driverC.o driverC \
dualCuts.o dualCuts \
ekk.o ekk \
ekk_interface.o ekk_interface \
hello.o hello \
makeDual.o makeDual \
minimum.o minimum \
network.o network \
piece.o piece \
rowColumn.o rowColumn \
sprint2.o sprint2 \
sprint.o sprint \
testBarrier.o testBarrier \
testBasis.o testBasis \
testGub2.o testGub2 \
testGub.o testGub \
testQP.o testQP \
useVolume.o useVolume
# Part 3
#
all: $(EXE)
.SUFFIXES: .cpp .c .o .obj
$(EXE): $(OBJS)
bla=;
for file in $(OBJS); do bla="$$bla `$(CYGPATH_W) $$file`"; done; \
$(CXX) $(CXXLINKFLAGS) $(CXXFLAGS) -o $# $$bla $(ADDLIBS) $(LIBS)
####
########
############
########
####
clean:
rm -rf $(CLEANFILES)
.cpp.o:
$(CXX) $(CXXFLAGS) $(INCL) -c -o $# `test -f '$<' || echo '$(SRCDIR)/'`$<
.cpp.obj:
$(CXX) $(CXXFLAGS) $(INCL) -c -o $# `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(SRCDIR)/$<'; fi`
.c.o:
$(CC) $(CFLAGS) $(INCL) -c -o $# `test -f '$<' || echo '$(SRCDIR)/'`$<
.c.obj:
$(CC) $(CFLAGS) $(INCL) -c -o $# `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(SRCDIR)/$<'; fi`
This is the error I'm receiving whenever I try the command
g++ main-farmer.o model-farmer.o param-farmer.o -o main
Error message:
model-farmer.o: In function models(double*, double (*) [3], double*, double*, double*, double (*) [3], double (*) [3], double (*)
[3], double (*) [3][3], double (*) [6][3])':
model-farmer.cpp:(.text+0x0): multiple definition ofmodels(double*, double () [3], double, double*, double*, double () [3], double () [3], double () [3], double () [3][3], double () [6][3])' main-farmer.o:main-farmer.cpp:(.text+0x60): first defined here param-farmer.o: In function param(double*, double (*) [3], double*,
double*, double*, double (*) [3], double (*) [3], double (*) [3],
double (*) [3][3], double (*) [6][3], double*, double*, double*,
double*, double*, int*, int*, double*, int&)':
param-farmer.cpp:(.text+0x0): multiple definition ofparam(double, double () [3], double, double*, double*, double () [3], double () [3], double () [3], double () [3][3], double () [6][3], double, double*, double*, double*, double*, int*, int*, double*, int&)' main-farmer.o:main-farmer.cpp:(.text+0x590): first defined here main-farmer.o: In function main':
main-farmer.cpp:(.text.startup+0x16e): undefined reference to
OsiClpSolverInterface::OsiClpSolverInterface()' main-farmer.cpp:(.text.startup+0x198): undefined reference to CoinPackedMatrix::CoinPackedMatrix(bool, int const*, int const*,
double const*, int)' main-farmer.cpp:(.text.startup+0x1cb): undefined
reference toOsiClpSolverInterface::loadProblem(CoinPackedMatrix const&, double const*, double const*, double const*, double const*, double const*)' main-farmer.cpp:(.text.startup+0x2fc): undefined reference to ClpModel::setOptimizationDirection(double)'
main-farmer.cpp:(.text.startup+0x32c): undefined reference to
OsiClpSolverInterface::setInteger(int)' main-farmer.cpp:(.text.startup+0x340): undefined reference to OsiClpSolverInterface::setInteger(int)'
main-farmer.cpp:(.text.startup+0x354): undefined reference to
OsiClpSolverInterface::setInteger(int)' main-farmer.cpp:(.text.startup+0x361): undefined reference to OsiClpSolverInterface::initialSolve()'
main-farmer.cpp:(.text.startup+0x36e): undefined reference to
OsiClpSolverInterface::isProvenPrimalInfeasible() const' main-farmer.cpp:(.text.startup+0x3ab): undefined reference to CoinPackedMatrix::~CoinPackedMatrix()'
main-farmer.cpp:(.text.startup+0x3b8): undefined reference to
OsiClpSolverInterface::~OsiClpSolverInterface()' main-farmer.cpp:(.text.startup+0x3de): undefined reference to OsiClpSolverInterface::isProvenOptimal() const'
main-farmer.cpp:(.text.startup+0x3f3): undefined reference to
OsiClpSolverInterface::getObjValue() const' main-farmer.cpp:(.text.startup+0x44d): undefined reference to OsiClpSolverInterface::getColSolution() const'
main-farmer.cpp:(.text.startup+0x478): undefined reference to
OsiClpSolverInterface::getColSolution() const' main-farmer.cpp:(.text.startup+0x4a4): undefined reference to OsiClpSolverInterface::getColSolution() const'
main-farmer.cpp:(.text.startup+0x520): undefined reference to
OsiClpSolverInterface::getColSolution() const' main-farmer.cpp:(.text.startup+0x551): undefined reference to OsiClpSolverInterface::getColSolution() const'
main-farmer.o:main-farmer.cpp:(.text.startup+0x582): more undefined
references toOsiClpSolverInterface::getColSolution() const' follow main-farmer.o: In function main':
main-farmer.cpp:(.text.startup+0x92f): undefined reference to
OsiClpSolverInterface::branchAndBound()' main-farmer.cpp:(.text.startup+0x94a): undefined reference to OsiClpSolverInterface::writeMps(char const*, char const*, double)
const' main-farmer.cpp:(.text.startup+0x957): undefined reference to
OsiClpSolverInterface::getObjValue() const' main-farmer.cpp:(.text.startup+0x96e): undefined reference to OsiClpSolverInterface::isProvenOptimal() const'
main-farmer.cpp:(.text.startup+0x9d6): undefined reference to
OsiClpSolverInterface::getObjValue() const' main-farmer.cpp:(.text.startup+0xa32): undefined reference to OsiClpSolverInterface::getColSolution() const'
main-farmer.cpp:(.text.startup+0xabc): undefined reference to
OsiClpSolverInterface::getColSolution() const' main-farmer.cpp:(.text.startup+0xae9): undefined reference to OsiClpSolverInterface::getColSolution() const'
main-farmer.cpp:(.text.startup+0xb16): undefined reference to
OsiClpSolverInterface::getColSolution() const' main-farmer.cpp:(.text.startup+0xb43): undefined reference to OsiClpSolverInterface::getColSolution() const'
main-farmer.o:main-farmer.cpp:(.text.startup+0xb70): more undefined
references toOsiClpSolverInterface::getColSolution() const' follow main-farmer.o: In function main':
main-farmer.cpp:(.text.startup+0xc8f): undefined reference to
CoinPackedMatrix::~CoinPackedMatrix()' main-farmer.cpp:(.text.startup+0xc9c): undefined reference to `OsiClpSolverInterface::~OsiClpSolverInterface()' collect2: error: ld returned 1 exit status
To compile .c and link .o files you should write
gcc FirstFile.o SecondFile.o ... -o main
But if you compile .cpp, use g++ instead of gcc.
Files from external libraries you should also write in the list above.
What errors did your command output?