Author Topic: How to setup for compiling template static library?  (Read 4860 times)

proboy

  • Guest
How to setup for compiling template static library?
« on: October 19, 2008, 02:34:28 am »
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?

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: How to setup for compiling template static library?
« Reply #1 on: October 19, 2008, 04:06:10 am »
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").
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)