I have 3 files to compile:
main.cc
transcoder.hpp
transcoder.cc
The g++ commands I'm running are:
g++ -c -Wall -g transcoder.cc transcoder.hpp -I. -lboost_system -pthread
g++ -c -Wall -g main.cc -I. -lboost_system -pthread
g++ -o main main.o transcoder.o -I. -lboost_system -pthread
After the last line, I get an undefined error reference error for when code in main.cc tries to call a function defined in transcoder.hpp/transcoder.cc. Does anyone know what I'm doing wrong?
Edit to add code snippets:
transcoder.hpp
#include <boost/network/protocol/http/server.hpp>
namespace transcoder {
template<class T>
class Transcoder {
public:
void HandleRequest(const typename ::boost::network::http::server<T>::request& request,
typename ::boost::network::http::server<T>::response* response);
};
} // namespace transcoder
transcoder.cc
namespace transcoder {
using boost::network::http::server;
template<class T>
void Transcoder<T>::HandleRequest(const typename server<T>::request& request,
typename server<T>::response* response) {
// random implementation
}
} // namespace transcoder
main.cc
const server<Handler>::request request;
server<Handler>::response response
::transcoder::Transcoder<Handler> transcoder;
transcoder.HandleRequest(request, &response);
Exact error message:
main.o: In function `(anonymous namespace)::Handler::operator()(boost::network::http::basic_request<boost::network::http::tags::http_server> const&, boost::network::http::basic_response<boost::network::http::tags::http_server>&)':
/some_dir/main.cc:16: undefined reference to `transcoder::Transcoder<(anonymous namespace)::Handler>::HandleRequest(boost::network::http::basic_request<boost::network::http::tags::http_server> const&, boost::network::http::basic_response<boost::network::http::tags::http_server>*)'