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

  • Home
  • SEARCH
  • 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 8883301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:46:52+00:00 2026-06-14T20:46:52+00:00

I wrote a class named UserScore: //header using namespace std; class UserScore{ public: UserScore(const

  • 0

I wrote a class named UserScore:

//header
using namespace std;
class UserScore{
public:
    UserScore(const int &user_id, const int &rating);

private:
    int _user_id;
    int _rating;
};


//cpp
#include "UserScore.h"
UserScore::UserScore (const int &user_id, const int &rating):
    _user_id(user_id),
    _rating(rating)
{

}

The compile command is:

g++ src/UserScore.cpp -o obj/UserScore.o

But why this simple thing won’t compile?

The error is:

Undefined symbols for architecture x86_64:
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
  • 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-14T20:46:53+00:00Added an answer on June 14, 2026 at 8:46 pm

    You need to include the -c option to the compilation line if you want to generate an object file, otherwise the compiler assumes you are trying to build an executable and will complain if you don’t have a main() method (which is happening here).

    To make an object file which you will link later to a code file that has a “main()” method in it you need to use

    g++ -c src/UserScore.cpp -o obj/UserScore.o

    Which is what I think you are trying to do.

    Alternatively you just need to add a main function to your code and then you can make an executable.

    //header
    using namespace std;
    class UserScore{
    public:
        UserScore(const int &user_id, const int &rating);
    
    private:
        int _user_id;
        int _rating;
    };
    
    
    //cpp
    #include "UserScore.h"
    UserScore::UserScore (const int &user_id, const int &rating):
    _user_id(user_id),
    _rating(rating)
    {
    
    }
    
    int main()
    {
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, so i have this code i wrote: class Connection { public static StreamWriter
I have wrote some class, named as Employe. Employees collection I set as source
First, I wrote a class which wraps a Windows API Event (using Wait to
I have a class named InvoiceLine which has the following properties. public class InvoiceLine
I wrote a class named Easter (see below) and a tester class named EasterTester
Some background: I wrote a UIScrollView derived class with an outlet named contentView, similar
I wrote some code in wich it has a class named Cars as below:
i wrote a class named octed_string , without a destructor it works well but
I'm trying to write a named scope that will order my 'Products' class based
Here is a related manager I wrote: class PortfolioItemManager(models.Manager): use_for_related_fields = True def extended(self):

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.