undefined reference to `void sort::swap<int>(int*, int, int)' [duplicate]-Collection of common programming errors

Possible Duplicate:
Why can templates only be implemented in the header file?

Here’s my make file:


#!/usr/bin/make -f
compiler = g++
compiler_flags = -Wall -I /usr/include/c++/4.5
debug_flags = -D DEBUG -g
binary_filename = sort_testing.bin

all: clean release

release: 
    $(compiler) $(compiler_flags) main.cpp sort.o -o $(binary_filename)
debug: sort.o 
    $(compiler) $(debug_flags) $(compiler_flags) main.cpp sort.o -o $(binary_filename)
run: 
    ./$(binary_filename)
clean: 
    rm -f *.o $(binary_filename)
sort.o: 
    $(compiler) $(debug_flags) $(compiler_flags) -c sort.cpp

Here are my C++ Files:


// sort.hpp
#ifndef SORT_H
#define SORT_H

namespace sort{
    template void swap(T*,int,int);
}

#endif

// sort.cpp
#include "sort.hpp"

namespace sort{
    template
    void swap(T* items, int index_a, int index_b){
        T t = items[index_a];
        items[index_a] = items[index_b];
        items[index_b] = t;
    }
}

// main.cpp
#include 
#include 
#include 
#include 
#include 
using namespace std;

#include "sort.hpp"
using namespace sort;

#define NUM_INTS 5

int main(int argc, char** argv){
    try{
        cout

Originally posted 2013-11-27 11:52:18.