Article View: borland.public.cppbuilder.oodesign
Article #58Re: Weird problem with linker
From: Andrue Cope [TeamB]
Date: Fri, 06 May 2005 10:55
Date: Fri, 06 May 2005 10:55
45 lines
2711 bytes
2711 bytes
Francisco M. Marzoa wrote: Forgive me if I'm misinterpreted your post but it seems to me that you're misunderstanding a basic principal of C/C++ development. I apologise profusely if this is the case. > Now, Tags is an instance of TTagList, defined on TagList.cpp. In the > includes of ReadAll.cpp I've put: > > #include "TagList.h" > > But this does not make the matter, as It compiles fine, but it does > not link later. Why do you think there is a relationship between #include and linker errors? It is possible for header files (and indeed any source code) to specify files to be linked but this is unusual and not particularly standard. All that a header usually does is tell the compiler what the function will look like. It's up to you to either provide the source for the function or an OBJ or LIB file containing the compiled code for that function. > Method GetCount for TTagList is declared as: > > protected: > int GetCount (void); Again, this is just a function declaration. What the linker is complaining about is that it can't find the function itself. You mention 'TagList.Cpp' - I would assume this contains the code for TTagList. Have you added this file to the project? If not then that will be the cause of the problem. In 'C/C++' all #include does is tell the compiler to start reading from a different file. There is no explicit relationship between 'taglist.h' and 'taglist.cpp'. It's only common sense, convention and modern IDEs that lead programmers to name them that way. If 'taglist.cpp' isn't in your project then it might as well not exist as far as the compiler/linker are concerned. -- Andrue Cope [TeamB] [Bicester, Uk] http://info.borland.com/newsgroups/guide.html
Technical Details
Message-ID:
<427b4d14$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!fr.ip.ndsoftware.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<427b351e$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10db1e,44e310bfdda1fa37 X-Google-Attributes: gid10db1e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Andrue Cope [TeamB]" <no.spam@not.a.valid.address> Subject: Re: Weird problem with linker Newsgroups: borland.public.cppbuilder.oodesign References: <427b351e$1@newsgroups.borland.com> User-Agent: XanaNews/1.17.4.1 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 NNTP-Posting-Host: 217.207.223.34 Message-ID: <427b4d14$1@newsgroups.borland.com> Date: 6 May 2005 03:55:16 -0700 X-Trace: newsgroups.borland.com 1115376916 217.207.223.34 (6 May 2005 03:55:16 -0700) Lines: 45 X-Authenticated-User: acope Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!fr.ip.ndsoftware.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail