I'm trying to compile a program with multiple source files - two CPP files and a header file, with code::blocks. As an example, I have created the following three files (an example program created by someone else on another forum):
main.cpp:
#include <stdio.h>
#include "other.h"
int main (void)
{
printf("%d\n", getfavoritenumber());
return 0;
}
other.cpp
#include "other.h"
int getfavoritenumber(void)
{
return 3;
}
other.h
#ifndef _OTHER_H_
#define _OTHER_H_
int getfavoritenumber(void);
#endif
Despite the fact that these three files should link to each other, I receive the error "Linking stage skipped (build target has no object files to link)" when I try to build the project.
What am I doing wrong? Trying to compile the individual files presents the error "That file isn't assigned to any target".
Here is what worked for me:
Go to the left panel that says projects, and right-click on .cpp file. Select properties, then go to build. Check the boxes under the heading Belongs in Targets: "Debug" and "Release"