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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:51:22+00:00 2026-06-12T07:51:22+00:00

I have this simple test file: #include stack.h int main() { Stack* stck =

  • 0

I have this simple test file:

#include "stack.h"

int main()
{
  Stack* stck = init_stack();

  return 0;
}

and stack.h is defined as follows:

#ifndef STACK_H
#define STACK_H

#define EMPTY_STACK -1
typedef struct stack
{
  char ch;
  struct stack* prev;
} Stack;

extern Stack* init_stack();

extern char pop(Stack*);

extern void push(Stack*, char);

#endif

These two files are in the same directory. But when I do gcc .. to build it, I keep getting the error below:

$ ls
stack.c  stack.h  teststack.c
$ gcc -o testit teststack.c 
/tmp/ccdUD3B7.o: In function `main':
teststack.c:(.text+0xe): undefined reference to `init_stack'
collect2: ld returned 1 exit status

Could anyone tell me what I did wrong here?

Thanks,

  • 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-12T07:51:23+00:00Added an answer on June 12, 2026 at 7:51 am
     gcc -o testit teststack.c stack.c
    

    You need to compile both C source files and link the object files; this does it all in one command.

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

Sidebar

Related Questions

In Ubuntu 11.10 x86_64 I have this this simple test.c file: #include <openssl/ssl.h> int
I have a simple test file, TestMe.cpp: #include <gtest/gtest.h> TEST(MyTest, SomeTest) { EXPECT_EQ(1, 1);
I have these (sample) lines in a HTML-file: test.ABC.test test.ABCD.test test.ABCE.test And this Ant
I have this simple test project just to test the IncludeExceptionDetailInFaults behavior. public class
We have a ubuntu test server that this simple script works fine on where
This is a simple script I have written to test command line argument handling:
I have this simple piece of code : int a = 1, b =
this is a simple html file: <!DOCTYPE html> <html> <head> <title>Test Uploading Func.</title> <script
I have simple page, like: ... <div><?php include 'somefile.php' ?></div> ... 'somefile.php'-file contains <p>Lorium
Take the following simple source (name it test.cpp): #include <windows.h> void main() { DebugBreak();

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.