Tan*_*ley 3 c++ makefile compilation c++11
当我make在终端中编译使用它打印:
g++ -Wall –std=c++11 -c File.cpp
clang: error: no such file or directory: '–std=c++11'
make: *** [Book.o] Error 1
Run Code Online (Sandbox Code Playgroud)
生成文件:
PROG = studs
CC = g++
OBJS = File.o FileTestDriver.o
CPPFLAGS = -Wall –std=c++11
$(PROG) : $(OBJS)
$(CC) -o $(PROG) $(OBJS)
File.o : File.h
$(CC) $(CPPFLAGS) -c File.cpp
FileTestDriver.o :
$(CC) $(CPPFLAGS) -c FileTestDriver.cpp
clean:
$(RM) $(PROG) $(OBJS)
Run Code Online (Sandbox Code Playgroud)
FileTestDriver具有main函数,File.cpp只是一个带有一些构造函数,实例变量和函数的简单类.我不确定问题出在哪里,但我认为它是在Makefile中,因为我刚开始使用它们.
当我简单编译时,g++ -std=c++11 File.cpp我得到错误:
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
但我认为错误是因为它有一个.h并且需要编译makefile.无论如何,不知道我做错了什么,但我感谢任何帮助.如果需要更多信息,请与我们联系.
另外(也许这应该是一个单独的问题/我需要更加努力),但在使用makefile之后,./a.out只会运行makefile,无论我编译的最后一件事.不知道如何改变它.
如果你仔细看看你的编译行,你会看到-之前Wall和–之前的一个非常微妙的区别std=c++11:
g++ -Wall –std=c++11 -c File.cpp
^ ^
Run Code Online (Sandbox Code Playgroud)
该字符实际上是一个短划线(Unicode代码点U+2013),这个问题经常是由字处理器之类的地方剪切和粘贴引起的.因为它不被认为是有效的引入字符(连字符,Unicode代码点U+002D),所以它只是被视为文件名,因此错误.
我建议你只需重新键入行(或只是-std=c++11位)以确保它使用正确的字符.
| 归档时间: |
|
| 查看次数: |
4447 次 |
| 最近记录: |