Compiling C++ Code in Tizen Native Project

Original Created Mar 30, 2017 | Regeneration Apr 22, 2026

I'm trying to compile C++ code in a Tizen Native project. Specifically, I want to add and compile a library written in C++. While Tizen's main native language has been ANSI C since 2015, I need to incorporate C++ code.

I attempted to add a class to a Native project, but the Tizen environment doesn't parse it correctly. Is there any way to configure a Tizen Native project to accept C++ code in Tizen IDE? Note that I don't intend to use C++ for creating UI or specific Tizen features.

Problem Understanding

The user wants to integrate C++ code into a Tizen Native project, which primarily supports ANSI C. The main challenge is configuring the project to properly compile C++ code.

Solution Methods

  1. Basic Configuration:

    • Start with a BasicUI project and change the source file extension from .c to .cpp
    • Go to Project Properties → C/C++ Build → Settings → C++ Compiler → Dialect → Language Selection and choose C++11
    • In Tizen Settings → Toolchain Info, select GCC 4.9
  2. Adding C++ Classes:

    • Add class header and source files in the project's inc folder
    • Include the header in your main project source file (located in src folder)
    • Create and use objects of your class
  3. Troubleshooting Compilation Errors:

    • If you encounter errors like "expected '=', ',', ';', 'asm' or 'attribute' before ':' token", ensure:
      • Your file extensions are correct (.cpp for source, .h for headers)
      • The compiler is properly configured for C++11
      • All necessary include paths are set

Code Examples

Here's a simple C++ class example that should work when properly configured:

// line.h
class Line {
public:
    void setLength(double len);
    double getLength();
    Line();
private:
    double length;
};
// line.cpp
#include "line.h"

Line::Line() : length(0) {}

void Line::setLength(double len) {
    length = len;
}

double Line::getLength() {
    return length;
}

Additional Tips

  • When porting external C++ libraries, pay attention to:
    • Library paths
    • Proper linking of dependencies
    • Any platform-specific requirements
  • Consider using extern "C" wrappers if you need to interface between C and C++ code
  • For more complex scenarios, refer to the official documentation on integrating external libraries

Customize your cookie preferences

You can enable or disable non-essential cookies. Essential cookies are always on to ensure the site works properly and to keep you signed in.

Necessary

These cookies are necessary for the website to function properly and cannot be switched off. They help with things like logging in and setting your privacy preferences.

Always on

Analytics

These cookies help us improve the site by tracking which pages are most popular and how visitors move around the site.

Enable analytics cookies
Public Forum Public Forum
Employees only. Please sign in with your company account.