I have three file:
main.cpp:
#include <iostream>
#include "head.h"
using namespace std;
int main()
{
int a,b;
a=2;b=3;
int c=sum(a,b);
cout <<"c:"<<c<<endl;
return 0;
}
head.h:
#ifndef _HEAD_H_
#define _HEAD_H_
int sum(int a , int b);
#endif
head.c:
#include "head.h"
int sum(int a, int b)
{
return(a+b);
}
When I compile it, codeblocks give me the error: undefined error to function sum. And I have also included the path in Setting->Build Options->Search Directories->Compiler->Add. But still I get the error.
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F
but probably you are not using projects?
No. I am using projects. But I did choose "Empty Project".
Then add all your files to the project. This will resolve the problem.
I have already done that but still doesn't seem to work. Here is screenshot:https://ibb.co/cKX5xc
how about you read my link and do what is written there? without this information this is wild guessing....
My problem is solved. It looks like the problem was related to the installation of code blocks but I was able to get the desired result after uninstalling and reinstalling codeBlocks. However the following are the details:
I am running codeBlocks 16.01 on ubuntu 16.04.9. The compiler I use is g++ version 5.4.0.
I have 3 files that I want to compile: main.cpp head.h head.cpp.
I had created a new empty project in codeblocks and then I had created these 3 files within codeblocks. I have also set the path in Setting->Build Options->Search Directories->Compiler->Add. However when I click the Build and Run button, codeblocks gives me the error that "Undefined reference to function 'sum(int, int)' ".
nice that it works... But for the next time: In the link is clearly described that we need a full rebuild log. Without this log it is impossible to help. Can people not read and follow instructions nowadays?
Quote from: BlueHazzard on February 23, 2018, 09:16:39 PM
nice that it works... But for the next time: In the link is clearly described that we need a full rebuild log. Without this log it is impossible to help. Can people not read and follow instructions nowadays?
I am actually wondering if they can follow links, sometimes.
Tim S.