How to include my own library in Codeblocks

Hello,

I'm a beginner in C++ and Codeblocks (using Windows) trying to include my own library in a cpp.File. I googled a bit and tried out the following:

1) I create a new project of the Type "static library" and keep the default code:



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  // The functions contained in this file are pretty dummy
// and are included only as a placeholder. Nevertheless,
// they *will* get included in the static library if you
// don't remove them :)
//
// Obviously, you 'll have to write yourself the super-duper
// functions to include in the resulting library...
// Also, it's not necessary to write every function in this file.
// Feel free to add more files in this project. They will be
// included in the resulting library.

// A function adding two integers and returning the result
int SampleAddInt(int p, int q)
{
    return p + q;
}

// A function doing nothing ;)
void SampleFunction1()
{
    // insert code here
}

// A function always returning zero
int SampleFunction2()
{
    // insert code here

    return 0;
}


2) I create another project with the following code:

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>

using namespace std;
int SampleAddInt(int, int );

int main()
{
int p=6; int q =5;
SampleAddInt(p,q);
    return 0;
}


3) I assure that the compiler and the linker of my project with the .cpp File use the right path and check the dependencies of my library project.



My Problem: But somehow I always get an error saying undefined reference to 'SampleAddInt(int, int )'.
I tried a lot but it just wont work for me. If someone could help me or give me some links I'd appreciate it very much.
Did you compile the library project? Where is the compiled binary library? Does the library have a header file(s) too?
Topic archived. No new replies allowed.