2016-03-06 120 views
0

我有3個文件。 這些在visual studio中編譯。如何構建一個makefile文件

in2post.cpp

long.h

long.hpp,

long.h的#includes long.hpp

並且兩個long.hpp和in2post.hpp的#include in2post

我的makefile看起來像這樣

in2post: in2post.o 
     g++ -std=c++11 -o in2post.o in2post 

in2post.o: in2post.cpp long.hpp long.h 
     g++ -std=c++11 -c in2post.cpp 

clean: 
     rm *.o in2post 

我得到

[email protected]:~>make 
g++ -std=c++11 -c in2post.cpp 
In file included from long.h:40:0, 
       from in2post.cpp:3: 
long.hpp: In member function ârob::Long<T>& rob::Long<T>::operator=(rob::Long<T>&&)â: 
Long.hpp:36:1: error: expected â;â before â}â token 
} 
^ 
makefile:5: recipe for target 'in2post.o' failed 
make: *** [in2post.o] Error 1 
[email protected]:~>nano makefile 
+2

該錯誤消息僅僅意味着'make'已經退出,因爲目標'inpost.o'的配方失敗了。爲了向我們展示實際發生了什麼問題,您需要發佈失敗的編譯命令('g ++ -c ...')以及後面的所有錯誤,如'make'輸出。 –

+0

請參閱[this](http://stackoverflow.com/a/14180540/841108)示例,但在「CXXFLAGS」標誌中添加「-std = C++ 11」。 –

+2

'g ++ -o in2post.o in2post' this * wont * quite * work。 –

回答

0

看來++遇到一些奇怪的字符,並且不能解析文件克我的建議是在像vim這樣的純文本編輯器中打開該文件,並刪除&重新插入rob::Long<T>(它可能是一個不可見的字符)之前的空格,並刪除函數聲明operator=(rob::Long<T>&&)â末尾的字符。

相關問題