Hi, I'm reading Bjarne Stroustrup's "Programming Principles and Practice Using C++" and I got a problem in Chapter 12. I keep getting "unresolved external symbol" error. The following is the code.
#include "stdafx.h"
#include"code\Simple_window.h"
#include"code\Graph.h"
int main()
{
using namespace Graph_lib;
Point tl(100, 100);
Simple_window win(tl, 600, 400, "Canvas");
Graph_lib::Polygon poly;
poly.add(Point(300, 200));
poly.add(Point(350, 100));
poly.add(Point(400, 200));
poly.set_color(Color::red);
win.attach(poly);
win.wait_for_button();
}
I'm using Visual Studio 2013, and I've downloaded the FLTK from
http://fltk.org.
The only difference is that I downloaded the latest version 1.3.3 instead of version 1.1 on the book. I think it doesn't matter and won't lead to any trouble. I think I have installed the FLTK properly for the "demo" project attacted to FLTK runs well and I copy some code from Internet to test, they compile and run,too. As for the Header files and cpp source files written by the author, I download them from his website and put them together in a document named "code" as you can see in my code above. I think I put "code" document in the correct place because my IDE didn't tell me he couldn't find those Header file. By the way, I created a "Win32 project", not a "Win32 Console Application". I don't know if I created a correct project.
The errors IDE tells me is the following:
Warning 1 warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library C:\Users\Admin\documents\visual studio 2013\Projects\Win32Project1\Win32Project1\LINK Win32Project1
Error 4 error LNK2019: unresolved external symbol "public: void __thiscall Graph_lib::Window::attach(class Graph_lib::Widget &)" (?attach@Window@Graph_lib@@QAEXAAVWidget@2@@Z) referenced in function "public: __thiscall Simple_window::Simple_window(struct Graph_lib::Point,int,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0Simple_window@@QAE@UPoint@Graph_lib@@HHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) C:\Users\Admin\documents\visual studio 2013\Projects\Win32Project1\Win32Project1\Win32Project1.obj Win32Project1
Error 3 error LNK2019: unresolved external symbol "public: void __thiscall Graph_lib::Window::attach(class Graph_lib::Shape &)" (?attach@Window@Graph_lib@@QAEXAAVShape@2@@Z) referenced in function _main C:\Users\Admin\documents\visual studio 2013\Projects\Win32Project1\Win32Project1\Win32Project1.obj Win32Project1
Error 10 error LNK2019: unresolved external symbol "public: void __thiscall Graph_lib::Polygon::add(struct Graph_lib::Point)" (?add@Polygon@Graph_lib@@QAEXUPoint@2@@Z) referenced in function _main C:\Users\Admin\documents\visual studio 2013\Projects\Win32Project1\Win32Project1\Win32Project1.obj Win32Project1
Error 2 error LNK2019: unresolved external symbol "public: __thiscall Graph_lib::Window::Window(struct Graph_lib::Point,int,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0Window@Graph_lib@@QAE@UPoint@1@HHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: __thiscall Simple_window::Simple_window(struct Graph_lib::Point,int,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0Simple_window@@QAE@UPoint@Graph_lib@@HHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) C:\Users\Admin\documents\visual studio 2013\Projects\Win32Project1\Win32Project1\Win32Project1.obj Win32Project1
Error 7 error LNK2001: unresolved external symbol "public: virtual void __thiscall Graph_lib::Shape::move(int,int)" (?move@Shape@Graph_lib@@UAEXHH@Z) C:\Users\Admin\documents\visual studio 2013\Projects\Win32Project1\Win32Project1\Win32Project1.obj Win32Project1
Error 11 error LNK2001: unresolved external symbol "public: virtual void __thiscall Graph_lib::Polygon::draw_lines(void)const " (?draw_lines@Polygon@Graph_lib@@UBEXXZ) C:\Users\Admin\documents\visual studio 2013\Projects\Win32Project1\Win32Project1\Win32Project1.obj Win32Project1
Error 8 error LNK2001: unresolved external symbol "public: virtual void __thiscall Graph_lib::Open_polyline::draw_lines(void)const " (?draw_lines@Open_polyline@Graph_lib@@UBEXXZ) C:\Users\Admin\documents\visual studio 2013\Projects\Win32Project1\Win32Project1\Win32Project1.obj Win32Project1
Error 9 error LNK2001: unresolved external symbol "public: virtual void __thiscall Graph_lib::Closed_polyline::draw_lines(void)const " (?draw_lines@Closed_polyline@Graph_lib@@UBEXXZ) C:\Users\Admin\documents\visual studio 2013\Projects\Win32Project1\Win32Project1\Win32Project1.obj Win32Project1
Error 12 error LNK2001: unresolved external symbol "public: virtual void __thiscall Graph_lib::Button::attach(class Graph_lib::Window &)" (?attach@Button@Graph_lib@@UAEXAAVWindow@2@@Z) C:\Users\Admin\documents\visual studio 2013\Projects\Win32Project1\Win32Project1\Win32Project1.obj Win32Project1
Error 5 error LNK2001: unresolved external symbol "protected: virtual void __thiscall Graph_lib::Window::draw(void)" (?draw@Window@Graph_lib@@MAEXXZ) C:\Users\Admin\documents\visual studio 2013\Projects\Win32Project1\Win32Project1\Win32Project1.obj Win32Project1
Error 6 error LNK2001: unresolved external symbol "protected: virtual void __thiscall Graph_lib::Shape::draw_lines(void)const " (?draw_lines@Shape@Graph_lib@@MBEXXZ) C:\Users\Admin\documents\visual studio 2013\Projects\Win32Project1\Win32Project1\Win32Project1.obj Win32Project1
I'm really sorry that I took a screenshot of the errors but I don't know how to upload it in this forum and I don't know how to edit code on the forum as well so that it may be a little hard for you to read my errors. I'll appreciate it if anyone can teach me how to do this. And more importantly, any and all help is appreciated. I spent all my weekend google how to solve my problem but it didn't work, and I can't go on reading the book if it's not solved.