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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:52:42+00:00 2026-05-13T06:52:42+00:00

I’ve try to compile this code: #include <iostream> #include <cstdlib> using namespace std; #define

  • 0

I’ve try to compile this code:

#include <iostream>
#include <cstdlib>

using namespace std;

#define ARRAY_TAM 2

typedef int (*operacion)(int, int);
typedef const char* (*Pfchar)();

int suma(int, int);
int resta(int, int);

const char* descrSuma();
const char* descrResta();
const char* simbSuma();
const char* simbResta();

class OP
{
    private:

    public:
        operacion op;
        Pfchar descr;
        Pfchar simb;

};

int main (int argv, char *argc[])
{
    OP ArrayOP[ARRAY_TAM];

    ArrayOP[0].op = suma;
    ArrayOP[0].descr = descrSuma;
    ArrayOP[1].op = resta;
    ArrayOP[1].descr = descrResta;

    int op1, op2;
    unsigned int i;
    char opcion;
    bool fin = false;

    while (fin != true)
    {
        cout << "CALCULADORA" << "\n";
        cout << "===========" << "\n";

        for (i = 0; (i < ARRAY_TAM); i++)
        {
            cout << i+1;
            cout << ".- ";
            cout << ArrayOP[i].descr() << "\n";
        }

        cout << i+1 << ".- " << "Salir" << endl;

        cout << "Opcion: ";

        cin >> opcion;
        opcion = atoi(&opcion);
        opcion--;
        cout << (int)opcion << endl;

        if ((opcion >= 0) && (opcion < ARRAY_TAM))
        {
            cout << "Operando 1: ";
            cin >> op1;
            cout << "Operando 2: ";
            cin >> op2;
            cout << "Resultado: op1 " << ArrayOP[opcion].simb()
                         << " op2 = " << ArrayOP[opcion].op(op1, op2);
        }   
        else if (opcion == ARRAY_TAM)
        {
            fin = true;
        }

    }

    return 0;

}


int suma (int op1, int op2)
{return op1 + op2;}

int resta (int op1, int op2)
{return op1 - op2;}

const char* descrSuma()    
{return "Suma";}

const char* descrResta() 
{return "Resta";}

const char* simbSuma()
{return "+";}

const char* simbResta()
{return "-";}

An it works, but I have a lot of problems linking with gcc with debbugging symbols and it doesn’t link 🙁

Need Help!

Large linker error:

facon@facon-laptop:~/Windows – Mis
documentos/Prog/C/Ejercicios/pedirentero$
g++ -o main main.o main.o: In function
`_start’:

/build/buildd/eglibc-2.10.1/csu/../sysdeps/i386/elf/start.S:65:
multiple definition of `_start’

/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crt1.o:/build/buildd/eglibc-2.10.1/csu/../sysdeps/i386/elf/start.S:65:

first defined here
main.o:(.rodata+0x0): multiple
definition of `_fp_hw’

/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crt1.o:(.rodata+0x0):
first defined here main.o: In function
_fini': (.fini+0x0): multiple
definition of
_fini’

/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crti.o:(.fini+0x0):
first defined here
main.o:(.rodata+0x4): multiple
definition of `_IO_stdin_used’

/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crt1.o:(.rodata.cst4+0x0):
first defined here main.o: In function
__data_start': (.data+0x0): multiple
definition of
__data_start’

/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crt1.o:(.data+0x0):
first defined here main.o: In function
__data_start': (.data+0x4): multiple
definition of
__dso_handle’

/usr/lib/gcc/i486-linux-gnu/4.4.1/crtbegin.o:(.data+0x0):
first defined here main.o: In function
_init': (.init+0x0): multiple
definition of
_init’

/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crti.o:(.init+0x0):
first defined here

/usr/lib/gcc/i486-linux-gnu/4.4.1/crtend.o:(.dtors+0x0):
multiple definition of `DTOR_END‘
main.o:(.dtors+0x4): first defined here

/usr/bin/ld: warning: Cannot
create .eh_frame_hdr section,
–eh-frame-hdr ignored. /usr/bin/ld: error in main.o(.eh_frame); no
.eh_frame_hdr table will be created.

collect2: ld returned 1 exit status

PD: Edited.

  • 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-05-13T06:52:42+00:00Added an answer on May 13, 2026 at 6:52 am

    You write “… it works”, but then you write “… problems with linking”.

    I am little bit confused with this question, because:

    • If there are problems with linking then it doesn’t work …
    • But if it works, then you don’t have problems with linking…

    So I guess that you mean: “it compiles, but there are linking errors” ?

    If that’s the case, then you could try

    g++ -g main.cpp -o main
    

    instead of

    gcc -g main.cpp -o main
    

    EDIT: … and do not mention main.o on the command line =;)

    EDIT: if that all doesn’t help – maybe there is something wrong with your g++/gcc installation?

    on ubuntu please try

    sudo aptitude install build-essential
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 302k
  • Answers 302k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer OK, so I found out. The answer is yes, it… May 13, 2026 at 8:18 pm
  • Editorial Team
    Editorial Team added an answer You may want to check out JDepend. It was specifically… May 13, 2026 at 8:18 pm
  • Editorial Team
    Editorial Team added an answer SELECT CL.*, U.* --change this as needed FROM ( SELECT… May 13, 2026 at 8:18 pm

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.