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 8483017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:58:19+00:00 2026-06-10T19:58:19+00:00

When building for a device (ipad 3) my build works find with no warnings

  • 0

When building for a device (ipad 3) my build works find with no warnings or errors, but when building for the iPad or iPhone simulator I receive linker errors like the following:

duplicate symbol _CONSTANT_NAME in:
/Users/me/libLibrary.a(FileName.o)
/Users/me/libOtherLibrary.a(OtherFileName.o)

The constants are defined like so in header files

const int CONSTANT_NAME = 123;

I have tried wrapping the constant’s in #define tag’s like so:

#ifndef CONSTANTS_H
#define CONSTANTS_H

const int CONSTANT_NAME = 123;

#endif

why does this work fine when building for device but cause issues when building for simulator?

  • 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-10T19:58:21+00:00Added an answer on June 10, 2026 at 7:58 pm

    The compiler is telling you exactly the correct thing. You are lucky that it’s not happening when building to your iPad directly.

    In every .m file where you include this header, you create a new and distinct variable with the same name. The compiler can resolve this when linking all these files into a single .a, but when multiple .a files are built and those multiple .a files are linked together, the compiler compiles about duplicate copies.

    I would do one of three things:

    1. Turn the const int into a #define. #define CONSTANT_NAME 123
    2. Add static before const int. static const int CONSTANT_NAME = 123;
    3. Add extern before const int and add the real const int to a single .m. In .h, extern const int CONSTANT_NAME;. In the single .m, const int CONSTANT_NAME = 123;.

    For the last one, I would create a constants.m file as a separate place to hold the const int CONSTANT_NAME = 123; definition.

    Hope that helps.

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

Sidebar

Related Questions

My app was building and running fine on the simulator and device, but I
I'm building a small controller device that I'd like to partner with a computer.
I am building an app for iPhone and iPad using PhoneGap and jQM <div
I'm trying to setup a library for simulator or device building and everywhere I
Regardless of build configuration, building my iPad app does not actually output a .app
Yesterday it was working and showing me option for building on Device , iphone
I was wondering if anyone knows a way to prevent building unneeded device drivers
I'm building an app for iPhone/iTouch that I also want to run on iPads
I'm getting the following warning when building an ad hoc distribution copy of a
I am building a universal app that uses a UISplitViewController for the iPad, and

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.