我有一个makefile,其中包含一个Rules.mak文件,该文件包含我想要使用的工具.问题是,如果工具文件夹要提取版本或使用"本机"安装,则它们具有空闲选项.所以我希望包含工具提取规则(如果存在),否则我想要包含本机文件.
这样的事情是目标:
if Tool/Rules.mak exists then
include Tool/Rules.mak
else
include common/Rules-Tool.mak
fi
Run Code Online (Sandbox Code Playgroud)
我已尝试过bash方式或make方式但是因为这是设置环境的前提条件我没有特定目标但由于检查失败而使调用错误.
if [ -f Tool/Rules.mak ]
then
echo testfile exists!
fi
Run Code Online (Sandbox Code Playgroud)
也
if [ -d ./Tool ]
then
echo testfile exists!
fi
Run Code Online (Sandbox Code Playgroud)
以及带引号和类似的版本.问题是,当我输入时几乎所有时间都会出现以下错误:
Rules.mak:14: *** missing separator. Stop.
Run Code Online (Sandbox Code Playgroud) 我还是UNIX/Linux世界的新手,尤其是相关工具,比如GCC编译器.也就是说,我仍然是makefiles和类似的东西的新手(我在Windows上使用MinGW),因为到目前为止,我的大多数开发都是使用像Visual Studio和Eclipse这样的IDE.
当我打开一个典型的项目文件夹时,我看到这样的文件:
configure
make
INSTALL
install-sh (or a variant)
Run Code Online (Sandbox Code Playgroud)
这里有很多我不理解的东西,我的主要问题是:
这些之间有什么区别,为什么我们需要每一个?(在IDE世界中,你所拥有的只是一个项目文件;就是这样.所以我很困惑为什么我们这里不仅仅是一个makefile.)
这些文件是如何生成的?对于小型项目,您可以手工编写它们,但对于像GCC这样的大型项目,即使尝试也是荒谬的.我发现编辑这些文件很痛苦,我得出的结论是我不应该手动修改它们.但如果是这样,那么人们通常使用哪些工具来添加和修改这些文件?
为什么他们不在makefile中使用通配符?为什么每个目标文件都有一行?这是因为限制,还是有优势?
拥有一个调用编译器的shell脚本和每个文件,以及一个makefile做同样的事情有什么区别?在Windows中,我很想在文件夹中创建批处理文件,并使用它编译所有内容 - 不需要只有一个文件.有什么不同?为什么不只是一个.sh
文件,编译一切?
奖金问题:
make
工具不接受彼此的格式......我怎么知道使用什么?GCC只是通常的工具,还是每个人都应遵循一些标准?我可能会有更多问题,因为我对这类项目的结构有了更多了解,但就目前而言,这些是我最大的问题.:)
你有没有试过将经典的c ++/make项目导入QtCreator?
让我们说我想在我的gui项目中使用一些需要构建的库.我怎样才能做到这一点 ?
这是我的目录的样子:
/project
makefile
/ceda_lib
makefile
files....
/general
makefile
files....
/CLI
makefile
files....
/objects
files.o
Run Code Online (Sandbox Code Playgroud)
Makefile文件(主):
1 #start other makefiles
2
3
4 o= ./objects
5 DEPS= Affine.hpp CEDA.hpp generalParameters.hpp generalFunctions.hpp
6 OBJ= $o/main.o $o/Affine.o $o/generalFunctions.o
7 CC=g++
8 CFLAGS= -Wall -g -I.
9 export CC
10 export CFLAGS
11 export DEPS
12
13 all:
14 ?---+$(MAKE) -C general
15 ?---+$(MAKE) -C ceda_lib
16 ?---+$(MAKE) -C CLI
17
18 run: $(OBJ) $(DEPS)
19 ?---$(CC) -o $@ $^
Run Code Online (Sandbox Code Playgroud)
其他makefile看起来像这样:(update2)
1 include ../makefile.variables …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Visual Studio 2010的MinGW(版本4.7.2)来使用一些新的C++ 11功能(遗憾的是我仍然使用WindowsXP并且不能使用Visual Studio 2012).首先,我创建了一个项目:File - > New Project - > Visual C++ - > General - > Makefile-Project
General:
Build Command Line: mingw32-make.exe
Rebuild All Command Line: mingw32-make.exe rebuild all
Clean Command Line: mingw32-make.exe clean all
IntelliSense:
Include Search Path: C:\MinGW\lib\gcc\mingw32\4.7.2\include\c++;C:\MinGW\include;
Assembly Search Path: C:\MinGW\lib\gcc\mingw32\4.7.2;C:\MinGW\lib;
Additional Arguments: -std=c++11
Run Code Online (Sandbox Code Playgroud)
我创建了一个包含内容的makefile:
all:
g++ -std=c++11 -pthread -o Makefile_Test.exe main.cpp
Run Code Online (Sandbox Code Playgroud)
它编译得很好,但在Visual Studios编辑器中几乎所有东西都是波浪形的红色.即
std::vector<std::thread> threads;
Run Code Online (Sandbox Code Playgroud)
std::vector
- >'错误:命名空间std没有成员向量'
std::thread
- >'错误:命名空间std没有成员线程'
甚至 std::cout << "";
std::cout
- >'错误:命名空间std没有成员cout'
但是我当然包括了相应的标题:Visual Studio甚至可以找到它们(将光标放在#include - > Ctrl …
我正在运行安装了CDT的Eclipse 3.7.2.Ubuntu 12.04 LTS.
我有一个现有的makefile C++项目,我试图从Geany导入.我可以$ make
在项目的根目录中运行,并且所有内容都按预期构建.
我在Eclipse中的错误:
make:***没有规则让目标"全部".停止.
我的问题:如何消除此错误?
以下是我正在采取的确切步骤:
Eclipse CDT:没有规则使目标全部接近回答我正在尝试纠正的问题,但我有与OP相同的问题:生成makefile自动不可用.
我已经尝试过制作:***没有规则可以制作目标"全部".停止.Eclipse错误的最高评级解决方案.但是,当我取消选中Build(Incremental Build)选项时,build完全没有任何功能,所以这也不对.
我正在尝试导入我之前在Windows下使用C++ 11和OpenCV编写的项目,但它给了我麻烦,我无法弄清楚为什么.这是一个MakeFile项目,我添加了一行来启用C++ 11支持.但是,当我试图在eclipse中运行"make"或运行项目时,我收到以下错误(以及其他一些错误)
use of deleted function ‘std::basic_filebuf<char>& std::basic_filebuf<char>::operator=(const std::basic_filebuf<char>&)’ FacadeLabelingV2 line 599, external location: /usr/include/c++/4.8/fstream
Run Code Online (Sandbox Code Playgroud)
我的代码看起来像这样:
#ifndef _FILEUTIL_CPP_
#define _FILEUTIL_CPP_
#include "Configuration.h"
#include "Utilities.cpp"
#include <iostream>
#include <fstream>
static void saveFeatures(const std::pair<cv::Mat, cv::Mat>& features, const Configuration& config, bool training, bool append, int counter = 0){
string prefix;
if (training) {
prefix = "train";
} else {
prefix = "test";
}
std::string directory = config.dir_classifiers + config.name_of_run;
std::ofstream save_file;
std::string counter_appendix = std::to_string(counter / 50);
std::string path_temp = directory + …
Run Code Online (Sandbox Code Playgroud) makefile ×4
c++ ×3
c++11 ×2
mingw ×2
bash ×1
configure ×1
eclipse ×1
eclipse-cdt ×1
opencv ×1
qt-creator ×1