Menu

Compiling with CXX

2003-03-28
2012-09-15
  • Simon Wood Jr

    Simon Wood Jr - 2003-03-28

    Has anyone tried compiling with cxx instead of g++? I get the following error types:

    cxx: Error: overloaded function "Mat<T>::Mat" is not a template.

    The error is in reference to line 425 of mat.h.

    Any suggestions?

     
    • Simon Wood Jr

      Simon Wood Jr - 2003-04-05

      I have successfully compiled, linked and tested (some functionality) of IT++ on a Tru64 system using the native Compaq C++ compiler (cxx). In most situations cxx is suppose to yield better performing code than g++ for Alpha processors.

      I will be happy to post the steps required if anyone is interested. There are basically 2 categories of things to fix.

      Compilation issues: The Compaq compiler cxx is not as forgiving as g++ on a few nit picky items. These were not too bad to sort through.

      Linking issues: This was the tough one. cxx uses a repository technique for template instantiation. The compiler/linker combination expects the files (*.h and *.cpp) to be done is a specific way. Basically the cxx compiler insists on having "inline" templates defined in the .h header file. Not complying with this structure yields no warnings or errors during compilation. However, the resulting library does not contain the instantiated inline templates (this took FOREVER to find). The fix here is simply to move all of the "template" functions and methods from the *.cpp file to the *.h file. You can then remove the explicit instantiations.

      It looks like both cxx and g++ are happy with having the templates defined in the .h files. Also, I believe this is the recommended technique for templates. Although, admittedly I too use to ignore this for the sake of wanting "implementation" not in .h files but in .cpp files. The cxx compiler is the first I've come across that basically paints you into a corner and forces the templated definitions to be inserted into the .h file.

      -Simon

       

Log in to post a comment.