overloading operator<< undefined reference - c++

This is my h file:
class Student
{
public:
Student(std::string _name, size_t _age)
:m_name(_name), m_age(_age){}
friend std::ostream& operator<<(std::ostream& _os, const Student& _student);
private:
std::string m_name;
size_t m_age;
};
std::ostream& operator<<(std::ostream& _os, const Student& _student)
{
_os <<"Student " << _student.m_name << ", age: " << _student.m_age << std::endl;
return _os;
}
And this is the cpp:
#include <iostream>
#include "student.h"
int main()
{
Student s1("Anna", 13);
std::cout << s1;
return 0;
}
I am getting a linkage error:
undefined reference to `std::ostream::operator<<(unsigned int)'
(it's much longer, but I assume all has to do with the overloading of operator<<)
What am I doing wrong?
The full error:
/tmp/ccv0Mh7n.o: In function `operator<<(std::ostream&, Student const&)':
oplefshift.cpp:(.text+0x1a): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
oplefshift.cpp:(.text+0x27): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
oplefshift.cpp:(.text+0x38): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
oplefshift.cpp:(.text+0x45): undefined reference to `std::ostream::operator<<(unsigned int)'
oplefshift.cpp:(.text+0x50): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
oplefshift.cpp:(.text+0x56): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
/tmp/ccv0Mh7n.o: In function `main':
oplefshift.cpp:(.text+0x8c): undefined reference to `std::allocator<char>::allocator()'
oplefshift.cpp:(.text+0xa4): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
oplefshift.cpp:(.text+0xc8): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
oplefshift.cpp:(.text+0xd7): undefined reference to `std::allocator<char>::~allocator()'
oplefshift.cpp:(.text+0xe6): undefined reference to `std::cout'
oplefshift.cpp:(.text+0xf6): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
oplefshift.cpp:(.text+0xfc): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
oplefshift.cpp:(.text+0x131): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
oplefshift.cpp:(.text+0x157): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccv0Mh7n.o: In function `__static_initialization_and_destruction_0(int, int)':
oplefshift.cpp:(.text+0x1b2): undefined reference to `std::ios_base::Init::Init()'
oplefshift.cpp:(.text+0x1c7): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccv0Mh7n.o: In function `Student::Student(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int)':
oplefshift.cpp:(.text._ZN7StudentC2ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj[_ZN7StudentC5ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj]+0x11): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/ccv0Mh7n.o: In function `Student::~Student()':
oplefshift.cpp:(.text._ZN7StudentD2Ev[_ZN7StudentD5Ev]+0xe): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccv0Mh7n.o:(.eh_frame+0x93): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status

Use g++ to compile your code. If you are using gcc, add the -lsdtc++ at the end.
g++ student.cpp
or
gcc student.cpp -lstdc++

Related

Running the Examples from WebRTC C++ source code

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!

OpenABE C++ Library: Undefined Reference Error

I have successfully installed the OpenABE Library - https://github.com/zeutro/openabe
But when I try to compile my own program or run the example - https://github.com/zeutro/openabe/blob/master/examples/test_cp.cpp
g++ test.cpp
I get the Error:
/tmp/ccAcWSoq.o: In function main':
test.cpp:(.text+0x29): undefined reference tooabe::InitializeOpenABE()'
test.cpp:(.text+0x6a): undefined reference to oabe::OpenABECryptoContext::OpenABECryptoContext(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool)'
test.cpp:(.text+0xea): undefined reference tooabe::OpenABECryptoContext::generateParams()'
test.cpp:(.text+0x1bf): undefined reference to oabe::OpenABECryptoContext::keygen(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&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
test.cpp:(.text+0x27b): undefined reference tooabe::OpenABECryptoContext::encrypt(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator >&)'
test.cpp:(.text+0x2dd): undefined reference to oabe::OpenABECryptoContext::decrypt(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> >&)'
test.cpp:(.text+0x385): undefined reference tooabe::ShutdownOpenABE()'
/tmp/ccAcWSoq.o: In function oabe::OpenABECryptoContext::~OpenABECryptoContext()':
test.cpp:(.text._ZN4oabe20OpenABECryptoContextD2Ev[_ZN4oabe20OpenABECryptoContextD5Ev]+0xf): undefined reference tovtable for oabe::OpenABECryptoContext'
collect2: error: ld returned 1 exit status
Here is the code - test.cpp
#include <iostream>
#include <string>
#include <cassert>
#include <openabe/openabe.h>
#include <openabe/zsymcrypto.h>
using namespace std;
using namespace oabe;
using namespace oabe::crypto;
int main(int argc, char **argv){
InitializeOpenABE();
OpenABECryptoContext cpabe("CP-ABE");
string ct, pt1 = "plaintext", pt2;
cpabe.generateParams();
cpabe.keygen("|attr1|attr2","key0");
cpabe.encrypt("attr1 and attr2",pt1,ct);
bool result = cpabe.decrypt("key0",ct,pt2);
assert(result && pt1 == pt2);
cout << "Message: " << pt2 << endl;
ShutdownOpenABE();
return 0;
}
Am I even compiling the file correctly?
Or is there any other issue that I cannot seem to identify?

C++ OpenCV 3.1.0 linking error (ubuntu)

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.

C++ MongoDB legacy client tutorial compile error

UPDATE
Solved the issue. The was the structure of the g++ command. This one worked for me:
g++ tutorial.cpp -I/opt/local/include -I/usr/include/boost -L/opt/local/lib -lmongoclient -lboost_thread -lboost_system -lboost_regex -o tutorial
OS: Ubuntu 16.04 64-bit
Following this tutorial:
https://mongodb.github.io/mongo-cxx-driver/legacy-v1/tutorial/
I'm able to build the mongodb-client using SCons with no issue.
mongo folder of header files here:
/opt/local/include
libmongoclient.a file here:
/opt/local/lib
Code is as follows, same as the tutorial:
#include <cstdlib>
#include <iostream>
#include "mongo/client/dbclient.h" // for the driver
void run() {
mongo::DBClientConnection c;
c.connect("localhost");
}
int main() {
mongo::client::initialize();
try {
run();
std::cout << "connected ok" << std::endl;
} catch( const mongo::DBException &e ) {
std::cout << "caught " << e.what() << std::endl;
}
return EXIT_SUCCESS;
}
This is the command I'm using to compile:
g++ -I/opt/local/include -L/opt/local/lib -pthread -lmongoclient -lboost_thread -lboost_system -lboost_filesystem -lboost_program_options tutorial.cpp -o tutorial
I receive the following error
/tmp/cceJe78D.o: In function `run()':
tutorial.cpp:(.text+0x34): undefined reference to `mongo::DBClientConnection::DBClientConnection(bool, mongo::DBClientReplicaSet*, double)'
/tmp/cceJe78D.o: In function `main':
tutorial.cpp:(.text+0x12f): undefined reference to `mongo::client::Options::Options()'
tutorial.cpp:(.text+0x148): undefined reference to `mongo::client::initialize(mongo::client::Options const&)'
/tmp/cceJe78D.o: In function `__static_initialization_and_destruction_0(int, int)':
tutorial.cpp:(.text+0x299): undefined reference to `boost::system::generic_category()'
tutorial.cpp:(.text+0x2a5): undefined reference to `boost::system::generic_category()'
tutorial.cpp:(.text+0x2b1): undefined reference to `boost::system::system_category()'
/tmp/cceJe78D.o: In function `mongo::DBException::DBException(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':
tutorial.cpp:(.text._ZN5mongo11DBExceptionC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi[_ZN5mongo11DBExceptionC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi]+0x21): undefined reference to `vtable for mongo::DBException'
/tmp/cceJe78D.o: In function `mongo::DBException::~DBException()':
tutorial.cpp:(.text._ZN5mongo11DBExceptionD2Ev[_ZN5mongo11DBExceptionD5Ev]+0x10): undefined reference to `vtable for mongo::DBException'
/tmp/cceJe78D.o: In function `mongo::DBException::addContext(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
tutorial.cpp:(.text._ZN5mongo11DBException10addContextERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN5mongo11DBException10addContextERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x33): undefined reference to `mongo::causedBy(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/cceJe78D.o: In function `mongo::UserException::UserException(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
tutorial.cpp:(.text._ZN5mongo13UserExceptionC2EiRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN5mongo13UserExceptionC5EiRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x2a): undefined reference to `vtable for mongo::UserException'
/tmp/cceJe78D.o: In function `mongo::UserException::~UserException()':
tutorial.cpp:(.text._ZN5mongo13UserExceptionD2Ev[_ZN5mongo13UserExceptionD5Ev]+0xd): undefined reference to `vtable for mongo::UserException'
/tmp/cceJe78D.o: In function `mongo::DBClientConnection::~DBClientConnection()':
tutorial.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD5Ev]+0xe): undefined reference to `vtable for mongo::DBClientConnection'
tutorial.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD5Ev]+0x1a): undefined reference to `vtable for mongo::DBClientConnection'
tutorial.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD5Ev]+0x2c): undefined reference to `mongo::DBClientConnection::_numConnections'
tutorial.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD5Ev]+0xbb): undefined reference to `mongo::DBClientBase::~DBClientBase()'
tutorial.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD5Ev]+0x189): undefined reference to `mongo::DBClientBase::~DBClientBase()'
/tmp/cceJe78D.o: In function `mongo::DBClientConnection::connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
tutorial.cpp:(.text._ZN5mongo18DBClientConnection7connectERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN5mongo18DBClientConnection7connectERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x78): undefined reference to `mongo::HostAndPort::HostAndPort(mongo::StringData const&)'
/tmp/cceJe78D.o:(.gcc_except_table+0x50): undefined reference to `typeinfo for mongo::DBException'
/tmp/cceJe78D.o:(.rodata._ZTVN5mongo16ConnectExceptionE[_ZTVN5mongo16ConnectExceptionE]+0x30): undefined reference to `mongo::UserException::appendPrefix(std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >&) const'
/tmp/cceJe78D.o:(.rodata._ZTVN5mongo16ConnectExceptionE[_ZTVN5mongo16ConnectExceptionE]+0x40): undefined reference to `mongo::DBException::toString[abi:cxx11]() const'
/tmp/cceJe78D.o:(.rodata._ZTVN5mongo18AssertionExceptionE[_ZTVN5mongo18AssertionExceptionE]+0x40): undefined reference to `mongo::DBException::toString[abi:cxx11]() const'
/tmp/cceJe78D.o:(.rodata._ZTIN5mongo16ConnectExceptionE[_ZTIN5mongo16ConnectExceptionE]+0x10): undefined reference to `typeinfo for mongo::UserException'
/tmp/cceJe78D.o:(.rodata._ZTIN5mongo18AssertionExceptionE[_ZTIN5mongo18AssertionExceptionE]+0x10): undefined reference to `typeinfo for mongo::DBException'
collect2: error: ld returned 1 exit status
I've searched around Google, and saw some people with the same issue, but they didn't appear to be linking files correctly. As far as I can tell I'm doing everything correctly.
Any help would be greatly appreciated.
EDIT
Output if I change the command to:
g++ tutorial.cpp -I/opt/local/include -I/usr/include/boost -L/opt/local/lib -pthread -lmongoclient -lboost_thread -lboost_system -lboost_filesystem -lboost_program_options -o tutorial
/opt/local/lib/libmongoclient.a(dbclient.o): In function `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign(char const*, char const*, unsigned int)':
/usr/include/boost/regex/v4/basic_regex.hpp:380: undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)'
/opt/local/lib/libmongoclient.a(dbclient.o): In function `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::unwind_extra_block(bool)':
/usr/include/boost/regex/v4/perl_matcher_non_recursive.hpp:1135: undefined reference to `boost::re_detail::put_mem_block(void*)'
/opt/local/lib/libmongoclient.a(dbclient.o): In function `boost::cpp_regex_traits<char>::transform_primary(char const*, char const*) const':
/usr/include/boost/regex/v4/cpp_regex_traits.hpp:965: undefined reference to `boost::re_detail::cpp_regex_traits_implementation<char>::transform_primary(char const*, char const*) const'
/opt/local/lib/libmongoclient.a(dbclient.o): In function `boost::cpp_regex_traits<char>::transform(char const*, char const*) const':
/usr/include/boost/regex/v4/cpp_regex_traits.hpp:961: undefined reference to `boost::re_detail::cpp_regex_traits_implementation<char>::transform(char const*, char const*) const'
/opt/local/lib/libmongoclient.a(dbclient.o): In function `void boost::re_detail::raise_error<boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > > >(boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::error_type)':
/usr/include/boost/regex/pattern_except.hpp:75: undefined reference to `boost::re_detail::raise_runtime_error(std::runtime_error const&)'
/opt/local/lib/libmongoclient.a(dbclient.o): In function `boost::re_detail::cpp_regex_traits_implementation<char>::error_string(boost::regex_constants::error_type) const':
/usr/include/boost/regex/v4/cpp_regex_traits.hpp:448: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)'
/opt/local/lib/libmongoclient.a(dbclient.o): In function `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::extend_stack()':
/usr/include/boost/regex/v4/perl_matcher_non_recursive.hpp:213: undefined reference to `boost::re_detail::get_mem_block()'
/opt/local/lib/libmongoclient.a(dbclient.o): In function `boost::re_detail::save_state_init::save_state_init(boost::re_detail::saved_state**, boost::re_detail::saved_state**)':
/usr/include/boost/regex/v4/perl_matcher_non_recursive.hpp:107: undefined reference to `boost::re_detail::get_mem_block()'
/opt/local/lib/libmongoclient.a(dbclient.o): In function `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match_imp()':
/usr/include/boost/regex/v4/perl_matcher_common.hpp:208: undefined reference to `boost::re_detail::verify_options(unsigned int, boost::regex_constants::_match_flags)'
/opt/local/lib/libmongoclient.a(dbclient.o): In function `boost::re_detail::save_state_init::~save_state_init()':
/usr/include/boost/regex/v4/perl_matcher_non_recursive.hpp:115: undefined reference to `boost::re_detail::put_mem_block(void*)'
/opt/local/lib/libmongoclient.a(dbclient.o): In function `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match_prefix()':
/usr/include/boost/regex/v4/perl_matcher_common.hpp:333: undefined reference to `boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >::maybe_assign(boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > const&)'
/opt/local/lib/libmongoclient.a(dbclient.o): In function `boost::re_detail::save_state_init::~save_state_init()':
/usr/include/boost/regex/v4/perl_matcher_non_recursive.hpp:115: undefined reference to `boost::re_detail::put_mem_block(void*)'
/opt/local/lib/libmongoclient.a(dbclient.o): In function `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::perl_matcher(__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags, __gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >)':
/usr/include/boost/regex/v4/perl_matcher.hpp:365: undefined reference to `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)'
/opt/local/lib/libmongoclient.a(dbclient.o): In function `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match_match()':
/usr/include/boost/regex/v4/perl_matcher_non_recursive.hpp:991: undefined reference to `boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >::maybe_assign(boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > const&)'
collect2: error: ld returned 1 exit status
In your g++ command, try to have tutorial.cpp first before the other libs. Some linkers needs to see the objects that need symbols first (from left to right)

