我想用多个源文件 - 两个CPP文件和一个头文件,用code :: blocks编译一个程序。举个例子,我创建了以下三个文件(由其他人在另一个论坛创建的示例程序):Code :: Blocks - 如何编译多个源文件
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;
}
其他.h
#ifndef _OTHER_H_
#define _OTHER_H_
int getfavoritenumber(void);
#endif
尽管事实上这三个文件应该彼此链接,当我尝试构建项目时,收到错误“跳过链接舞台(构建目标没有目标文件链接)”。
我在做什么错?尝试编译单个文件会出现错误“该文件未分配给任何目标”。
您选择了哪种类型的项目?您应该选择“控制台应用程序”。 – jonsca 2011-05-11 22:26:43