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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:20:25+00:00 2026-06-01T14:20:25+00:00

I wrote a program on Ubuntu 11.04 that uses freeglut. It worked fine. Then

  • 0

I wrote a program on Ubuntu 11.04 that uses freeglut. It worked fine. Then I got another computer and tried to run the program on a fresh install of Ubuntu 11.04. Doesn’t work. So I installed

sudo apt-get install freeglut3 freeglut3-dev libglew1.5 libglew1.5-dev libglu1-mesa libglu1-mesa-dev libgl1-mesa-glx libgl1-mesa-dev mesa-common-dev gcc

and tried to run the program, which imports



    #include <GL/freeglut.h>
    #include <GL/gl.h>
    #include <GL/glu.h>

using the command

g++ -lGL -lGLU -lglut Driver.cpp -o a

However the linker or whatever spits out like 200 errors of the form:



    Driver.cpp:(.text+0x3c6b): undefined reference to `glutSolidSphere'
    Driver.cpp:(.text+0x3c75): undefined reference to `glEnable'
    Driver.cpp:(.text+0x3c9a): undefined reference to `glColor4f'
    Driver.cpp:(.text+0x3cb5): undefined reference to `glRotatef'
    Driver.cpp:(.text+0x3d02): undefined reference to `glutSolidSphere'
    Driver.cpp:(.text+0x3d07): undefined reference to `glutSwapBuffers'

What is the cause of the 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-06-01T14:20:26+00:00Added an answer on June 1, 2026 at 2:20 pm

    The order in which you specify the objects you want to link to (including static and dynamic libraries) can matter.

    Try with:

    g++ Driver.cpp -lGL -lGLU -lglut  -o a
    

    (Not sure about the order of the libs, but that looks ok.)

    The idea when you build your command line is that if a requires a symbol from b, b must appear after a in the command line.

    The link order problem happens (or not) with GCC/ld for shared libraries depending on (most likely among other things – I’m no expert here) whether the --as-needed link flag is set or not. (See for instance the before-last item in Gentoo’s as-needed transition guide.)
    The linking process eliminates un-needed symbols ASAP when --as-needed is active, which causes problems if the link order is not “correct”. This is done to reduce the number of un-necessary dependencies present in final executables.
    This doesn’t happen (or less so) if --as-needed is not active – all symbols are kept in that case, and link order doesn’t matter as much (more or less – again, I’m no expert.)

    Since different distributions use different defaults for that flag, the behavior of GCC might seem inconsistent, but that’s just an impression.

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

Sidebar

Related Questions

I wrote a program in C with Ubuntu Linux and now I need to
I wrote a program which includes writing and reading from database. When I run
I wrote a program that forks some processes with fork(). I want to kill
I wrote a program that accepts and outputs Hebrew (i.e. right-to-left) text. In lieu
I got a C++ program (source) that is said to work in parallel. However,
I'm writing a program that uses File I/O to traverse through a directory given
I wrote a program that employs multithreading for parallel computing. I have verified that
I just realised that this program compiles and runs (gcc version 4.4.5 / Ubuntu):
i wrote program to connect oracle database 11g for my android application to store
I wrote a program using AutoIT to fetch information from a number of websites

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.