<i id='tdSC3'><tr id='tdSC3'><dt id='tdSC3'><q id='tdSC3'><span id='tdSC3'><b id='tdSC3'><form id='tdSC3'><ins id='tdSC3'></ins><ul id='tdSC3'></ul><sub id='tdSC3'></sub></form><legend id='tdSC3'></legend><bdo id='tdSC3'><pre id='tdSC3'><center id='tdSC3'></center></pre></bdo></b><th id='tdSC3'></th></span></q></dt></tr></i><div id='tdSC3'><tfoot id='tdSC3'></tfoot><dl id='tdSC3'><fieldset id='tdSC3'></fieldset></dl></div>

    <small id='tdSC3'></small><noframes id='tdSC3'>

  1. <legend id='tdSC3'><style id='tdSC3'><dir id='tdSC3'><q id='tdSC3'></q></dir></style></legend>
  2. <tfoot id='tdSC3'></tfoot>

      <bdo id='tdSC3'></bdo><ul id='tdSC3'></ul>

    1. 用于 linux 的最小 C++ 生成文件

      minimum c++ make file for linux(用于 linux 的最小 C++ 生成文件)
      1. <tfoot id='UbM5U'></tfoot>

        <small id='UbM5U'></small><noframes id='UbM5U'>

      2. <legend id='UbM5U'><style id='UbM5U'><dir id='UbM5U'><q id='UbM5U'></q></dir></style></legend>

          • <bdo id='UbM5U'></bdo><ul id='UbM5U'></ul>
                  <tbody id='UbM5U'></tbody>
              • <i id='UbM5U'><tr id='UbM5U'><dt id='UbM5U'><q id='UbM5U'><span id='UbM5U'><b id='UbM5U'><form id='UbM5U'><ins id='UbM5U'></ins><ul id='UbM5U'></ul><sub id='UbM5U'></sub></form><legend id='UbM5U'></legend><bdo id='UbM5U'><pre id='UbM5U'><center id='UbM5U'></center></pre></bdo></b><th id='UbM5U'></th></span></q></dt></tr></i><div id='UbM5U'><tfoot id='UbM5U'></tfoot><dl id='UbM5U'><fieldset id='UbM5U'></fieldset></dl></div>
                本文介绍了用于 linux 的最小 C++ 生成文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在寻找一个简单的推荐最小"c++ makefile for linux,它将使用 g++ 来编译和链接单个文件和 h 文件.理想情况下,make 文件中甚至不会包含物理文件名,并且只有 .cpp 到 .o 的转换.在不深入研究 autoconf 的恐怖的情况下生成这样的 makefile 的最佳方法是什么?

                I've looking to find a simple recommended "minimal" c++ makefile for linux which will use g++ to compile and link a single file and h file. Ideally the make file will not even have the physical file names in it and only have a .cpp to .o transform. What is the best way to generate such a makefile without diving into the horrors of autoconf?

                当前目录包含,例如

                t.cppt.h

                并且我想要为此创建一个 makefile.我试过 autoconf 但它假设 .h 是 gcc 而不是 g++.是的,虽然我不是初学者,但我正在从多年前重新学习项目操作的最佳方法,因此我正在寻找自动化的方法来为小型项目创建和维护 makefile.

                and I want a makefile for that to be created. I tried autoconf but its assuming .h is gcc instead of g++. Yes, while not a beginner, I am relearning from years ago best approaches to project manipulation and hence am looking for automated ways to create and maintain makefiles for small projects.

                推荐答案

                如果是单个文件,可以输入

                If it is a single file, you can type

                make t
                

                它会调用

                g++ t.cpp -o t
                

                这甚至不需要目录中的 Makefile,尽管如果您有 t.cpp、t.c 和 t.java 等,它会感到困惑

                This doesn't even require a Makefile in the directory, although it will get confused if you have a t.cpp and a t.c and a t.java, etc etc.

                也是一个真正的 Makefile:

                Also a real Makefile:

                SOURCES := t.cpp
                # Objs are all the sources, with .cpp replaced by .o
                OBJS := $(SOURCES:.cpp=.o)
                
                all: t
                
                # Compile the binary 't' by calling the compiler with cflags, lflags, and any libs (if defined) and the list of objects.
                t: $(OBJS)
                    $(CC) $(CFLAGS) -o t $(OBJS) $(LFLAGS) $(LIBS)
                
                # Get a .o from a .cpp by calling compiler with cflags and includes (if defined)
                .cpp.o:
                    $(CC) $(CFLAGS) $(INCLUDES) -c $<
                

                这篇关于用于 linux 的最小 C++ 生成文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                C++ stl unordered_map implementation, reference validity(C++ stl unordered_map 实现,参考有效性)
                C++: Is it possible to use a reference as the value in a map?(C++:是否可以使用引用作为映射中的值?)
                Where ampersand quot;amp;quot; can be put when passing argument by reference?(其中符号“amp;通过引用传递参数时可以放置吗?)
                Why can a non-const reference parameter be bound to a temporary object?(为什么可以将非常量引用参数绑定到临时对象?)
                What is a dangling reference?(什么是悬空引用?)
                C++ reference changes when push_back new element to std::vector(当 push_back 新元素到 std::vector 时,C++ 引用发生变化)
                <legend id='UaK4P'><style id='UaK4P'><dir id='UaK4P'><q id='UaK4P'></q></dir></style></legend>

                  <small id='UaK4P'></small><noframes id='UaK4P'>

                    <tbody id='UaK4P'></tbody>

                      <tfoot id='UaK4P'></tfoot>
                        <bdo id='UaK4P'></bdo><ul id='UaK4P'></ul>

                        • <i id='UaK4P'><tr id='UaK4P'><dt id='UaK4P'><q id='UaK4P'><span id='UaK4P'><b id='UaK4P'><form id='UaK4P'><ins id='UaK4P'></ins><ul id='UaK4P'></ul><sub id='UaK4P'></sub></form><legend id='UaK4P'></legend><bdo id='UaK4P'><pre id='UaK4P'><center id='UaK4P'></center></pre></bdo></b><th id='UaK4P'></th></span></q></dt></tr></i><div id='UaK4P'><tfoot id='UaK4P'></tfoot><dl id='UaK4P'><fieldset id='UaK4P'></fieldset></dl></div>