code :: blocks - 如何编译多个文件项目 [英] code::blocks - how to compile multiple file projects

查看:1469
本文介绍了code :: blocks - 如何编译多个文件项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编译一个程序有多个源文件 - 两个CPP文件和一个头文件,代码::块。例如,我创建了以下三个文件(由另一个论坛上的其他人创建的示例程序):

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

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".

推荐答案

对我来说:

转到说明项目的左侧面板,右键单击.cpp文件。选择属性,然后去构建。选中标题属于目标:调试和释放

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"

这篇关于code :: blocks - 如何编译多个文件项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