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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:09:41+00:00 2026-05-16T15:09:41+00:00

I think I have a problem with my makefile. I’m writing this program: Q2.cpp

  • 0

I think I have a problem with my makefile. I’m writing this program:

  • Q2.cpp contains the main.
  • Agent.cpp Agent.h
  • Timing.cpp Timing.h
  • RandomDouble.cpp RandomDouble.cpp

And I’m using the header randoma.h in RandomDouble.cpp.
I downloaded the randomaelf64.a file and I wrote this makefile:

 Q2 : Q2.o Agent.o Timing.o RandomDouble.o
     g++ -Wall -g randomaelf64.a RandomDouble.o Q2.o Agent.o Timing.o -o Q2

 Q2.o : Q2.cpp Agent.h Timing.h
     g++ -Wall -g -c Q2.cpp -o Q2.o

 Agent.o : Agent.cpp Agent.h Timing.h RandomDouble.h PrintQ2.h
     g++ -Wall -g -c Agent.cpp -o Agent.o

 RandomDouble.o : RandomDouble.cpp RandomDouble.h  randoma.h
     g++ -Wall -g -c RandomDouble.cpp -o RandomDouble.o

 Timing.o : Timing.cpp Timing.h Agent.h
     g++ -Wall -g -c Timing.cpp -o Timing.o

 clear :
     rm *.o Q2

Except for the first command, each g++.. command is working when I do it separately.
Even when I add a main() to RandomDouble.cpp and run:

g++ -Wall -g randomael64.a RandomDouble.cpp -o rand

it’s working. So I think that maybe the problem is with my makefile.

When I run make I get this error:

RandomDouble.o: In function `InitSeed()':
/cs/stud/ofrenk33/CPP/ex1/RandomDouble.cpp:11: undefined reference to `MersenneRandomInit'
RandomDouble.o: In function `InitSeed(int)':
/cs/stud/ofrenk33/CPP/ex1/RandomDouble.cpp:16: undefined reference to `MersenneRandomInit'
RandomDouble.o: In function `GetRandomDouble()':
/cs/stud/ofrenk33/CPP/ex1/RandomDouble.cpp:21: undefined reference to `MersenneRandom'
Agent.o: In function `Agent::SendMessage()':
/cs/stud/ofrenk33/CPP/ex1/Agent.cpp:31: undefined reference to
...
make: *** [Q2] Error 1

I need to say that there are functions declared in randoma.h which are in the randomaelf64.a library.

How do I fix this problem?

  • 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-16T15:09:42+00:00Added an answer on May 16, 2026 at 3:09 pm

    You need to link against the library after all your own object files. The linker will only include as much of the library as it needs, and if there are no unresolved references yet, then none of the library will be needed. Change the first rule to:

    Q2 : Q2.o Agent.o Timing.o RandomDouble.o 
        g++ -Wall -g RandomDouble.o Q2.o Agent.o Timing.o randomaelf64.a -o Q2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think I have a problem in understanding the proper way of using MVC.
I am trying to solve this problem http://www.spoj.pl/problems/PEBBMOV/ . I think I have the
I think I have a problem with casting. $db = mysqli_connect('127.0.0.1','root','password','test'); if (! $db)
I think I have a big problem. I have a two projects solution. First
I think I have a synchronization problem...It may be too basic..Please help.. I have
I think i have a basic problem in understanding the dojo toolkit. Well I
I have a problem with a template and pointers ( I think ). Below
I have a problem which makes me crazy. I think it is very easy
i have a problem that i can't solve ! (sqlite3, but i think it
Hi I have a problem in sending data from php to pdf. I think

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.