473,385 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Force linker to check all the implementation

In C++ , when the class is declared in the header & not implemented in
the cpp, the linker is not giving a error untill the method gets
called. How to ensure that all non pure-virtual method declared is
implemented, even when the method/member function not getting called.
Any linker checking can be performed for this purpose?

How can a template class can be splitted in header & source? And to
ensure every method is having an implementation at the compile time?
Also, can a template class be made a shared object (dll) & header
combination, so that it can be linked with a different program, without
recompiling the template class source code (or shipping the template
class source code) ?

I am using boost for some computation. As it is a huge library, with
most of the classes are template, It causes a large compile time for
the program. can it be build as shared library (static / dynamic) and
linked in my program? ...
I am using gcc 4.0.2 version at present...

abir

Jul 20 '06 #1
1 1741
toton wrote:
In C++ , when the class is declared in the header & not implemented in
the cpp, the linker is not giving a error untill the method gets
called. How to ensure that all non pure-virtual method declared is
implemented, even when the method/member function not getting called.
Any linker checking can be performed for this purpose?
As far as I know, the language doesn't give you any mechanism for that
purpose. You might could try something like forming pointers to all
your functions (or just calling them all). Beyond that it is going to
be an implementation specific issue.
How can a template class can be splitted in header & source? And to
ensure every method is having an implementation at the compile time?
Also, can a template class be made a shared object (dll) & header
combination, so that it can be linked with a different program, without
recompiling the template class source code (or shipping the template
class source code) ?
This is in the FAQ:
http://www.parashift.com/c++-faq-lit...html#faq-35.12
I am using boost for some computation. As it is a huge library, with
most of the classes are template, It causes a large compile time for
the program. can it be build as shared library (static / dynamic) and
linked in my program? ...
I am using gcc 4.0.2 version at present...
Much of Boost can (and is) compiled to libraries. The templates,
however, cannot, because that doesn't make any sense. As much as you
might like them to be, a class template and a class are not the same
thing. Think of templates as code generators. You give them some
parameters, and they generate some code for you. Before those
parameters are known, there is no code to compile.

--
Alan Johnson
Jul 20 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ingo Nolden | last post by:
When I build a static lib how can I force the linker to include other lib modules or at least the symbols that are used in my libs? -- ~ Samba, more than a low cost File and Printer server ~ --...
4
by: Sam Smith | last post by:
Hi, I'm thinking about whether or not to build a general library on its own and later link that lib with the main executable, or to build the main executable with a subset of the relevant source...
12
by: Baloff | last post by:
Hello I have this linker error which makes me think that the definition file is not being seen by the linker, this code is taken from "Thinking in C++, 2nd Edition, Volume 1, Annotated Solutions...
0
by: Tom McDermott | last post by:
I am having linker errors : error LNK2022: metadata operation failed (80131188) : Inconsistent field declarations in duplicated types This code linked sucessfully in C++.NET 2002, but does...
3
by: Bob Altman | last post by:
Hi all, This is the first time I've tried to create a templatized function, and I can't get past a linker error. I create a new, unmanaged C++ application and added a class named MyClass. In...
3
by: little.freaky | last post by:
Hello group, I have a problem with template classes and inheritance. I've searched on the internet to find a solution but all the examples look the same as my code (as far as I can tell) and I...
6
by: bryanbabula | last post by:
I have a question about overriding i was wondering if anyone could help me with, or even suggesting a better/different way. I have no idea if this can even be done or not. I was wondering if there...
2
by: Markus Dehmann | last post by:
What to do if an external library is header-files-only (but you have to use it), and you get lots of linker errors? You will necessarily get linker errors "multiple definition of ..." if you try...
2
by: rjddude1 | last post by:
I created a rational class, created member functions to add, subtract, multiply and divide. The reduction function however doesn't work. And the Dev cpp compiler gives a linker error. I have attached...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.