根据官方文档安装即可
https://github.com/google/glog
% git clone https://github.com/google/glog.git % cd glog % cmake -S . -B build -G "Unix Makefiles" //这句含义未知 % cmake --build build
安装完后可以去/usr/local目录下查看是否有对应的头文件和lib文件
若没有可以尝试make install命令
% make install
源文件如下
demo.cpp
#include#pragma comment(lib, "glog.lib") using namespace std; int main(int argc, char* argv[]) { string logpath = "./"; //init google::InitGoogleLogging(argv[0]); string info_log = logpath + "info_"; google::SetLogDestination(google::INFO, info_log.c_str()); string warning_log = logpath + "warning_"; google::SetLogDestination(google::WARNING, warning_log.c_str()); LOG(INFO) << "Hello Glog"; LOG(WARNING) << "Hello Glog"; getchar(); return 0; }
makefile
test: g++ demo.cpp -o main -I/usr/local/include/glog -L/usr/local/lib -lglogfltk
官方网站https://www.fltk.org/
1.3.7版本安装
然后cd进入fltk-1.3.7
% pwd ..../fltk-1.3.7 % mkdir build % cd build % cmake ..../fltk-1.3.7 【一些输出】 % make 【一些输出】 % make install
到此为止安装结束
源文件
base.hpp
#ifndef _base_HPP_ #define _base_HPP_ #include#include #include #endif//!_base_HPP_
demo.cpp
#include "base.hpp"
using namespace std;
int main(int argc, char **argv) {
Fl_Window *window = new Fl_Window(340,180);
Fl_Box *box = new Fl_Box(20,40,300,100,"Hello, World!");
box->box(FL_UP_BOX);
box->labelfont(FL_BOLD+FL_ITALIC);
box->labelsize(36);
box->labeltype(FL_SHADOW_LABEL);
window->end();
window->show(argc, argv);
return Fl::run();
}
makefile
#1.from document
test:
fltk-config —compile demo.cpp
#2.from document
CXX = $(shell fltk-config --cxx)
DEBUG = -g
CXXFLAGS = $(shell fltk-config --use-gl --use-images --cxxflags ) -I.
LDFLAGS = $(shell fltk-config --use-gl --use-images --ldflags )
LDSTATIC = $(shell fltk-config --use-gl --use-images --ldstaticflags )
link = $(CXX)
TARGET = cube
OBJS = demo.o
SRCS = demo.cpp
.SUFFIXES: .o .cpp
%.o: %.cpp
$(CXX) $(CXXFLAGS) $(DEBUG) -c $<
all: $(TARGET)
$(link) -o $(TARGET) $(OBJS) $(LDSTATIC)
$(TARGET): $(OBJS)
demo.o: demo.cpp
clean: $(TARGET) $(OBJS)
rm -f *.o 2> /dev/null
rm -f $(TARGET) 2> /dev/null
makefile里有两种选择,任选一种即可,均来自于fltk的官方文档
插两张windows下使用fltk的图片
补上windows下编译通过的makefile,最后一行命令我找了很久才找到,但是我对其表示的含义目前尚不明确
test: g++ base.hpp demo.cpp -o test -I F:CommonlyUsedAllCodefltk-1.3.5 -I F:CommonlyUsedAllCodefltk-1.3.5build -L F:CommonlyUsedAllCodefltk-1.3.5buildlib -lfltk -lcomctl32 -lwsock32 -lole32 -luuid -mwindows



