Author Topic: How can I link a lib from “The Art and Science of C”  (Read 5084 times)

Fibonacci

  • Guest
How can I link a lib from “The Art and Science of C”
« on: November 22, 2010, 04:40:15 pm »
I am using “The Art and Science of C” to learn C.If you want to write a program,you need to use his lib.I download it but i don't konw how to link it..

Here is my settings:
1.create a new project and select all .h & .c files from "standard" folder
2.build it ---- successful
3.open an example c source file(add2.c)
Code
#include <stdio.h>
#include "genlib.h"
#include "simpio.h"

main()
{
    int n1, n2, total;

    printf("This program adds two numbers.\n");
    printf("1st number? ");
    n1 = GetInteger();
    printf("2nd number? ");
    n2 = GetInteger();
    total = n1 + n2;
    printf("The total is %d.\n", total);
}
4.bulid it,then it has an messages.

Code
\programs\03-Problem-Solving\add10.c|11|error: genlib.h: No such file or directory|
\programs\03-Problem-Solving\add10.c|12|error: simpio.h: No such file or directory|
||=== Build finished: 2 errors, 0 warnings ===|

5.What can i do if i want to link this lib?I search the internet and view all the topics that related to this topic,but i still don't know how to link it..orz.

PS:Settings--Global xxx---Linker Settings--add the .a files . it can't work.

6.
Code::Blocks version:10.05
Complier:GCC
OS:Windows XP SP3

You can download this source from http://www.rayfile.com/files/fb21770c-f64b-11df-90bb-0015c55db73d/

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7592
    • My Best Post
Re: How can I link a lib from “The Art and Science of C”
« Reply #1 on: November 22, 2010, 05:36:03 pm »
This IS NOT a site that teaches basic programming.

Learn the difference between Compiler and Linker Errors!

An .h file is NOT a library; it is an header!

You are having an Compiler Error when you get a message about not finding an .h file.

Add, the path to the not found header(s) to the Compiler Search Path under the Project "Build Options"

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org