C++ newbie looking for help with linker error

L

lashnjo

[Linker error] undefined reference to
`HTMLWindow::HTMLWindow(std::string const&, std::string const&,
HINSTANCE__*, bool)'

Thats the error, and the code is below.
The complier is Dev-C++ 4.9.9.2.
Thank you if you can help.


#include <windows.h>
#include "HTMLWindow.h"

int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE unused__, LPSTR
lpszCmdLine, int nCmdShow) {

HTMLWindow* html_window = new HTMLWindow (

"<html><head>"
"<title>MSHTMLTest</title>" // seems a little useless in this
context
"</head><body>"
"<h1>This is a test</h1>"
"I offer the following links:"
"<ul>"
"<li><a href='http://www.google.com'>www.google.com</a>"
"<li><a href='http://www.adp-gmbh.ch'>www.adp-gmbh.ch</a>"
"<li><a href='http://www.yahoo.com'>www.yahoo.com</a>"
"</ul>"
"</body></html>",
"MSHTMLTest", hInstance,
false // not an url
);

MSG msg;
while (GetMessage(&msg, 0, 0, 0)) {
TranslateMessage(&msg);
if (msg.message >= WM_KEYFIRST &&
msg.message <= WM_KEYLAST) {
::SendMessage(html_window->hwnd_, msg.message, msg.wParam,
msg.lParam);
}
DispatchMessage(&msg);
}

return 0;
}
 
R

Robert Bauck Hamar

lashnjo said:
[Linker error] undefined reference to
`HTMLWindow::HTMLWindow(std::string const&, std::string const&,
HINSTANCE__*, bool)'

If you have defined HTMLWindow::HTMLWindow in a C++ file somewhere, you must
link it's object file together with your C++ file.
Thats the error, and the code is below.
The complier is Dev-C++ 4.9.9.2.

Dev-C++ is your IDE, not your compiler. The IDE just invokes the compiler,
but you could do this yourself. I guess your compiler is the GNU C++
compiler.
Thank you if you can help.

There is very little code to help.
#include <windows.h>
#include "HTMLWindow.h"

Does HTMLWindow.h also come with a HTMLWindow.c* (where c* stands for cpp,
cc, cxx, c++, or any other common C++ source file extension)? If it does,
then you must see to it that it is compiled with your project. For example,
you could add it to your project.
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE unused__, LPSTR
lpszCmdLine, int nCmdShow) {

HTMLWindow* html_window = new HTMLWindow (

"<html><head>"
"<title>MSHTMLTest</title>" // seems a little useless in this
context
"</head><body>"
"<h1>This is a test</h1>"
"I offer the following links:"
"<ul>"
"<li><a href='http://www.google.com'>www.google.com</a>"
"<li><a href='http://www.adp-gmbh.ch'>www.adp-gmbh.ch</a>"
"<li><a href='http://www.yahoo.com'>www.yahoo.com</a>"
"</ul>"
"</body></html>",
"MSHTMLTest", hInstance,
false // not an url
);

MSG msg;
while (GetMessage(&msg, 0, 0, 0)) {
TranslateMessage(&msg);
if (msg.message >= WM_KEYFIRST &&
msg.message <= WM_KEYLAST) {
::SendMessage(html_window->hwnd_, msg.message, msg.wParam,
msg.lParam);
}
DispatchMessage(&msg);
}

return 0;
}

You have called a lot of functions here. None of them are defined by the
standard. You might be better off asking in a NG related to your compiler
or operating system.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top