Hello everybody!
I'm new on this forum so I have to present myself: I'm David, 17 years old and I am programming for almost 2 years in C++ (this is the primary language). I can handle a bit PHP, Python, C, C# and Visual C++ and that's all until now. If you continue reading this, please excuse my english, I'm not from UK or US so english is not my basic language. I am learning it.
I am working in Code::Blocks since I started to program. I can say that is a tremendous IDE, very intelligent (especially in syntax highlighting).
Now, I have to create a library (about vectors, but this is not important now).
Well, I saw that I can create that in Code::Blocks...so I did like that: New Project -> Static Library
Here, I see a file, called main.c with some functions in it. I can see a function wich returns the sum of 2 numbers. I rename it "Add". Now, I create a header file, named Add.h and I attach it to that project. I put it that header file, the prototype of the Add function. I compile the project. Now, the IDE gives me a libStatic_Library.a file located near the main.c file. Static_Library is the name of the project. As far as I learned, that file, libStatic_Library.a is a library - file, so my function "Add" is in that file.
Now I create a new Console Application project, in C++ language, I attach the Add.h header file to that project AND I link the library (or I at least I think that) like that:
Project -> Build Options -> Linker Settings -> Add, and here I browse the libStatic_Library.a file, and when I double - click on it, it says: "Keep this as a relative path? Yes/no". I click Yes, and then OK. Now (I think) the library should be linked.
I the main.cpp file I add the header file, #include"Add.h" and in main() function, I write that: std::cout<<Add(3,4); When I compile, I have an error, which says like that: undefined refference to 'Add(int, int)'.
What am I doing wrong?
I notice you that I am trying to solve this problem for a few weeks, but no result. Below, I tried to explain you every step I do, so that you can see if I am doing something wrong or if I am missing something.
P.S: All that I want is to create a library with a function in it, and to link it in Code::Blocks.
Thank you respectfully.