I am trying to create a class with an std::function member:
# include<functional>
class Widget {
public:
std::function<int(double)> call_foo;
Widget(std::function<int(double)> call_func)
: call_foo(call_func)
{};
};
However, when I try to initialize the class my code fails:
const int f(double x){
if(x > 5.0){
return 22;
}
return 17;
}
int main()
{
std::function<int(double)> f1 = f;
Widget p(f1);
}
The full set of errors is below:
tmp/ccDoRHCh.o: In function `__static_initialization_and_destruction_0(int, int)':
widget.cpp:(.text+0x109): undefined reference to `std::ios_base::Init::Init()'
widget.cpp:(.text+0x118): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccDoRHCh.o:(.rodata._ZTIPFidE[_ZTIPFidE]+0x0): undefined reference to `vtable for __cxxabiv1::__pointer_type_info'
/tmp/ccDoRHCh.o:(.rodata._ZTIFidE[_ZTIFidE]+0x0): undefined reference to `vtable for __cxxabiv1::__function_type_info'
/tmp/ccDoRHCh.o:(.eh_frame+0xab): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
I am compiling with C++ 11 enabled.
Chances are either you forgot
#include <functional>
or you'r not compiling in C++11 mode.
Related
This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 7 years ago.
I'm getting this errors and I can't find solution anywhere.. It's supposed to be working but with this errors I'm not moving on and I can't find where is problem...
g++ -std=c++0x -pedantic -Wall -Wextra simims.cpp -o simims
/tmp/ccZa3W7s.o: In function `Calendar::Init(double, double)':
simims.cpp:(.text+0x5d): undefined reference to `Calendar::start_time'
simims.cpp:(.text+0x6a): undefined reference to `Calendar::Time'
simims.cpp:(.text+0x77): undefined reference to `Calendar::end_time'
/tmp/ccZa3W7s.o: In function `Calendar::Push(Process*, double)':
simims.cpp:(.text+0x9f): undefined reference to
`Calendar::listOfEvents[abi:cxx11]'
/tmp/ccZa3W7s.o: In function `Calendar::Pop(std::__cxx11::list<Process,
std::allocator<Process> >)':
simims.cpp:(.text+0x1b9): undefined reference to
`Calendar::listOfEvents[abi:cxx11]'
/tmp/ccZa3W7s.o: In function `Calendar::PopLists[abi:cxx11](double)':
simims.cpp:(.text+0x1da): undefined reference to
`Calendar::listOfEvents[abi:cxx11]'
/tmp/ccZa3W7s.o: In function `Calendar::Run()':
simims.cpp:(.text+0x230): undefined reference to `Calendar::Time'
simims.cpp:(.text+0x24a): undefined reference to
`Calendar::listOfEvents[abi:cxx11]'
simims.cpp:(.text+0x29a): undefined reference to `Calendar::end_time'
simims.cpp:(.text+0x2b1): undefined reference to `Calendar::Time'
simims.cpp:(.text+0x2b9): undefined reference to `Calendar::Time'
simims.cpp:(.text+0x2c1): undefined reference to `Calendar::start_time'
simims.cpp:(.text+0x2d9): undefined reference to `Process::Behavior()'
simims.cpp:(.text+0x2f8): undefined reference to `Calendar::Time'
simims.cpp:(.text+0x30c): undefined reference to `Calendar::Time'
/tmp/ccZa3W7s.o: In function `Process::Wait(double)':
simims.cpp:(.text+0x3ef): undefined reference to `Calendar::Time'
collect2: error: ld returned 1 exit status
Here is my class in C++:
class Calendar
{
public:
static double start_time;
static double Time;
static double end_time;
static list<list<Process>> listOfEvents;
Calendar();
~Calendar();
static void Run();
static void Push(Process*, double t);
static Process * Pop(list<Process> listOfLists);
static list<Process> PopLists(double t);
static void Init(double, double);
static Calendar * GetInstance() // Singleton
{
if(instance == NULL)
instance = new Calendar();
return instance;
}
private:
static Calendar * instance; // Singleton variable
};
Anyone know where could be a problem?
Thank you
There is a collision between variable name Time and the class Time.
static double Time;
Rename the Time to some other variable.
static double MyTime;
You should compile the file with the Calendar class first:
g++ -std=c++0x -pedantic -Wall -Wextra Calendar.cpp -o calendar.o
and then try to link it with simims.cpp:
g++ -std=c++0x -pedantic -Wall -Wextra calendar.o simims.cpp -o simims
I am trying to get OGDF working to see if it is suitable for my project, but I am having trouble with a sample program.
I am trying to compile this example program:
#include <ogdf/basic/Graph.h>
#include <ogdf/basic/graph_generators.h>
#include <ogdf/layered/DfsAcyclicSubgraph.h>
using namespace ogdf;
int main()
{
Graph G;
randomSimpleGraph(G, 10, 20);
DfsAcyclicSubgraph DAS;
DAS.callAndReverse(G);
G.writeGML("test.gml");
return 0;
}
using this command:
$g++ -pthread -I ./OGDF/ -L ./OGDF/_release/ -lOGDF test2.cpp
But I get the following error
/tmp/ccbpkfdt.o: In function `main':
test2.cpp:(.text+0x12): undefined reference to `ogdf::Graph::Graph()'
test2.cpp:(.text+0x2e): undefined reference to `ogdf::randomSimpleGraph(ogdf::Graph&, int, int)'
test2.cpp:(.text+0x4e): undefined reference to `ogdf::AcyclicSubgraphModule::callAndReverse(ogdf::Graph&)'
test2.cpp:(.text+0x62): undefined reference to `ogdf::Graph::writeGML(char const*) const'
test2.cpp:(.text+0x7f): undefined reference to `ogdf::Graph::~Graph()'
test2.cpp:(.text+0xa1): undefined reference to `ogdf::Graph::~Graph()'
/tmp/ccbpkfdt.o: In function `__static_initialization_and_destruction_0(int, int)':
test2.cpp:(.text+0xfb): undefined reference to `ogdf::Initialization::Initialization()'
test2.cpp:(.text+0x112): undefined reference to `ogdf::Initialization::~Initialization()'
/tmp/ccbpkfdt.o: In function `ogdf::DfsAcyclicSubgraph::DfsAcyclicSubgraph()':
test2.cpp:(.text._ZN4ogdf18DfsAcyclicSubgraphC2Ev[_ZN4ogdf18DfsAcyclicSubgraphC5Ev]+0x16): undefined reference to `vtable for ogdf::DfsAcyclicSubgraph'
/tmp/ccbpkfdt.o: In function `ogdf::DfsAcyclicSubgraph::~DfsAcyclicSubgraph()':
test2.cpp:(.text._ZN4ogdf18DfsAcyclicSubgraphD2Ev[_ZN4ogdf18DfsAcyclicSubgraphD5Ev]+0xb): undefined reference to `vtable for ogdf::DfsAcyclicSubgraph'
collect2: error: ld returned 1 exit status
I tried compiling hello world, with an include from OGDF, and I still got:
undefined reference to `ogdf::Initialization::Initialization()'
I think I am not linking properly or something?
You have to be very careful in which order you type stuff when linking with a library.
Try putting test2.cpp before -lOGDF instead, like this:
g++ -pthread -I ./OGDF/ -L ./OGDF/_release/ test2.cpp -lOGDF
You must build your program using the -DOGDF_DLL when using OGDF as a shared library.
See here: http://www.ogdf.net/doku.php/tech:defines
I am trying to call R functions from C++ on Windows. I am using MinGW for compiling the program, but it throws error while compiling. Code (taken from Dirk) and compilation error are as follows:
#include <iostream>
using namespace std;
#include "RInside.h" // for the embedded R via RInside
Rcpp::NumericMatrix createMatrix(const int n) {
Rcpp::NumericMatrix M(n,n);
for (int i=0; i<n; i++) {
for (int j=0; j<n; j++) {
M(i,j) = i*10+j;
}
}
return(M);
}
int main(int argc, char *argv[]) {
const int mdim = 4; // let the matrices be 4 by 4
SEXP ans;
RInside R(argc, argv); // create an embedded R instance
Rcpp::NumericMatrix M = createMatrix(mdim); // create and fill a sample data Matrix
R["M"] = M; // assign C++ matrix M to R's 'M' var
std::string evalstr = "\
cat('Running ls()\n'); print(ls()); \
cat('Showing M\n'); print(M); \
cat('Showing colSums()\n'); Z <- colSums(M); print(Z); \
Z"; // returns Z
ans = R.parseEval(evalstr); // eval the init string -- Z is now in ans
Rcpp::NumericVector v(ans); // convert SEXP ans to a vector of doubles
for (int i=0; i< v.size(); i++) { // show the result
std::cout << "In C++ element " << i << " is " << v[i] << std::endl;
}
return 0;
}
Compile:
g++ -I "C:\ProgramFiles\R\R-2.14.0\library\RInside\include" -I "C:\Progra
mFiles\R\R-2.14.0\library\Rcpp\include" -I "C:\ProgramFiles\R\R-2.14.0\include"
RFunctions.cpp -o sh1.exe
Error:
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text+0x19a): und
efined reference to `RInside::RInside(int, char const* const*, bool)'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text+0x1ee): und
efined reference to `RInside::operator[](std::string const&)'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text+0x26d): und
efined reference to `RInside::parseEval(std::string const&)'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text+0x35b): und
efined reference to `RInside::~RInside()'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text+0x3e1): und
efined reference to `RInside::~RInside()'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp7RO
bjectC2Ev[Rcpp::RObject::RObject()]+0x8): undefined reference to `vtable for Rcp
p::RObject'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp7RO
bjectC2Ev[Rcpp::RObject::RObject()]+0xd): undefined reference to `_imp__R_NilVal
ue'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN7RInside
5ProxyD1Ev[RInside::Proxy::~Proxy()]+0xd): undefined reference to `Rcpp::RObject
::~RObject()'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve
ctorILi14EED2Ev[Rcpp::Vector<14>::~Vector()]+0x16): undefined reference to `Rcpp
::RObject::~RObject()'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve
ctorILi14EED1Ev[Rcpp::Vector<14>::~Vector()]+0x16): undefined reference to `Rcpp
::RObject::~RObject()'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve
ctorILi14EEC1EP7SEXPREC[Rcpp::Vector<14>::Vector(SEXPREC*)]+0x57): undefined ref
erence to `Rcpp::RObject::setSEXP(SEXPREC*)'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve
ctorILi14EEC1EP7SEXPREC[Rcpp::Vector<14>::Vector(SEXPREC*)]+0x66): undefined ref
erence to `Rcpp::RObject::~RObject()'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ma
trixILi14EEC1ERKiS3_[Rcpp::Matrix<14>::Matrix(int const&, int const&)]+0x2c): un
defined reference to `Rcpp::Dimension::Dimension(unsigned int const&, unsigned i
nt const&)'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZNK4Rcpp6V
ectorILi14EE4sizeEv[Rcpp::Vector<14>::size() const]+0x10): undefined reference t
o `Rf_length'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6r_
castILi14EEEP7SEXPRECS2_[SEXPREC* Rcpp::r_cast<14>(SEXPREC*)]+0xd): undefined re
ference to `TYPEOF'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6r_
castILi14EEEP7SEXPRECS2_[SEXPREC* Rcpp::r_cast<14>(SEXPREC*)]+0x1d): undefined r
eference to `SEXPREC* Rcpp::internal::r_true_cast<14>(SEXPREC*)'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve
ctorILi14EEC2ERKNS_9DimensionE[Rcpp::Vector<14>::Vector(Rcpp::Dimension const&)]
+0x46): undefined reference to `Rcpp::Dimension::prod() const'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve
ctorILi14EEC2ERKNS_9DimensionE[Rcpp::Vector<14>::Vector(Rcpp::Dimension const&)]
+0x56): undefined reference to `Rf_allocVector'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve
ctorILi14EEC2ERKNS_9DimensionE[Rcpp::Vector<14>::Vector(Rcpp::Dimension const&)]
+0x67): undefined reference to `Rcpp::RObject::setSEXP(SEXPREC*)'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve
ctorILi14EEC2ERKNS_9DimensionE[Rcpp::Vector<14>::Vector(Rcpp::Dimension const&)]
+0x7d): undefined reference to `Rcpp::Dimension::size() const'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve
ctorILi14EEC2ERKNS_9DimensionE[Rcpp::Vector<14>::Vector(Rcpp::Dimension const&)]
+0xc9): undefined reference to `Rcpp::RObject::attr(std::string const&) const'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6Ve
ctorILi14EEC2ERKNS_9DimensionE[Rcpp::Vector<14>::Vector(Rcpp::Dimension const&)]
+0x13b): undefined reference to `Rcpp::RObject::~RObject()'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZNK4Rcpp11
Environment6assignINS_6MatrixILi14EEEEEbRKSsRKT_[bool Rcpp::Environment::assign<
Rcpp::Matrix<14> >(std::basic_string<char, std::char_traits<char>, std::allocato
r<char> > const&, Rcpp::Matrix<14> const&) const]+0x23): undefined reference to
`Rcpp::Environment::assign(std::string const&, SEXPREC*) const'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp7RO
bject14AttributeProxyaSINS_9DimensionEEERS1_RKT_[Rcpp::RObject::AttributeProxy&
Rcpp::RObject::AttributeProxy::operator=<Rcpp::Dimension>(Rcpp::Dimension const&
)]+0x1c): undefined reference to `Rcpp::RObject::AttributeProxy::set(SEXPREC*) c
onst'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp8in
ternal13r_init_vectorILi14EEEvP7SEXPREC[void Rcpp::internal::r_init_vector<14>(S
EXPREC*)]+0xd): undefined reference to `double* Rcpp::internal::r_vector_start<1
4, double>(SEXPREC*)'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp8in
ternal13r_init_vectorILi14EEEvP7SEXPREC[void Rcpp::internal::r_init_vector<14>(S
EXPREC*)]+0x23): undefined reference to `Rf_length'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp8in
ternal21wrap_dispatch_unknownINS_9DimensionEEEP7SEXPRECRKT_NS_6traits17integral_
constantIbLb1EEE[SEXPREC* Rcpp::internal::wrap_dispatch_unknown<Rcpp::Dimension>
(Rcpp::Dimension const&, Rcpp::traits::integral_constant<bool, true>)]+0xd): und
efined reference to `Rcpp::Dimension::operator SEXPREC*() const'
C:\Users\ksharma\AppData\Local\Temp\ccgMgFPS.o:RFunctions.cpp:(.text$_ZN4Rcpp6tr
aits14r_vector_cacheILi14EE6updateERKNS_6VectorILi14EEE[Rcpp::traits::r_vector_c
ache<14>::update(Rcpp::Vector<14> const&)]+0x15): undefined reference to `double
* Rcpp::internal::r_vector_start<14, double>(SEXPREC*)'
collect2: ld returned 1 exit status
Any ideas what I am missing?
Jim is correct in his earlier answer, but there is more.
When using RInside , you also need to
include and link with Rcpp (which RInside depends upon) a
include and link with R (which both depends upon) as well as of course
RInside's own library
The easiest way of doing this is to simply use the Makefile from the examples/standard directory --- given that you copied the code of one of the examples, you should also copy the build instructions.
Lastly, and that is your biggest issue: RInside applications do not currently work on Windows, which is clearly documented on the RInside page. It will build, but segfault on startup. Debugging help would be appreciated, this works on OS X and Linux.
You're not actually linking in the R library (whatever that is).
I try to write a webserver. As far as I am, it works quiet good with Windows. But I want to make it also Unix compatible. And I think there has to be a problem with the heredity f the exception class.
For better understanding, just the important parts:
server.cpp
#include <exception>
#include <stdexcept>
#ifdef __unix__
#include "UnixSocket.h"
#elif __WIN32__ || _MSC_VER
#include "WinSocket.h"
#endif
#include "HTTPParser.h"
int main(void) {
try {
socket->socketInit(PORT);
}
catch (exception &e) {
cout << endl << "Exception: " << e.what() << endl;
socket->cleanAll();
}
return 0
}
NetInterface.h
class NetInterface : public exception {
private:
public:
virtual void socketInit(const char *port) = 0;
virtual void cleanAll(void) = 0;
virtual void cleanPersCon(void) = 0;
virtual char *akzeptieren(void) = 0;
virtual void empfangen(void) = 0;
virtual void senden(void) = 0;
virtual void *get_in_addr(struct sockaddr *sa) = 0;
virtual string getIncoming(void) = 0;
virtual void setOutcoming(string s) = 0;
virtual ~NetInterface() throw() {};
};
UnixSocket.h
class UnixSocket : virtual public NetInterface {
private:
[...]
public:
UnixSocket(void);
//kill socket connections
void cleanAll(void);
void cleanPersCon(void);
//SysCalls
void socketInit(const char *port);
char *akzeptieren(void);
void empfangen(void);
void senden(void);
//Getter and Setter
string getIncoming(void);
void setOutcoming(string s);
virtual ~UnixSocket() throw() {};
};
HTTPParser.h
class HTTPParser : public exception {
private:
[...]
public:
HTTPParser(NetInterface *_socket, string _path);
void parsePacket(void);
virtual ~HTTPParser() throw() {};
};
There you can se a short summary of the class declarations.
But now the gcc tells me something like this:
/tmp/cc8DNmKI.o:(.rodata._ZTV10HTTPParser[vtable for HTTPParser]+0x10): undefined reference to `std::exception::what() const'
/tmp/cc8DNmKI.o:(.rodata._ZTV10UnixSocket[vtable for UnixSocket]+0x14): undefined reference to `std::exception::what() const'
/tmp/cc8DNmKI.o:(.rodata._ZTV10UnixSocket[vtable for UnixSocket]+0x78): undefined reference to `std::exception::what() const'
/tmp/cc8DNmKI.o:(.rodata._ZTV12NetInterface[vtable for NetInterface]+0x10): undefined reference to `std::exception::what() const'
/tmp/cc8DNmKI.o:(.rodata._ZTV12NetInterface[vtable for NetInterface]+0x14): undefined reference to `__cxa_pure_virtual'
/tmp/cc8DNmKI.o:(.rodata._ZTV12NetInterface[vtable for NetInterface]+0x18): undefined reference to `__cxa_pure_virtual'
/tmp/cc8DNmKI.o:(.rodata._ZTV12NetInterface[vtable for NetInterface]+0x1c): undefined reference to `__cxa_pure_virtual'
/tmp/cc8DNmKI.o:(.rodata._ZTV12NetInterface[vtable for NetInterface]+0x20): undefined reference to `__cxa_pure_virtual'
/tmp/cc8DNmKI.o:(.rodata._ZTV12NetInterface[vtable for NetInterface]+0x24): undefined reference to `__cxa_pure_virtual'
/tmp/cc8DNmKI.o:(.rodata._ZTV12NetInterface[vtable for NetInterface]+0x28): more undefined references to `__cxa_pure_virtual' follow
/tmp/cc8DNmKI.o:(.rodata._ZTVSt16invalid_argument[vtable for std::invalid_argument]+0x10): undefined reference to `std::logic_error::what() const'
/tmp/cc8DNmKI.o:(.rodata._ZTVSt12domain_error[vtable for std::domain_error]+0x10): undefined reference to `std::logic_error::what() const'
/tmp/cc8DNmKI.o:(.rodata._ZTI10HTTPParser[typeinfo for HTTPParser]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
/tmp/cc8DNmKI.o:(.rodata._ZTI10HTTPParser[typeinfo for HTTPParser]+0x8): undefined reference to `typeinfo for std::exception'
/tmp/cc8DNmKI.o:(.rodata._ZTI10UnixSocket[typeinfo for UnixSocket]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
/tmp/cc8DNmKI.o:(.rodata._ZTI10UnixSocket[typeinfo for UnixSocket]+0x18): undefined reference to `typeinfo for std::exception'
/tmp/cc8DNmKI.o:(.rodata._ZTI12NetInterface[typeinfo for NetInterface]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
/tmp/cc8DNmKI.o:(.rodata._ZTI12NetInterface[typeinfo for NetInterface]+0x8): undefined reference to `typeinfo for std::exception'
/tmp/cc8DNmKI.o:(.rodata._ZTISt16invalid_argument[typeinfo for std::invalid_argument]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
/tmp/cc8DNmKI.o:(.rodata._ZTISt16invalid_argument[typeinfo for std::invalid_argument]+0x8): undefined reference to `typeinfo for std::logic_error'
/tmp/cc8DNmKI.o:(.rodata._ZTISt12domain_error[typeinfo for std::domain_error]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
/tmp/cc8DNmKI.o:(.rodata._ZTISt12domain_error[typeinfo for std::domain_error]+0x8): undefined reference to `typeinfo for std::logic_error'
/tmp/cc8DNmKI.o:(.eh_frame+0xeb): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
and even more....
Judging from undefined reference to __gxx_personality_v0 linker message it looks like you are linking with gcc. You need to link C++ applications with g++. Or link with gcc and add -lstdc++ to the linker command line.
You aren't showing the relevant code and compiler invocation, but know that std::exception has an unimplemented virtual member function what() that you're expected to override, so don't go throwing naked std::exceptions if you want to callwhat().
Any of the derived, specific exceptions in <stdexcept> will implement what() and allow you to store a message when you're constructing the exception object.
I am a leda-6.3 library user.
I used graphwin to manipulate and display graphs, but I found that references
to graphwin methods are undefined while compiling the code although they
are declared in the LEDA/incl/LEDA/graphics/graphwin.h
So I think it is a problem of object file.
#include <LEDA/graphics/graphwin.h>
#include <LEDA/graph/graph_alg.h>
using namespace leda;
int main()
{
GraphWin gw("LEDA Graph Editor");
node u=gw.new_node(point(100,100));
node v=gw.new_node(point(100,200));
gw.new_edge(u,v);
gw.display();
gw.get_window().read_mouse();
graph& G=gw.get_graph();
G.new_node();
gw.get_window().read_mouse();
gw.update_graph();
gw.get_window().read_mouse();
return 0;
}
compilation: g++ -I$LEDAROOT/incl -L$LEDAROOT gw.cpp -lleda -lX11 -lm -o gw
ERROR :
/tmp/ccVHyRbL.o: In function `main':
gw.cpp:(.text+0x1e): undefined reference to `leda::GraphWin::GraphWin(char const*)'
gw.cpp:(.text+0x58): undefined reference to `leda::GraphWin::new_node(leda::point const&)'
gw.cpp:(.text+0xc6): undefined reference to `leda::GraphWin::new_node(leda::point const&)'
gw.cpp:(.text+0x11c): undefined reference to `leda::GraphWin::new_edge(leda::node_struct*, leda::node_struct*)'
gw.cpp:(.text+0x128): undefined reference to `leda::GraphWin::display()'
gw.cpp:(.text+0x17e): undefined reference to `leda::GraphWin::update_graph()'
collect2: ld returned 1 exit status
Which edition of LEDA are you using?
Please consider that free edition of LEDA does not contain GraphWin.
So, it dos not contain GraphWin libraries, which results to getting such errors while compiling your program.