News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

CodeBlock does't detect non main source file

Started by reemassam14, April 26, 2015, 06:15:54 AM

Previous topic - Next topic

reemassam14

I build 3 files main.cpp , head.h and head.cpp.


main.cpp===>>

#include <iostream>
#include "head.h"
using namespace std;

int main()
{
show();
return 0;
}


head.h===>>

#ifndef HEAD_H_INCLUDED
#define HEAD_H_INCLUDED

void show();

#endif // HEAD_H_INCLUDED


head.cpp===>

#include <iostream>
#include "head.h"
using std::cout;

void show()
{
cout<<"Hello world!!";
}
-----------------------------------------------------------------------------
simple program to illustrate my problem. Whenever i run this program i get an error saying
in function main undefine refernce to show()
--------------------------------------------------------------------------
any solution to configure my CodeBlock..
--------------------------------------------------------------------------
it is working only when i include head.cpp in head.h . and i don't want to do that .plzzz help

MortenMacFly

Create a project, add all files, hit compile. Don't do a single file compilation. Inspect the C::B manual to see how to do so.

Next time, please don't do multiple posts with the same content. I've removed the other.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

reemassam14

Still not working... same error in main undefine refence to show()

MortenMacFly

Sorry, but I cannot believe this.
I've attached the project that works just fine.

Next time, please be more clear what EXACTLY you do, on what platform, what version, what compiler etc...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]