I'm trying to build project which uses standalone asio as dependency. Problem is that with exceptions turned off (-fno-exceptions), I have to define throw_exception function (link to boost documentation), but no matter how I define that function, linker throws undefined reference.
This is how I've tried to define throw_exception:
#define ASIO_NO_EXCEPTIONS
#include <asio/detail/throw_exception.hpp>
template <class E>
void asio::detail::throw_exception(E const& e) {
// do something
}
I receive these linking errors:
/usr/bin/ld: libsioclient.a(sio_socket.cpp.o): in function `asio::detail::do_throw_error(std::error_code const&, char const*) [clone .isra.0]':
sio_socket.cpp:(.text+0x333): undefined reference to `void asio::detail::throw_exception<std::system_error>(std::system_error const&)'
/usr/bin/ld: _libsioclient.a(sio_socket.cpp.o): in function `void asio::execution::detail::any_executor_base::query_fn<void, asio::execution::prefer_only<asio::execution::detail::outstanding_work::tracked_t<0> > >(void*, void const*, void const*)':
sio_socket.cpp:(.text._ZN4asio9execution6detail17any_executor_base8query_fnIvNS0_11prefer_onlyINS1_16outstanding_work9tracked_tILi0EEEEEEEvPvPKvSB_[_ZN4asio9execution6detail17any_executor_base8query_fnIvNS0_11prefer_onlyINS1_16outstanding_work9tracked_tILi0EEEEEEEvPvPKvSB_]+0x28): undefined reference to `void asio::detail::throw_exception<asio::execution::bad_executor>(asio::execution::bad_executor const&)'
/usr/bin/ld: libsioclient.a(sio_socket.cpp.o): in function `void asio::execution::detail::any_executor_base::query_fn<void, asio::execution::prefer_only<asio::execution::detail::outstanding_work::untracked_t<0> > >(void*, void const*, void const*)':
sio_socket.cpp:(.text._ZN4asio9execution6detail17any_executor_base8query_fnIvNS0_11prefer_onlyINS1_16outstanding_work11untracked_tILi0EEEEEEEvPvPKvSB_[_ZN4asio9execution6detail17any_executor_base8query_fnIvNS0_11prefer_onlyINS1_16outstanding_work11untracked_tILi0EEEEEEEvPvPKvSB_]+0x28): undefined reference to `void asio::detail::throw_exception<asio::execution::bad_executor>(asio::execution::bad_executor const&)'
/usr/bin/ld: libsioclient.a(sio_socket.cpp.o): in function `void asio::execution::detail::any_executor_base::query_fn<void, asio::execution::prefer_only<asio::execution::detail::relationship::fork_t<0> > >(void*, void const*, void const*)':
sio_socket.cpp:(.text._ZN4asio9execution6detail17any_executor_base8query_fnIvNS0_11prefer_onlyINS1_12relationship6fork_tILi0EEEEEEEvPvPKvSB_[_ZN4asio9execution6detail17any_executor_base8query_fnIvNS0_11prefer_onlyINS1_12relationship6fork_tILi0EEEEEEEvPvPKvSB_]+0x28): undefined reference to `void asio::detail::throw_exception<asio::execution::bad_executor>(asio::execution::bad_executor const&)'
/usr/bin/ld: libsioclient.a(sio_socket.cpp.o): in function `void asio::execution::detail::any_executor_base::query_fn<void, asio::execution::prefer_only<asio::execution::detail::relationship::continuation_t<0> > >(void*, void const*, void const*)':
sio_socket.cpp:(.text._ZN4asio9execution6detail17any_executor_base8query_fnIvNS0_11prefer_onlyINS1_12relationship14continuation_tILi0EEEEEEEvPvPKvSB_[_ZN4asio9execution6detail17any_executor_base8query_fnIvNS0_11prefer_onlyINS1_12relationship14continuation_tILi0EEEEEEEvPvPKvSB_]+0x28): undefined reference to `void asio::detail::throw_exception<asio::execution::bad_executor>(asio::execution::bad_executor const&)'
/usr/bin/ld: libsioclient.a(sio_socket.cpp.o): in function `void asio::execution::detail::any_executor_base::query_fn<void, asio::execution::context_as_t<asio::execution_context&> >(void*, void const*, void const*)':
sio_socket.cpp:(.text._ZN4asio9execution6detail17any_executor_base8query_fnIvNS0_12context_as_tIRNS_17execution_contextEEEEEvPvPKvSA_[_ZN4asio9execution6detail17any_executor_base8query_fnIvNS0_12context_as_tIRNS_17execution_contextEEEEEvPvPKvSA_]+0x28): undefined reference to `void asio::detail::throw_exception<asio::execution::bad_executor>(asio::execution::bad_executor const&)'
/usr/bin/ld: libsioclient.a(sio_socket.cpp.o):sio_socket.cpp:(.text._ZN4asio9execution6detail17any_executor_base10require_fnINS0_12any_executorIJNS0_12context_as_tIRNS_17execution_contextEEENS1_8blocking7never_tILi0EEENS0_11prefer_onlyINS9_10possibly_tILi0EEEEENSC_INS1_16outstanding_work9tracked_tILi0EEEEENSC_INSG_11untracked_tILi0EEEEENSC_INS1_12relationship6fork_tILi0EEEEENSC_INSN_14continuation_tILi0EEEEEEEEvS8_EET_PKvSX_[_ZN4asio9execution6detail17any_executor_base10require_fnINS0_12any_executorIJNS0_12context_as_tIRNS_17execution_contextEEENS1_8blocking7never_tILi0EEENS0_11prefer_onlyINS9_10possibly_tILi0EEEEENSC_INS1_16outstanding_work9tracked_tILi0EEEEENSC_INSG_11untracked_tILi0EEEEENSC_INS1_12relationship6fork_tILi0EEEEENSC_INSN_14continuation_tILi0EEEEEEEEvS8_EET_PKvSX_]+0x2d): more undefined references to `void asio::detail::throw_exception<asio::execution::bad_executor>(asio::execution::bad_executor const&)' follow
/usr/bin/ld: libsioclient.a(sio_socket.cpp.o): in function `asio::detail::scheduler::scheduler(asio::execution_context&, int, bool, asio::detail::scheduler_task* (*)(asio::execution_context&)) [clone .part.0]':
sio_socket.cpp:(.text._ZN4asio6detail9schedulerC2ERNS_17execution_contextEibPFPNS0_14scheduler_taskES3_E.part.0[_ZN4asio6detail9schedulerC5ERNS_17execution_contextEibPFPNS0_14scheduler_taskES3_E]+0x228): undefined reference to `void asio::detail::throw_exception<std::system_error>(std::system_error const&)'
/usr/bin/ld: libsioclient.a(sio_socket.cpp.o): in function `asio::detail::epoll_reactor::notify_fork(asio::execution_context::fork_event)':
sio_socket.cpp:(.text._ZN4asio6detail13epoll_reactor11notify_forkENS_17execution_context10fork_eventE[_ZN4asio6detail13epoll_reactor11notify_forkENS_17execution_context10fork_eventE]+0x375): undefined reference to `void asio::detail::throw_exception<std::system_error>(std::system_error const&)'
/usr/bin/ld: libsioclient.a(sio_socket.cpp.o): in function `asio::detail::scheduler::scheduler(asio::execution_context&, int, bool, asio::detail::scheduler_task* (*)(asio::execution_context&))':
sio_socket.cpp:(.text._ZN4asio6detail9schedulerC2ERNS_17execution_contextEibPFPNS0_14scheduler_taskES3_E[_ZN4asio6detail9schedulerC5ERNS_17execution_contextEibPFPNS0_14scheduler_taskES3_E]+0x24a): undefined reference to `void asio::detail::throw_exception<std::system_error>(std::system_error const&)'
/usr/bin/ld: sio_socket.cpp:(.text._ZN4asio6detail9schedulerC2ERNS_17execution_contextEibPFPNS0_14scheduler_taskES3_E[_ZN4asio6detail9schedulerC5ERNS_17execution_contextEibPFPNS0_14scheduler_taskES3_E]+0x4f7): undefined reference to `void asio::detail::throw_exception<std::system_error>(std::system_error const&)'
/usr/bin/ld: libsioclient.a(sio_socket.cpp.o): in function `asio::execution_context::service* asio::detail::service_registry::create<asio::detail::epoll_reactor, asio::execution_context>(void*)':
sio_socket.cpp:(.text._ZN4asio6detail16service_registry6createINS0_13epoll_reactorENS_17execution_contextEEEPNS4_7serviceEPv[_ZN4asio6detail16service_registry6createINS0_13epoll_reactorENS_17execution_contextEEEPNS4_7serviceEPv]+0x5d6): undefined reference to `void asio::detail::throw_exception<std::system_error>(std::system_error const&)'
/usr/bin/ld: libsioclient.a(sio_client_impl.cpp.o): in function `std::_Function_handler<void (bool, std::shared_ptr<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> const&), sio::client_impl::on_ping()::{lambda(bool, std::shared_ptr<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const>)#1}>::_M_invoke(std::_Any_data const&, bool&&, std::shared_ptr<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> const&)':
sio_client_impl.cpp:(.text+0x3c40): undefined reference to `websocketpp::endpoint<websocketpp::connection<websocketpp::config::asio_client>, websocketpp::config::asio_client>::send(std::weak_ptr<void>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, websocketpp::frame::opcode::value)'
/usr/bin/ld: libsioclient.a(sio_client_impl.cpp.o): in function `sio::client_impl::connect_impl(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
sio_client_impl.cpp:(.text+0x988c): undefined reference to `websocketpp::connection<websocketpp::config::asio_client>::replace_header(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
How to properly define throw_exception function or if I'm missing something, how can these errors be solved?
You can try this, log() is the imaginary function you already use for logging ...
// somechere in a cpp file, preferably.
#include <boost/asio.hpp>
// ...
namespace boost::asio::detail {
template<>
void throw_exception(const asio::execution::bad_executor& e)
{
// throw e; // this is what the original function does
LOG("asio::execution::bad_executor thrown\n"); // etc...
exit(3); // That's all you can do at this point.
}
template<>
void throw_exception(const std::system_error& e)
{
LOG("std::system_error thrown\n"); // etc...
exit(3); // That's all you can do at this point.
}
}
You may need to declare more specializations as you go along.
I find solution. Problem was that compiler threw implementation of throw_exception from code while compiling, and when linker tried to find that function, there simply was no throw_exception. I made it like this:
namespace asio::detail {
template <typename Exception> void throw_exception(const Exception& e) {
std::cerr << "Something went wrong..." << std::endl;
std::terminate();
}
}; // namespace asio::detail
If I call this function somewhere, I don't receive linking errors. Probably, I have to implement some kind of error handling instead of that and find a solution to make this function properly compiled and linked, but, at least, I've found a reason of that strange behaviour.
I am trying to run the examples in C++ from the WebRTC source code, using the native API(not building)
My Cmakelist is:
cmake_minimum_required(VERSION 3.5)
project(WebRTC)
include_directories("D:/Clion_Projects/src/api")
include_directories("D:/abseil-cpp")
include_directories("D:/CLion_Projects/src/")
add_executable(main examples/peerconnection/server/main.cc)
And the code is:
/*
* Copyright 2011 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#if defined(WEBRTC_POSIX)
#include <sys/select.h>
#endif
#include <time.h>
#include <string>
#include <vector>
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/flags/usage.h"
#include "examples/peerconnection/server/data_socket.h"
#include "examples/peerconnection/server/peer_channel.h"
#include "system_wrappers/include/field_trial.h"
#include "test/field_trial.h"
ABSL_FLAG(
std::string,
force_fieldtrials,
"",
"Field trials control experimental features. This flag specifies the field "
"trials in effect. E.g. running with "
"--force_fieldtrials=WebRTC-FooFeature/Enabled/ "
"will assign the group Enabled to field trial WebRTC-FooFeature. Multiple "
"trials are separated by \"/\"");
ABSL_FLAG(int, port, 8888, "default: 8888");
static const size_t kMaxConnections = (FD_SETSIZE - 2);
void HandleBrowserRequest(DataSocket *ds, bool *quit) {
assert(ds && ds->valid());
assert(quit);
const std::string &path = ds->request_path();
*quit = (path.compare("/quit") == 0);
if (*quit) {
ds->Send("200 OK", true, "text/html", "",
"<html><body>Quitting...</body></html>");
} else if (ds->method() == DataSocket::OPTIONS) {
// We'll get this when a browsers do cross-resource-sharing requests.
// The headers to allow cross-origin script support will be set inside
// Send.
ds->Send("200 OK", true, "", "", "");
} else {
// Here we could write some useful output back to the browser depending on
// the path.
printf("Received an invalid request: %s\n", ds->request_path().c_str());
ds->Send("500 Sorry", true, "text/html", "",
"<html><body>Sorry, not yet implemented</body></html>");
}
}
int main(int argc, char *argv[]) {
absl::SetProgramUsageMessage(
"Example usage: ./peerconnection_server --port=8888\n");
absl::ParseCommandLine(argc, argv);
// InitFieldTrialsFromString stores the char*, so the char array must outlive
// the application.
const std::string force_field_trials = absl::GetFlag(FLAGS_force_fieldtrials);
webrtc::field_trial::InitFieldTrialsFromString(force_field_trials.c_str());
int port = absl::GetFlag(FLAGS_port);
// Abort if the user specifies a port that is outside the allowed
// range [1, 65535].
if ((port < 1) || (port > 65535)) {
printf("Error: %i is not a valid port.\n", port);
return -1;
}
ListeningSocket listener;
if (!listener.Create()) {
printf("Failed to create server socket\n");
return -1;
} else if (!listener.Listen(port)) {
printf("Failed to listen on server socket\n");
return -1;
}
printf("Server listening on port %i\n", port);
PeerChannel clients;
typedef std::vector<DataSocket *> SocketArray;
SocketArray sockets;
bool quit = false;
while (!quit) {
fd_set socket_set;
FD_ZERO(&socket_set);
if (listener.valid())
FD_SET(listener.socket(), &socket_set);
for (SocketArray::iterator i = sockets.begin(); i != sockets.end(); ++i)
FD_SET((*i)->socket(), &socket_set);
struct timeval timeout = {10, 0};
if (select(FD_SETSIZE, &socket_set, NULL, NULL, &timeout) == SOCKET_ERROR) {
printf("select failed\n");
break;
}
for (SocketArray::iterator i = sockets.begin(); i != sockets.end(); ++i) {
DataSocket *s = *i;
bool socket_done = true;
if (FD_ISSET(s->socket(), &socket_set)) {
if (s->OnDataAvailable(&socket_done) && s->request_received()) {
ChannelMember *member = clients.Lookup(s);
if (member || PeerChannel::IsPeerConnection(s)) {
if (!member) {
if (s->PathEquals("/sign_in")) {
clients.AddMember(s);
} else {
printf("No member found for: %s\n", s->request_path().c_str());
s->Send("500 Error", true, "text/plain", "",
"Peer most likely gone.");
}
} else if (member->is_wait_request(s)) {
// no need to do anything.
socket_done = false;
} else {
ChannelMember *target = clients.IsTargetedRequest(s);
if (target) {
member->ForwardRequestToPeer(s, target);
} else if (s->PathEquals("/sign_out")) {
s->Send("200 OK", true, "text/plain", "", "");
} else {
printf("Couldn't find target for request: %s\n",
s->request_path().c_str());
s->Send("500 Error", true, "text/plain", "",
"Peer most likely gone.");
}
}
} else {
HandleBrowserRequest(s, &quit);
if (quit) {
printf("Quitting...\n");
FD_CLR(listener.socket(), &socket_set);
listener.Close();
clients.CloseAll();
}
}
}
} else {
socket_done = false;
}
if (socket_done) {
printf("Disconnecting socket\n");
clients.OnClosing(s);
assert(s->valid()); // Close must not have been called yet.
FD_CLR(s->socket(), &socket_set);
delete (*i);
i = sockets.erase(i);
if (i == sockets.end())
break;
}
}
clients.CheckForTimeout();
if (FD_ISSET(listener.socket(), &socket_set)) {
DataSocket *s = listener.Accept();
if (sockets.size() >= kMaxConnections) {
delete s; // sorry, that's all we can take.
printf("Connection limit reached\n");
} else {
sockets.push_back(s);
printf("New connection...\n");
}
}
}
for (SocketArray::iterator i = sockets.begin(); i != sockets.end(); ++i)
delete (*i);
sockets.clear();
return 0;
}
But even after configuring the CmakeList I run into these errors:
Scanning dependencies of target main
[ 50%] Building CXX object CMakeFiles/main.dir/examples/peerconnection/server/main.cc.obj
[100%] Linking CXX executable main.exe
CMakeFiles\main.dir/objects.a(main.cc.obj): In function `HandleBrowserRequest(DataSocket*, bool*)':
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:55: undefined reference to `DataSocket::Send(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:61: undefined reference to `DataSocket::Send(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:66: undefined reference to `DataSocket::Send(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
CMakeFiles\main.dir/objects.a(main.cc.obj): In function `main':
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:72: undefined reference to `absl::SetProgramUsageMessage(absl::string_view)'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:74: undefined reference to `absl::ParseCommandLine(int, char**)'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:79: undefined reference to `webrtc::field_trial::InitFieldTrialsFromString(char const*)'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:91: undefined reference to `SocketBase::Create()'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:94: undefined reference to `ListeningSocket::Listen(unsigned short)'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:115: undefined reference to `__imp_select'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:123: undefined reference to `__WSAFDIsSet'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:124: undefined reference to `DataSocket::OnDataAvailable(bool*)'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:125: undefined reference to `PeerChannel::Lookup(DataSocket*) const'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:126: undefined reference to `PeerChannel::IsPeerConnection(DataSocket const*)'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:128: undefined reference to `DataSocket::PathEquals(char const*) const'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:129: undefined reference to `PeerChannel::AddMember(DataSocket*)'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:132: undefined reference to `DataSocket::Send(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:135: undefined reference to `ChannelMember::is_wait_request(DataSocket*) const'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:139: undefined reference to `PeerChannel::IsTargetedRequest(DataSocket const*) const'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:141: undefined reference to `ChannelMember::ForwardRequestToPeer(DataSocket*, ChannelMember*)'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:142: undefined reference to `DataSocket::PathEquals(char const*) const'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:143: undefined reference to `DataSocket::Send(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:147: undefined reference to `DataSocket::Send(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:156: undefined reference to `SocketBase::Close()'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:157: undefined reference to `PeerChannel::CloseAll()'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:167: undefined reference to `PeerChannel::OnClosing(DataSocket*)'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:177: undefined reference to `PeerChannel::CheckForTimeout()'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:179: undefined reference to `__WSAFDIsSet'
D:/CLion_Projects/src/examples/peerconnection/server/main.cc:180: undefined reference to `ListeningSocket::Accept() const'
CMakeFiles\main.dir/objects.a(main.cc.obj):main.cc:(.data+0x0): undefined reference to `vtable for absl::flags_internal::FlagImpl'
CMakeFiles\main.dir/objects.a(main.cc.obj):D:/CLion_Projects/src/examples/peerconnection/server/main.cc:42: undefined reference to `vtable for absl::flags_internal::FlagImpl'
CMakeFiles\main.dir/objects.a(main.cc.obj): In function `SocketBase::~SocketBase()':
D:/CLion_Projects/src/examples/peerconnection/server/data_socket.h:40: undefined reference to `SocketBase::Close()'
CMakeFiles\main.dir/objects.a(main.cc.obj): In function `PeerChannel::~PeerChannel()':
D:/CLion_Projects/src/examples/peerconnection/server/peer_channel.h:75: undefined reference to `PeerChannel::DeleteAll()'
CMakeFiles\main.dir/objects.a(main.cc.obj): In function `absl::flags_internal::FlagRegistrar<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, true>::FlagRegistrar(absl::flags_internal::Flag<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >&, char const*)':
D:/abseil-cpp/absl/flags/internal/flag.h:726: undefined reference to `absl::flags_internal::RegisterCommandLineFlag(absl::CommandLineFlag&, char const*)'
CMakeFiles\main.dir/objects.a(main.cc.obj): In function `absl::flags_internal::FlagRegistrar<int, true>::FlagRegistrar(absl::flags_internal::Flag<int>&, char const*)':
D:/abseil-cpp/absl/flags/internal/flag.h:726: undefined reference to `absl::flags_internal::RegisterCommandLineFlag(absl::CommandLineFlag&, char const*)'
CMakeFiles\main.dir/objects.a(main.cc.obj): In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > absl::UnparseFlag<int>(int const&)':
D:/abseil-cpp/absl/flags/marshalling.h:251: undefined reference to `absl::flags_internal::Unparse[abi:cxx11](int)'
CMakeFiles\main.dir/objects.a(main.cc.obj): In function `bool absl::flags_internal::InvokeParseFlag<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(absl::string_view, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)':
D:/abseil-cpp/absl/flags/marshalling.h:195: undefined reference to `absl::flags_internal::AbslParseFlag(absl::string_view, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
CMakeFiles\main.dir/objects.a(main.cc.obj): In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > absl::flags_internal::Unparse<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
D:/abseil-cpp/absl/flags/marshalling.h:208: undefined reference to `absl::flags_internal::AbslUnparseFlag[abi:cxx11](absl::string_view)'
CMakeFiles\main.dir/objects.a(main.cc.obj): In function `bool absl::flags_internal::InvokeParseFlag<int>(absl::string_view, int*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)':
D:/abseil-cpp/absl/flags/marshalling.h:195: undefined reference to `absl::flags_internal::AbslParseFlag(absl::string_view, int*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
CMakeFiles\main.dir/objects.a(main.cc.obj): In function `absl::flags_internal::Flag<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Get() const':
D:/abseil-cpp/absl/flags/internal/flag.h:618: undefined reference to `absl::flags_internal::FlagImpl::AssertValidType(void const*, std::type_info const* (*)()) const'
D:/abseil-cpp/absl/flags/internal/flag.h:622: undefined reference to `absl::flags_internal::FlagImpl::Read(void*) const'
CMakeFiles\main.dir/objects.a(main.cc.obj): In function `absl::flags_internal::Flag<int>::Get() const':
D:/abseil-cpp/absl/flags/internal/flag.h:618: undefined reference to `absl::flags_internal::FlagImpl::AssertValidType(void const*, std::type_info const* (*)()) const'
D:/abseil-cpp/absl/flags/internal/flag.h:622: undefined reference to `absl::flags_internal::FlagImpl::Read(void*) const'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [CMakeFiles\main.dir\build.make:106: main.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:95: CMakeFiles/main.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:102: CMakeFiles/main.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:137: main] Error 2
I don't understand why I am getting these errors, since I am running the example as is from the repo.
Any help would be greatly appreciated!
I am a C++ newbie trying to compile some OpenCV tutorial code.
I'm running Ubuntu 16.04, and I installed OpenCV 3.1.0 with this script: https://github.com/milq/scripts-ubuntu-debian/blob/master/install-opencv.sh
The source file I'm trying to compile is here:
https://github.com/opencv/opencv/blob/master/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp
I wrote this makefile:
CC=g++
CFLAGS = `pkg-config --cflags opencv` -c -g
LIBS = `pkg-config --libs opencv`
all: camcalib
camcalib: camera_calibration.o
$(CC) camera_calibration.o -o camcalib
camera_calibration.o: camera_calibration.cpp
$(CC) $(CFLAGS) $(LIBS) camera_calibration.cpp
clean:
rm *o camcalib
When I "make", the camera_calibration.o object file is generated, but I get the following error during linking:
make
g++ `pkg-config --cflags opencv` -c -g `pkg-config --libs opencv` camera_calibration.cpp
g++ camera_calibration.o -o camcalib
camera_calibration.o: In function `cv::read(cv::FileNode const&, bool&, bool)':
/usr/local/include/opencv2/core/persistence.hpp:996: undefined reference to `cv::read(cv::FileNode const&, int&, int)'
camera_calibration.o: In function `cv::operator<<(cv::FileStorage&, char const*)':
/usr/local/include/opencv2/core/persistence.hpp:1076: undefined reference to `cv::operator<<(cv::FileStorage&, cv::String const&)'
camera_calibration.o: In function `cv::operator<<(cv::FileStorage&, char*)':
/usr/local/include/opencv2/core/persistence.hpp:1084: undefined reference to `cv::operator<<(cv::FileStorage&, cv::String const&)'
camera_calibration.o: In function `void cv::operator>><std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(cv::FileNode const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
/usr/local/include/opencv2/core/cvstd.inl.hpp:155: undefined reference to `cv::read(cv::FileNode const&, cv::String&, cv::String const&)'
camera_calibration.o: In function `main':
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:239: undefined reference to `cv::FileStorage::FileStorage(cv::String const&, int, cv::String const&)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:240: undefined reference to `cv::FileStorage::isOpened() const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:245: undefined reference to `cv::FileStorage::operator[](char const*) const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:246: undefined reference to `cv::FileStorage::release()'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:292: undefined reference to `cv::flip(cv::_InputArray const&, cv::_OutputArray const&, int)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:309: undefined reference to `cv::findChessboardCorners(cv::_InputArray const&, cv::Size_<int>, cv::_OutputArray const&, int)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:312: undefined reference to `cv::SimpleBlobDetector::Params::Params()'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:312: undefined reference to `cv::SimpleBlobDetector::create(cv::SimpleBlobDetector::Params const&)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:312: undefined reference to `cv::findCirclesGrid(cv::_InputArray const&, cv::Size_<int>, cv::_OutputArray const&, int, cv::Ptr<cv::Feature2D> const&)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:315: undefined reference to `cv::SimpleBlobDetector::Params::Params()'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:315: undefined reference to `cv::SimpleBlobDetector::create(cv::SimpleBlobDetector::Params const&)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:315: undefined reference to `cv::findCirclesGrid(cv::_InputArray const&, cv::Size_<int>, cv::_OutputArray const&, int, cv::Ptr<cv::Feature2D> const&)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:329: undefined reference to `cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:331: undefined reference to `cv::cornerSubPix(cv::_InputArray const&, cv::_InputOutputArray const&, cv::Size_<int>, cv::Size_<int>, cv::TermCriteria)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:335: undefined reference to `cv::VideoCapture::isOpened() const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:339: undefined reference to `cv::VideoCapture::isOpened() const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:343: undefined reference to `cv::drawChessboardCorners(cv::_InputOutputArray const&, cv::Size_<int>, cv::_InputArray const&, bool)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:351: undefined reference to `cv::getTextSize(cv::String const&, int, double, int, int*)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:357: undefined reference to `cv::format(char const*, ...)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:359: undefined reference to `cv::format(char const*, ...)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:362: undefined reference to `cv::putText(cv::_InputOutputArray const&, cv::String const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)'
camera_calibration.o: In function `main':
/usr/local/include/opencv2/core.hpp:1257: undefined reference to `cv::noArray()'
camera_calibration.o: In function `main':
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:365: undefined reference to `cv::bitwise_not(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&)'
camera_calibration.o: In function `main':
/usr/local/include/opencv2/imgproc.hpp:2609: undefined reference to `cv::noArray()'
camera_calibration.o: In function `main':
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:372: undefined reference to `cv::undistort(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:377: undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:378: undefined reference to `cv::VideoCapture::isOpened() const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:378: undefined reference to `cv::waitKey(int)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:386: undefined reference to `cv::VideoCapture::isOpened() const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:404: undefined reference to `cv::fisheye::estimateNewCameraMatrixForUndistortRectify(cv::_InputArray const&, cv::_InputArray const&, cv::Size_<int> const&, cv::_InputArray const&, cv::_OutputArray const&, double, cv::Size_<int> const&, double)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:406: undefined reference to `cv::fisheye::initUndistortRectifyMap(cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::Size_<int> const&, int, cv::_OutputArray const&, cv::_OutputArray const&)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:412: undefined reference to `cv::getOptimalNewCameraMatrix(cv::_InputArray const&, cv::_InputArray const&, cv::Size_<int>, double, cv::Size_<int>, cv::Rect_<int>*, bool)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:413: undefined reference to `cv::initUndistortRectifyMap(cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::Size_<int>, int, cv::_OutputArray const&, cv::_OutputArray const&)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:418: undefined reference to `cv::imread(cv::String const&, int)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:421: undefined reference to `cv::remap(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::_InputArray const&, int, int, cv::Scalar_<double> const&)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:422: undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:423: undefined reference to `cv::waitKey(int)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:239: undefined reference to `cv::FileStorage::~FileStorage()'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:431: undefined reference to `cv::FileStorage::~FileStorage()'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:431: undefined reference to `cv::FileStorage::~FileStorage()'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:239: undefined reference to `cv::FileStorage::~FileStorage()'
camera_calibration.o: In function `computeReprojectionErrors(std::vector<std::vector<cv::Point3_<float>, std::allocator<cv::Point3_<float> > >, std::allocator<std::vector<cv::Point3_<float>, std::allocator<cv::Point3_<float> > > > > const&, std::vector<std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > >, std::allocator<std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > > > > const&, std::vector<cv::Mat, std::allocator<cv::Mat> > const&, std::vector<cv::Mat, std::allocator<cv::Mat> > const&, cv::Mat const&, cv::Mat const&, std::vector<float, std::allocator<float> >&, bool)':
/usr/local/include/opencv2/calib3d.hpp:1795: undefined reference to `cv::noArray()'
camera_calibration.o: In function `computeReprojectionErrors(std::vector<std::vector<cv::Point3_<float>, std::allocator<cv::Point3_<float> > >, std::allocator<std::vector<cv::Point3_<float>, std::allocator<cv::Point3_<float> > > > > const&, std::vector<std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > >, std::allocator<std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > > > > const&, std::vector<cv::Mat, std::allocator<cv::Mat> > const&, std::vector<cv::Mat, std::allocator<cv::Mat> > const&, cv::Mat const&, cv::Mat const&, std::vector<float, std::allocator<float> >&, bool)':
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:450: undefined reference to `cv::fisheye::projectPoints(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, double, cv::_OutputArray const&)'
camera_calibration.o: In function `computeReprojectionErrors(std::vector<std::vector<cv::Point3_<float>, std::allocator<cv::Point3_<float> > >, std::allocator<std::vector<cv::Point3_<float>, std::allocator<cv::Point3_<float> > > > > const&, std::vector<std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > >, std::allocator<std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > > > > const&, std::vector<cv::Mat, std::allocator<cv::Mat> > const&, std::vector<cv::Mat, std::allocator<cv::Mat> > const&, cv::Mat const&, cv::Mat const&, std::vector<float, std::allocator<float> >&, bool)':
/usr/local/include/opencv2/calib3d.hpp:513: undefined reference to `cv::noArray()'
camera_calibration.o: In function `computeReprojectionErrors(std::vector<std::vector<cv::Point3_<float>, std::allocator<cv::Point3_<float> > >, std::allocator<std::vector<cv::Point3_<float>, std::allocator<cv::Point3_<float> > > > > const&, std::vector<std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > >, std::allocator<std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > > > > const&, std::vector<cv::Mat, std::allocator<cv::Mat> > const&, std::vector<cv::Mat, std::allocator<cv::Mat> > const&, cv::Mat const&, cv::Mat const&, std::vector<float, std::allocator<float> >&, bool)':
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:454: undefined reference to `cv::projectPoints(cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, double)'
camera_calibration.o: In function `computeReprojectionErrors(std::vector<std::vector<cv::Point3_<float>, std::allocator<cv::Point3_<float> > >, std::allocator<std::vector<cv::Point3_<float>, std::allocator<cv::Point3_<float> > > > > const&, std::vector<std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > >, std::allocator<std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > > > > const&, std::vector<cv::Mat, std::allocator<cv::Mat> > const&, std::vector<cv::Mat, std::allocator<cv::Mat> > const&, cv::Mat const&, cv::Mat const&, std::vector<float, std::allocator<float> >&, bool)':
/usr/local/include/opencv2/core.hpp:668: undefined reference to `cv::noArray()'
camera_calibration.o: In function `computeReprojectionErrors(std::vector<std::vector<cv::Point3_<float>, std::allocator<cv::Point3_<float> > >, std::allocator<std::vector<cv::Point3_<float>, std::allocator<cv::Point3_<float> > > > > const&, std::vector<std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > >, std::allocator<std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > > > > const&, std::vector<cv::Mat, std::allocator<cv::Mat> > const&, std::vector<cv::Mat, std::allocator<cv::Mat> > const&, cv::Mat const&, cv::Mat const&, std::vector<float, std::allocator<float> >&, bool)':
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:456: undefined reference to `cv::norm(cv::_InputArray const&, cv::_InputArray const&, int, cv::_InputArray const&)'
camera_calibration.o: In function `runCalibration(Settings&, cv::Size_<int>&, cv::Mat&, cv::Mat&, std::vector<std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > >, std::allocator<std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > > > >, std::vector<cv::Mat, std::allocator<cv::Mat> >&, std::vector<cv::Mat, std::allocator<cv::Mat> >&, std::vector<float, std::allocator<float> >&, double&)':
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:497: undefined reference to `cv::Mat::eye(int, int, int)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:502: undefined reference to `cv::Mat::zeros(int, int, int)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:504: undefined reference to `cv::Mat::zeros(int, int, int)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:518: undefined reference to `cv::fisheye::calibrate(cv::_InputArray const&, cv::_InputArray const&, cv::Size_<int> const&, cv::_InputOutputArray const&, cv::_InputOutputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, cv::TermCriteria)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:528: undefined reference to `cv::calibrateCamera(cv::_InputArray const&, cv::_InputArray const&, cv::Size_<int>, cv::_InputOutputArray const&, cv::_InputOutputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, cv::TermCriteria)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:533: undefined reference to `cv::checkRange(cv::_InputArray const&, bool, cv::Point_<int>*, double, double)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:533: undefined reference to `cv::checkRange(cv::_InputArray const&, bool, cv::Point_<int>*, double, double)'
camera_calibration.o: In function `saveCameraParams(Settings&, cv::Size_<int>&, cv::Mat&, cv::Mat&, std::vector<cv::Mat, std::allocator<cv::Mat> > const&, std::vector<cv::Mat, std::allocator<cv::Mat> > const&, std::vector<float, std::allocator<float> > const&, std::vector<std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > >, std::allocator<std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > > > > const&, double)':
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:547: undefined reference to `cv::FileStorage::FileStorage(cv::String const&, int, cv::String const&)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:588: undefined reference to `cvWriteComment'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:604: undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:611: undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:612: undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:614: undefined reference to `cv::Mat::t() const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:615: undefined reference to `cv::Mat::t() const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:626: undefined reference to `cv::Mat::reshape(int, int) const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:628: undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:547: undefined reference to `cv::FileStorage::~FileStorage()'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:632: undefined reference to `cv::FileStorage::~FileStorage()'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:632: undefined reference to `cv::FileStorage::~FileStorage()'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:547: undefined reference to `cv::FileStorage::~FileStorage()'
camera_calibration.o: In function `cv::FileStorage& cv::operator<< <int>(cv::FileStorage&, int const&)':
/usr/local/include/opencv2/core/persistence.hpp:1064: undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
/usr/local/include/opencv2/core/persistence.hpp:1065: undefined reference to `cv::write(cv::FileStorage&, cv::String const&, int)'
camera_calibration.o: In function `cv::FileStorage& cv::operator<< <float>(cv::FileStorage&, float const&)':
/usr/local/include/opencv2/core/persistence.hpp:1064: undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
/usr/local/include/opencv2/core/persistence.hpp:1065: undefined reference to `cv::write(cv::FileStorage&, cv::String const&, float)'
camera_calibration.o: In function `cv::FileStorage& cv::operator<< <bool>(cv::FileStorage&, bool const&)':
/usr/local/include/opencv2/core/persistence.hpp:1064: undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
/usr/local/include/opencv2/core/persistence.hpp:1065: undefined reference to `cv::write(cv::FileStorage&, cv::String const&, int)'
camera_calibration.o: In function `void cv::operator>><int>(cv::FileNode const&, int&)':
/usr/local/include/opencv2/core/persistence.hpp:1121: undefined reference to `cv::read(cv::FileNode const&, int&, int)'
camera_calibration.o: In function `void cv::operator>><float>(cv::FileNode const&, float&)':
/usr/local/include/opencv2/core/persistence.hpp:1121: undefined reference to `cv::read(cv::FileNode const&, float&, float)'
camera_calibration.o: In function `cv::FileStorage& cv::operator<< <cv::Mat>(cv::FileStorage&, cv::Mat const&)':
/usr/local/include/opencv2/core/persistence.hpp:1064: undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
/usr/local/include/opencv2/core/persistence.hpp:1065: undefined reference to `cv::write(cv::FileStorage&, cv::String const&, cv::Mat const&)'
camera_calibration.o: In function `cv::FileStorage& cv::operator<< <double>(cv::FileStorage&, double const&)':
/usr/local/include/opencv2/core/persistence.hpp:1064: undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
/usr/local/include/opencv2/core/persistence.hpp:1065: undefined reference to `cv::write(cv::FileStorage&, cv::String const&, double)'
camera_calibration.o: In function `cv::String::String(char const*)':
/usr/local/include/opencv2/core/cvstd.hpp:625: undefined reference to `cv::String::allocate(unsigned long)'
camera_calibration.o: In function `cv::String::~String()':
/usr/local/include/opencv2/core/cvstd.hpp:667: undefined reference to `cv::String::deallocate()'
camera_calibration.o: In function `cv::Mat::Mat(cv::Mat const&)':
/usr/local/include/opencv2/core/mat.inl.hpp:400: undefined reference to `cv::Mat::copySize(cv::Mat const&)'
camera_calibration.o: In function `cv::Mat::Mat(int, int, int, void*, unsigned long)':
/usr/local/include/opencv2/core/mat.inl.hpp:410: undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
/usr/local/include/opencv2/core/mat.inl.hpp:426: undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
camera_calibration.o: In function `cv::Mat::~Mat()':
/usr/local/include/opencv2/core/mat.inl.hpp:571: undefined reference to `cv::fastFree(void*)'
camera_calibration.o: In function `cv::Mat::operator=(cv::Mat const&)':
/usr/local/include/opencv2/core/mat.inl.hpp:592: undefined reference to `cv::Mat::copySize(cv::Mat const&)'
camera_calibration.o: In function `cv::Mat::row(int) const':
/usr/local/include/opencv2/core/mat.inl.hpp:606: undefined reference to `cv::Mat::Mat(cv::Mat const&, cv::Range const&, cv::Range const&)'
camera_calibration.o: In function `cv::Mat::clone() const':
/usr/local/include/opencv2/core/mat.inl.hpp:643: undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
camera_calibration.o: In function `cv::Mat::create(int, int, int)':
/usr/local/include/opencv2/core/mat.inl.hpp:663: undefined reference to `cv::Mat::create(int, int const*, int)'
camera_calibration.o: In function `cv::Mat::release()':
/usr/local/include/opencv2/core/mat.inl.hpp:682: undefined reference to `cv::Mat::deallocate()'
camera_calibration.o: In function `cv::Mat::operator()(cv::Range, cv::Range) const':
/usr/local/include/opencv2/core/mat.inl.hpp:692: undefined reference to `cv::Mat::Mat(cv::Mat const&, cv::Range const&, cv::Range const&)'
camera_calibration.o: In function `cv::FileStorage::getFirstTopLevelNode() const':
/usr/local/include/opencv2/core/persistence.hpp:1167: undefined reference to `cv::FileStorage::root(int) const'
camera_calibration.o: In function `cv::FileNode::begin() const':
/usr/local/include/opencv2/core/persistence.hpp:1184: undefined reference to `cv::FileNodeIterator::FileNodeIterator(CvFileStorage const*, CvFileNode const*, unsigned long)'
camera_calibration.o: In function `cv::FileNode::end() const':
/usr/local/include/opencv2/core/persistence.hpp:1185: undefined reference to `cv::FileNode::size() const'
/usr/local/include/opencv2/core/persistence.hpp:1185: undefined reference to `cv::FileNodeIterator::FileNodeIterator(CvFileStorage const*, CvFileNode const*, unsigned long)'
camera_calibration.o: In function `cv::String::String(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/local/include/opencv2/core/cvstd.inl.hpp:81: undefined reference to `cv::String::allocate(unsigned long)'
camera_calibration.o: In function `cv::FileNode::operator std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >[abi:cxx11]() const':
/usr/local/include/opencv2/core/cvstd.inl.hpp:147: undefined reference to `cv::read(cv::FileNode const&, cv::String&, cv::String const&)'
camera_calibration.o: In function `Settings::Settings()':
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:31: undefined reference to `cv::VideoCapture::VideoCapture()'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:31: undefined reference to `cv::VideoCapture::~VideoCapture()'
camera_calibration.o: In function `Settings::read(cv::FileNode const&)':
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:60: undefined reference to `cv::FileNode::operator[](char const*) const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:61: undefined reference to `cv::FileNode::operator[](char const*) const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:62: undefined reference to `cv::FileNode::operator[](char const*) const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:63: undefined reference to `cv::FileNode::operator[](char const*) const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:64: undefined reference to `cv::FileNode::operator[](char const*) const'
camera_calibration.o:/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:65: more undefined references to `cv::FileNode::operator[](char const*) const' follow
camera_calibration.o: In function `Settings::validate()':
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:118: undefined reference to `cv::VideoCapture::open(int)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:120: undefined reference to `cv::VideoCapture::open(cv::String const&)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:121: undefined reference to `cv::VideoCapture::isOpened() const'
camera_calibration.o: In function `Settings::nextImage()':
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:157: undefined reference to `cv::VideoCapture::isOpened() const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:160: undefined reference to `cv::VideoCapture::operator>>(cv::Mat&)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:161: undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:164: undefined reference to `cv::imread(cv::String const&, int)'
camera_calibration.o: In function `Settings::readStringList(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)':
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:172: undefined reference to `cv::FileStorage::FileStorage(cv::String const&, int, cv::String const&)'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:173: undefined reference to `cv::FileStorage::isOpened() const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:176: undefined reference to `cv::FileNode::type() const'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:179: undefined reference to `cv::FileNodeIterator::operator++()'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:172: undefined reference to `cv::FileStorage::~FileStorage()'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:182: undefined reference to `cv::FileStorage::~FileStorage()'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:182: undefined reference to `cv::FileStorage::~FileStorage()'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:172: undefined reference to `cv::FileStorage::~FileStorage()'
camera_calibration.o: In function `Settings::~Settings()':
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:28: undefined reference to `cv::VideoCapture::~VideoCapture()'
/home/paradisolab/Desktop/camera_calibration/camera_calibration.cpp:28: undefined reference to `cv::VideoCapture::~VideoCapture()'
camera_calibration.o: In function `cv::Mat::Mat<cv::Point_<float> >(std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > > const&, bool)':
/usr/local/include/opencv2/core/mat.inl.hpp:484: undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
camera_calibration.o: In function `cv::Mat::Mat<float>(std::vector<float, std::allocator<float> > const&, bool)':
/usr/local/include/opencv2/core/mat.inl.hpp:484: undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
collect2: error: ld returned 1 exit status
makefile:9: recipe for target 'camcalib' failed
make: *** [camcalib] Error 1
It seems OpenCV is installed, because when I type "pkg-config --libs --cflags opencv" in terminal, I get:
-I/usr/local/include/opencv -I/usr/local/include -L/usr/local/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_viz -lippicv -lopencv_core
I've been trying lots of things, but I'm stumped. If anyone has any advice, I would greatly appreciate it.