c++ - 生成错误 Makefile.win FLTK

标签 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 

最佳答案

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

编辑:

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

关于c++ - 生成错误 Makefile.win FLTK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1230708/

相关文章:

ruby-on-rails - 如何在 Ruby Views 中制作漂亮的 UI

c# - 填充 DropDownList

java - 跨方法更改变量

java - 选择框架中的所有对象

c++ - 动态转换的一些 'good use' 示例是什么?

c++ - istringstream 运算符>> 返回值

php - 如何让PHP和C/C++相互交互

c++ - 没有cygwin的android ndk调试

c++ - OpenCV 尝试读取或写入视频文件导致 VIDEOIO 异常 "Can' t 找到起始编号”(icvExtractPattern)

android - 如何在Android中从位图中裁剪圆形区域