Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8354869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:41:22+00:00 2026-06-09T09:41:22+00:00

I am using the arm-linux-androideabi-g++ compiler. When I try to compile a simple Hello,

  • 0

I am using the arm-linux-androideabi-g++ compiler. When I try to compile a simple “Hello, World!” program it compiles fine. When I test it by adding a simple exception handling in that code it works too (after adding -fexceptions .. I guess it is disabled by default).

This is for an Android device, and I only want to use CMake, not ndk-build.

For example – first.cpp

#include <iostream>

using namespace std;

int main()
{
   try
   {
   }
   catch (...)
   {
   }
   return 0;
}

./arm-linux-androideadi-g++ -o first-test first.cpp -fexceptions

It works with no problem…

The problem … I am trying to compile the file with a CMake file.

I want to add the -fexceptions as a flag. I tried with

set (CMAKE_EXE_LINKER_FLAGS -fexceptions ) or set (CMAKE_EXE_LINKER_FLAGS "fexceptions" )

and

set ( CMAKE_C_FLAGS "fexceptions")

It still displays an error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:41:25+00:00Added an answer on June 9, 2026 at 9:41 am

    Please be aware that due to the evolution of CMake since the writing of this answer in 2012, the majority of the recommendations provided here are now obsolete or no longer recommended, with improved alternatives available.


    Suppose you want to add those flags (better to declare them in a constant):

    SET(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
    SET(GCC_COVERAGE_LINK_FLAGS    "-lgcov")
    

    There are several ways to add them:

    1. The easiest one (not clean, but easy and convenient, and works only for compiler flags, C & C++ at once):

      add_definitions(${GCC_COVERAGE_COMPILE_FLAGS})
      
    2. Appending to corresponding CMake variables:

      SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
      SET(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
      
    3. Using target properties, cf. doc CMake compile flag target property and need to know the target name.

      get_target_property(TEMP ${THE_TARGET} COMPILE_FLAGS)
      if(TEMP STREQUAL "TEMP-NOTFOUND")
          SET(TEMP "") # Set to empty string
      else()
          SET(TEMP "${TEMP} ") # A space to cleanly separate from existing content
      endif()
      # Append our values
      SET(TEMP "${TEMP}${GCC_COVERAGE_COMPILE_FLAGS}" )
      set_target_properties(${THE_TARGET} PROPERTIES COMPILE_FLAGS ${TEMP} )
      

    Right now I use method 2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to compile a simple program using arm-linux-androideabi-g++. I am including this
I'm trying to compile my first linux ARM hello world program and when I
I would like to cross-compile a simple program for ARM architecture using the arm-linux-gcc
I want to build a static hello world from C using arm-linux-gnueabi-gcc as opposed
I have arm-linux-androideabi-gcc installed in my computer, but when I try to compiler even
We're working on a C program compiled with arm-eabi-gcc under Linux. We're using a
I'm writing a Linux program that currently compiles and works fine on x86 and
I am trying to configure util-linux to cross compile using arm-none-linux-gnueabi from CodeSourcery. My
I have an application which i build using gcc on linux host for ARM
I'm trying to program ARM using Eclipse + CDT + yagarto (gnu toolchain) +

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.