Code :: Blocks - how to compile multiple source files

I am trying to compile a program with several source files - two CPP files and a header file with code :: blocks. As an example, I created the following three files (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 must refer to each other, I get an error: “Skip step link (assembly target is not tied to object files)” when I try to create a project.

What am I doing wrong? When trying to compile individual files, the error "This file is not assigned to any purpose" appears.

+9
source share
5 answers

:

, , .cpp . , . " :" "" "

+18

:

  • Code:: Blocks

  • File|New , .

  • .

, . , , . :: - . , GCC .

:

  • , CB, IDE. , . http://tdm-gcc.tdragon.net GCC . , .

  • CB Settings|Compiler and Debugger Toolchains executables. , TCC GCC ( , bin ), .

, CB http://forums.codeblocks.org.

+1

. , , , , #include , , . , #include "include/other.h", , .... / , .

+1

, , , , , .

+1

Make sure all files (.h and .cpp) are added to the project using Project> Add Files ... or Project> Add Floating Recursively ...

0
source

All Articles