带头文件的C ++ Makefile依赖关系

时间:2016-11-10 18:56:01

标签: c++

我目前正在尝试生成可以处理C和C ++光线跟踪器项目的生成依赖项的makefile。我需要帮助生成正在使用的包含文件。

# Makefile

# Default Directories:
#  bin  the binary directory
#  inc  the include directory
#  obj  the object directory
#  src  the source directory
BIN_DIR  := bin
INC_DIR  := inc
OBJ_DIR  := obj
SRC_DIR  := src

# The compiler: gcc for C programs, define as g++ for C++
CC       := gcc
CXX      := g++

# Compiler flags:
#  -g      adds debugging information to the executable file
#  -Wall   turns on most, but not all, compiler warnings
#  -O2/O3  defines the optimization level of the program(s)  
CFLAGS   := -g -Wall -O2
CXXFLAGS := -g -Wall -O3

INCLUDES := -I$(INC_DIR)

我的文件结构如下:

Raytracer
  |
  |___bin
  |
  |___inc
  |    |__Geometric
  |           |____Vector3D.h
  |
  |___obj
  |
  |___src
       |__Geometric
       |    |______Vector3D.c
       |    |______Vector3D.cpp
       |
       |___Main
            |__Main.c
            |__Main.cpp 

在Vector3D.h文件中,我使用了模板格式并进行了初始化:

#ifndef __VECTOR3D_H__
#define __VECTOR3D_H__

#include <math.h>
#include <stdio.h>
#include <stdlib.h>

// C Methods defined surrounded with __cplusplus & extern "C" {...}
#ifdef __cplusplus
#include <sstream>
#include <iostream>

namespace Geometric {

   template <typename T = float>
   class Vector3D { // Vector3D

     // Constructors already defined...
     // Methods already defined...
     // Etc...

   }; // The 'Vector3D' Class

     // Implemented constructors...
     // Implemented Methods...
     // Implemented Etc...

} // The 'Geometric' Namespace

#endif /* __cplusplus */
#endif /* __VECTOR3D_H__ */

定义Vector3D.c&amp;我应该使用Vector3D.cpp文件:

#include "Geometric/Vector3D.h"

// Or

#include <Geometric/Vector3D.h>

// Or does it matter...

0 个答案:

没有答案