Reputation: 25559
I encountered a wired problem on my C++ code. I'm using TCLAP software to accept command line arguments, and one of the flags is a file name:
TCLAP::ValueArg<string> Poly ("p", "poly", "file name of the polynomial", false, "", "string");
I also have another function that accepts 3 parameters,
void GetBiPoly(const char *filename, BiPoly<BigFloat> *u, BiPoly<BigFloat> *v);
I'm passing the Poly string to the function GetBiPoly
in this way:
benchmark::GetBiPoly(Poly.getValue().c_str(), &fxy, &gxy);
When I compile the program, it gives me the following error:
miranda.cpp:(.text+0x1900): undefined reference to `benchmark::GetBiPoly(char const*, CORE::BiPoly<CORE::BigFloat>*, CORE::BiPoly<CORE::BigFloat>*)'
It seems like the only difference is that the type of the file name in the error information is char const*
, while the definition is const char*
. Can anybody tell me what the problem it seems to be? Thanks.
Upvotes: 0
Views: 190
Reputation: 225162
char const *
and const char *
are exactly the same thing. Your problem is not related to that part of the message. Your error is that you're calling the function benchmark::GetBiPoly()
, but the linker can't find it in the objects you're linking. Where is that function defined? Are you linking it? Is it in that namespace?
Upvotes: 1