栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

fltk和glog在mac下的安装与编译

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

fltk和glog在mac下的安装与编译

glog

根据官方文档安装即可
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 
		-lglog
fltk

官方网站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
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/664416.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号