static lib file problems with codeblocks

Hi guys

so as a lot of you may know I have been programming on and off in C++ for two years,and this is the first time I have ever used static libraries,I know what they are used for etc but have never implemented my own,

so I wanted to test the waters and try to see how they are written with a very simple static library file

it was originally saved as a .c file but I renamed it to a .cpp file

and when I build the project an alert comes up saying I must select a host application to run a library,

any idea what is going wrong? it's probably something simple

I am using codeblocks with mingw 32 bit compiler

thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  #include <iostream>


int SampleAddInt(int i1, int i2)
{
    return i1 + i2;
}

// A function doing nothing ;)
void SampleFunction1()
{
    std::cout << "hey" << std::endl;
    // insert code here
}

// A function always returning zero
int SampleFunction2()
{
    // insert code here
    std::cout << "ya" << std::endl;
    return 0;
}
closed account (SECMoG1T)
this tutorial can be very handy:
https://www.geeksforgeeks.org/static-vs-dynamic-libraries/
**update

hey guys managed to fix the problem,

just a question while on this topic.

when I included the lib file that I made in my linker settings why didn't I need to use the -l option in other linker options??

because with a library like SDL I need to specify -lSDL2 in the other linker option aswell as including the lib file

thanks
when I included the lib file that I made in my linker settings why didn't I need to use the -l option in other linker options??

Probably because the library happens to be in the current working directory of your project.
thanks jlb,that would make sense :)
Topic archived. No new replies allowed.