linking two files

Posted on 2008-11-07
Last Modified: 2012-05-05
how do I compile the program, say I have a file called test.c, which has:

extern void print_int(int x);
extern void print_str(char x[]);

and the definition of both function is located at a file called print.c

I tried gcc -ansi -Wall test.c testing

but it doesn't work
Question by:kuntilanak
    LVL 86

    Expert Comment

    You should use

    gcc -ansi -Wall test.c print.c -o test

    to specify both files when compiling.

    Author Comment

    ok, what if I want to run test?
    LVL 86

    Accepted Solution

    On the command line, type


    That should do it.

    Author Comment

    gotcha.. thanks!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Suggested Solutions

    Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode ( They will have you believe that Unicode requires you to use…
    This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now