构建错误Makefile.win FLTK

时间:2009-08-05 01:13:45

标签: c++ user-interface

我有一个GUI项目(使用Fast Light Toolkit),其中包含以下组件。

此处列出的所有标题和文件(请注意Makefile.win)

http://www.stroustrup.com/Programming/Graphics/

这是我试图运行的文件。

#include "Simple_window.h"  // get access to our window library
#include "Graph.h"          // get access to our graphics library facilties

int main()
{
    using namespace Graph_lib; // our graphics facilities are in Graph_lib

    Point tl(100,100);         // to become top left corner of window

    Simple_window win(tl,600,400,"Canvas"); // make a simple window

    Polygon poly; // make a shape (a polygon)

    poly.add(Point(300,200));     // add point
    poly.add(Point(350,100));     // add another point
    poly.add(Point(400,200));     // add a third point

    poly.set_color(Color::red);   // adjust properties of poly

    win.attach(poly);             // connect poly to window

    win.wait_for_button();        // give control to display engine
}

首先,当我尝试编译时,我收到了一个错误

File: C:\Dev-Cpp\Makefile.win
Error: [Build Error] [Projectname.exe] Error 1

然后我进入项目选项并选择“使用自定义makefile”从网站中选择自定义makefile,该文件保存在我的C ++文件夹中(并且是项目的一部分。)

当我这样做时,我得到了

File: C:\Users\Alex\Makefile.win (this is a different makefile.win)
Error: [Build Error] No rule to make target 'c12_3.cpp'(the file I'm compiling)
       needed by 'c12_3.o'. Stop.

我使用Dev-C ++作为编译器。如果您需要更多信息,请告诉我。我很困惑。

编译后来自网站的makefile.win看起来像这样。

# Project: Stroustrup
# Makefile created by Dev-C++ 4.9.9.2

CPP  = g++.exe
CC   = gcc.exe
WINDRES = windres.exe
RES  = Stroustrup_private.res
OBJ  = Makefile.o ../Users/Alex/C++/ch12_3.o ../Users/Alex/C++/Graph.o ../Users/Alex/C++/GUI.o ../Users/Alex/C++/Simple_Window.o ../Users/Alex/C++/Window.o $(RES)
LINKOBJ  = Makefile.o ../Users/Alex/C++/ch12_3.o ../Users/Alex/C++/Graph.o ../Users/Alex/C++/GUI.o ../Users/Alex/C++/Simple_Window.o ../Users/Alex/C++/Window.o $(RES)
LIBS =  -L"C:/Dev-Cpp/lib" -mwindows -lfltk -lole32 -luuid -lcomctl32 -lwsock32 -lm  
INCS =  -I"C:/Dev-Cpp/include" 
CXXINCS =  -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include" 
BIN  = Stroustrup.exe
CXXFLAGS = $(CXXINCS)  
CFLAGS = $(INCS) -DWIN32 -mms-bitfields  
RM = rm -f

.PHONY: all all-before all-after clean clean-custom

all: all-before Stroustrup.exe all-after


clean: clean-custom
    ${RM} $(OBJ) $(BIN)

$(BIN): $(OBJ)
    $(CPP) $(LINKOBJ) -o "Stroustrup.exe" $(LIBS)

Makefile.o: Makefile.win
    $(CPP) -c Makefile.win -o Makefile.o $(CXXFLAGS)

../Users/Alex/C++/ch12_3.o: ../Users/Alex/C++/ch12_3.cpp
    $(CPP) -c ../Users/Alex/C++/ch12_3.cpp -o ../Users/Alex/C++/ch12_3.o $(CXXFLAGS)

../Users/Alex/C++/Graph.o: ../Users/Alex/C++/Graph.cpp
    $(CPP) -c ../Users/Alex/C++/Graph.cpp -o ../Users/Alex/C++/Graph.o $(CXXFLAGS)

../Users/Alex/C++/GUI.o: ../Users/Alex/C++/GUI.cpp
    $(CPP) -c ../Users/Alex/C++/GUI.cpp -o ../Users/Alex/C++/GUI.o $(CXXFLAGS)

../Users/Alex/C++/Simple_Window.o: ../Users/Alex/C++/Simple_Window.cpp
    $(CPP) -c ../Users/Alex/C++/Simple_Window.cpp -o ../Users/Alex/C++/Simple_Window.o $(CXXFLAGS)

../Users/Alex/C++/Window.o: ../Users/Alex/C++/Window.cpp
    $(CPP) -c ../Users/Alex/C++/Window.cpp -o ../Users/Alex/C++/Window.o $(CXXFLAGS)

Stroustrup_private.res: Stroustrup_private.rc 
    $(WINDRES) -i Stroustrup_private.rc --input-format=rc -o Stroustrup_private.res -O coff 

1 个答案:

答案 0 :(得分:1)

您不应该明确定义CPP和CC。这些已由Make定义。此外,您应该使用CXX而不是CPP(默认情况下,CXX指的是c ++编译器,而CPP指的是C预处理器)。此外,您不需要提供这么多目标。已经有自动构建规则将从.cpp文件生成具有相同基本名称的.o文件。另外,你的规则“Makefile.o:Makefile.win”没有任何意义(我怀疑你是在编译一个makefile)。我强烈建议你学习CMake,因为它会让你的生活变得更轻松。除此之外,您可能想要了解更多有关Make。

的信息

编辑:

我注意到你的路径有正斜杠(“/”)而不是反斜杠(“\”),这可能是Windows上的一个问题。虽然通常它不是Cygwin的问题,但如果你混合使用两种类型的斜杠,它可能会成为一个问题。