This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C2000: link v6.4.9 library with v6.2.11

Guru 20075 points

Hello,

Is it possible to link a v6.4.9 library with v6.2.11 code?

My purpose is to link a v6.4.9 libary which contains a class template with v6.2.11 code. 

Stephen

  • As a general rule, it is safest to use the newer version of the linker (in this case 6.4.9) when linking in libraries or object files built with different versions. If the linker version is older than the library, there is a chance that the library may be built with options or features that the older linker may not be able to handle.

  • For my situation (using templates in static library), I will take that as a "no, it's not possible".

    Thanks,

    Stephen 

     

  • Actually it's supported, as long as you use a version of the linker that is at least as recent as every input file, and the RTS library that exactly matches the linker version. In your case, just use linker version 6.4.9 and you should be fine.
  • Using a new compiler can break existing code.  I was wanting to use templates, which v6.4.9 has, without compiling all the code with a new compiler version.

    Thanks,
    Stephen

  • Having thought about this a bit more, I'm confused about what you are trying to do. I'm going to presume you aren't trying to use C++ STL templates, because 6.2.11 has them. I'll presume you have some third-party software which has a template class in a header file, and comes with a pre-built library compiled with 6.4.9. Typically, all of the template's functions are defined in a header file, and you should only need to include the header file to get all of those functions, and this should work fine even if you are using the 6.2.11 toolset. Perhaps it is the case that these template functions eventually call something in the pre-built library? Does this sound about right? In this scenario, you can use compiler version 6.2.11 to compile all of your code, including code that uses the template. However, at link time, you'd want to use the 6.4.9 linker because the library was built with 6.4.9. If I've made an incorrect assumption, let me know and I'll try to revise it to match your scenario.
  • According to processors.wiki.ti.com/.../C++_Support_in_TI_Compilers. Embedded C++ doesn't include templates (see below).  

    The C2000 v6.2.11 compiler only allows Embedded C++. 

    "Having thought about this a bit more, I'm confused about what you are trying to do."

    I have existing code that has been tested thoroughly with the hardware (It took many hours to do by a validation engineer).  Now, I created some classes that uses templates and I want to add them to the thoroughly tested existing code.  At first, I thought I could compile the new code into a static library using v6.4.9 and then link that library with the existing code compiled with v6.2.11.  

    According to what you previously said, that is not possible. 

    Compiling all the code a new compiler could like introduce some unintended effect or maybe bug int the existing code.

    Stephen

    Embedded C++:

    Support for Embedded C++ is in the form of the compiler option -pe. This option makes it illegal to use any C++ feature that is not in Embedded C++. Embedded C++ omits these C++ features:

    • Templates
    • Exceptions
    • Run-time type information (RTTI)
    • The new cast syntax
    • The keyword mutable
    • Multiple inheritance
    • Virtual inheritance

    Note Embedded C++ disallows templates. This means you can use very few of the features in the C++ portion of the RTS library.

  • That's not what that page means. 6.2.x supports C++98, including templates. Additionally, it provides some support for Embedded C++, but it is not required.

    Usually you can't create a "template library." Usually the templates are instantiated right in the place where they are used, so if you add (for instance) a std::vector<int> to your file, you'll get a bunch of functions created at compile time to satisfy that class.

    You have some tested functions compiled with 6.2.11. If you modify these files to use STL classes, you'll need to recompile them, but you can recompile them with 6.2.11. If you do not modify these files, you can link them with other object files that use to STL classes.
  • Ok, When I have 6.2.11 selected as the compiler, "Embedded C++" is the only c++ dialect shown in the Language options. What am I missing?  

    So, if I don't choose any C++ dialect, the compiler will compile the code using C++98?

    Stephen

  • Yes, if it detects the file is a C++ file (for instance, the extension should be .cpp)