News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

How to setup for compiling template static library?

Started by proboy, October 19, 2008, 02:34:28 AM

Previous topic - Next topic

proboy

This is a really newbie question but I couldn't find it answered anywhere.  I'm new to all of this programming stuff and I'm trying to switch away from Dev C++.

I want to compile a static library consisting of a template class.  To maintain separate compilation, in DevC I would have a header file and a *.template file.  The header file would have an #include directive at the bottom to include the template file.

How do I do this in CodeBlocks?  What file extension should I be using for my implementation file?  I thought that instead of separate compilation, I could just put everything in the header file.  But when I do that I get

"Linking stage skipped (build target has no object files to link)
Nothing to be done."

Can anybody direct me as to how to setup my CodeBlocks project to accomplish what I'm trying to do?

TDragon

What you describe from Dev-C++ sounds like a non-standard extension of some sort; or at the very least a non-standard usage scenario. For a template class, you typically define the class fully in the header. However, you can also use explicit instantiation and specialization in a source file (Code::Blocks expects ".cpp").
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)