I think I understand the gist of LNK2019 errors from reading SO and this MSDN article.
I have one Why question and one How question (both asked in the title already).
Why would a library provide a .cpp file with unimplemented functions? I'm guessing the answer is: "So end-users can implement those functions themselves, or 'link' some other thing that does." (Please correct me if I'm wrong, but I'll continue with this assumption.)
For example, in the screenshot below (click for larger version), I show the LNK2019 errors I encountered, as well as the offending file, wx.cpp
.
None of the methods in the class mglCanvasWX
are implemented (and yes, I've scrolled down :-). Here's a permanent Pastebin of wx.cpp
, and here's the output, in case someone wants to peer at the code, but I wouldn't ask of anyone to go so far.
How do such functions get implemented?
I'm guessing it's the .dll files which contain the implementations. Therefore, I need to locate the .dll file implementing Window
, ToggleAlpha
, ToggleLight
, and so on. (I'm guessing I can ignore all the other types of files, .obj, .lib, .exp, etc.) But how do I know where to find those .dll files?—or even know that a .dll file does implement those functions, since they're binary (non-human-readable) files?
I'm sorry to ask two questions at once, but I think these are the essential things I need to understand to resolve this linker error. (I feel I'm missing a single concept, even if I needed to ask in two questions.) Thank you in advance for any guidance you can give, and sorry to add to the existing pile of LNK2019 questions on SO...
Addendum
This might be relevant:
# define MGL_EXPORT __declspec(dllexport)
But I'm not sure whether this indicates that this unimplemented class is being exported as a DLL (of what use would such a DLL be?), or indicates that this class must be implemented by a DLL file (which would make more sense).
Also, the reason I phrased my question, "Why would a library...", is that the other dependency in this project, mgl-fltk
, provides a similar source, but does implement the analogous class and its functions (and builds fine)! See a screenshot here. Its class definition, however, unlike mgl-wx
, omits the MGL_EXPORT
, hinting to me that FLTK was not intended to be implemented externally.
class mglCanvasFL : public mglCanvasWnd
Theory
Okay, after some more thinking, I came up with a theory, but only an experienced software developer could tell me if it's plausible / makes sense.
Did the developer(s) of MathGL, perhaps, simply not get around to implementing those definitions? That is, is it possible MathGL doesn't yet support wxWidgets?
See, in the original MathGL source, there are these files:
QT, FLTK, and GLUT all implement their mglCanvasQT
, mglCanvasFL
, and mglCanvasGLUT
, e.g.
// qt.cpp
void mglCanvasQT::Animation() { QMGL->animation(true); }
void mglCanvasQT::ToggleAlpha() { QMGL->setAlpha(!QMGL->getAlpha()); }
// fltk.cpp
void mglCanvasFL::Animation() { Fl::lock(); mgl_sshow_cb(0,mgl); Fl::unlock(); }
void mglCanvasFL::ToggleAlpha() { Fl::lock(); mgl->toggle_alpha(); Fl::unlock(); }
// glut.cpp
class mglCanvasGLUT : public mglCanvasGL
{
public:
// ...
void ToggleAlpha() { _mgl_key_up('r',0,0); }
void Animation() { _mgl_key_up('m',0,0); } ///< Run slideshow (animation) of frames
// ...
}
and it's only mglCanvasWX
that's left unimplemented, and only mglCanvasWX
that has the MGL_EXPORT
macro ahead of its class name.
So what's the likely explanation? That WX support just isn't there yet? Or, support for WX exists, but was found easier to provide as an external library (DLL)? I'd really appreciate if an experienced software developer could weigh in on this...