How do I resolve "undefined reference to 'std::basic_ostream<char, std::char_traits<char>"?

Well I'm trying to install SFML for C++ and it's giving me horrific log crashes... I linked and put all the paths for the compiler and the linker and Buid Log is giving me that:
GLCheck.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >&
std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
GLCheck.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
GLCheck.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
GLCheck.cpp||undefined reference to `std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long)'|
GLCheck.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
GLCheck.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
GLCheck.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
GLCheck.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
GLCheck.cpp||undefined reference to `std::ctype<char>::_M_widen_init() const'|
GLCheck.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
GLCheck.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
GLCheck.cpp||undefined reference to `std::ctype<char>::_M_widen_init() const'|
Texture.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Texture.cpp||undefined reference to `std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long)'|
Texture.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Texture.cpp||undefined reference to `std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long)'|
Texture.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Texture.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Texture.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Texture.cpp||undefined reference to `std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long)'|
Texture.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Texture.cpp||undefined reference to `std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long)'|
Texture.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Texture.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Texture.cpp||undefined reference to `std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long)'|
Texture.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Texture.cpp||undefined reference to `std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long)'|
Texture.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Texture.cpp||undefined reference to `std::ctype<char>::_M_widen_init() const'|
Shader.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Shader.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Shader.cpp||undefined reference to `std::ctype<char>::_M_widen_init() const'|
Shader.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Shader.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Shader.cpp||undefined reference to `std::ctype<char>::_M_widen_init() const'|
Shader.cpp||undefined reference to `std::ctype<char>::_M_widen_init() const'|
Shader.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Shader.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Shader.cpp||undefined reference to `std::ctype<char>::_M_widen_init() const'|
Shader.cpp||undefined reference to `std::ctype<char>::_M_widen_init() const'|
Shader.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Shader.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Shader.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Shader.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Shader.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Shader.cpp||more undefined references to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)' follow|
Shader.cpp||undefined reference to `std::ctype<char>::_M_widen_init() const'|
Shader.cpp||undefined reference to `std::ctype<char>::_M_widen_init() const'|
Shader.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
Shader.cpp||undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings (0 minutes, 1 seconds) ===|
I have tried that links: -lminwg32, and nothing happens. What can I do?