im trying to create my own libraries and header files and jst cant seem to get it right i try simple examples but compiler keep thorwing out same error heres my code;
try.h
1 2 3 4 5 6 7 8
#ifndef TRY_H_INCLUDED
#define TRY_H_INCLUDED
int SUM(int a , int b , int c);
#endif // TRY_H_INCLUDED
try.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
#include "try.h"
usingnamespace std;
int SUM (int a , int b , int c )
{
int sum;
sum = a + b + c;
cout<< a <<" + "<< b <<" + "<< c <<" = "<<sum<<endl;
return sum;
}
The files in your project should be listed in the little explorer window on the left. Right click on each .cpp file, go to properties, and look around for a "compile this file" and "link this file" option. Make sure both are checked.
My guess is when you added the try.cpp file to the project you didn't check those options.
lol silly error guys soo this what you got to do....(for code blocks)
1) Go to the PROJECT , then right click and go to PROPERTIES...
2) han go to the BUILD TARGETS tab....
3) Look for the BUILD TARGET FILES at the bottom....
4) Now select all the .cpp and .h files and click ok
5) And boom it works lol