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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:09:02+00:00 2026-06-08T21:09:02+00:00

display.h #ifndef PRO_DISPLAY_H #define PRO_DISPLAY_H /** Initializes the display **/ int pro_display_init(void); #endif /*

  • 0

display.h

#ifndef PRO_DISPLAY_H
#define PRO_DISPLAY_H

/** Initializes the display **/
int pro_display_init(void);

#endif /* PRO_DISPLAY_H */

display.c

#include "main.h"

static int height_ = 300;
static int width_ = 300;
static int bpp_ = 16;

static SDL_Surface* screen_ = NULL;

int pro_display_init(void)
{
    screen_ = SDL_SetVideoMode(width_, height_, bpp_, SDL_HWSURFACE|SDL_DOUBLEBUF);
    if (!screen_)
    {
        pro_sdl_error("Video initialization failed.");
        return 0;
    }

    return 1;
}

main.h

#ifndef PRO_MAIN_H
#define PRO_MAIN_H

// standard headers
#include <stdlib.h>
#include <stdlib.h>

// conditional headers
#if defined(WIN32) || defined(_WIN32)
#include <windows.h>
#endif

// our own headers
#include "scripter.h"
#include "ttf_util.h"
#include "events.h"
#include "display.h"

// some macros
#define pro_error(...) fprintf(stderr, __VA_ARGS__)
#define pro_sdl_error(x) fprintf(stderr, "%s. \n=> %s\n", x, SDL_GetError())
#define pro_ttf_error(x) fprintf(stderr, "%s. \n=> %s\n", x, TTF_GetError())

#endif /* PRO_MAIN_H */

** main.c**

#include "main.h"

int main(int argc, char* argv[])
{
    pro_display_init();
    return 0;
}

The Error:

main.c|5|undefined reference to `pro_display_init()'|

Checked the build process. Made sure I was adding “display.c” to gcc’s input files. I’m at my wit’s end. Why the error?

  • 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-08T21:09:04+00:00Added an answer on June 8, 2026 at 9:09 pm

    display.c and main.c are compiled into their own “translation unit”. What happens is that when trying to resolve symbols name (i.e. looking for pro_display_init), the C compiler thinks it’s compiling a standalone .c unit. The proper way to go is to compile them separately and then link them, e.g.

    gcc -c display.c # creates display.o
    gcc main.c display.o # compiles main.o and then link with display.o
    

    Of course, you’ll be creating/reusing a Makefile soon that lets you define rules for all this.

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

Sidebar

Related Questions

What is your opinion about my code ? #ifndef PROTOTYPE_H #define PROTOTYPE_H #include <map>
treecombobox.h #ifndef TREECOMBOBOX_H #define TREECOMBOBOX_H #include <QComboBox> #include QAbstractItemView #include QTreeView class TreeComboBox :
I have the following seemingly innocuous piece of code: #ifndef UI_H #define UI_H #include
###MyClass.h### #ifndef _MyClass #define _MyClass #include <string> using namespace std; class MyClass { public:
I display set of images(small). I need to show the larger image(300*300) at some
Why can't I get anything to display with this code? #include <iostream> #include GL/glfw.h
void display() { list *newlist; newlist = first; cout << endl; do { if
Here is the prototype of my class Rational #ifndef RATIONAL_H #define RATIONAL_H //forward declaration
Display whitespace characters in Eclipse is a simple trick , but unfortunately this applies
Error display as Incorrect syntax near '@Cmp_DocPath', if i use comment Line code I

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.