Caffe中Flages的安装与使用!

    调试Caffe的过程,小伙伴们应该都知道,需要通过.bat或.sh,把相关的命令传到Caffe.exe中,那么Caffe的命令传入是怎么实现的呢!下面给大家做一个简单的介绍,Caffe中命令的传入借用了google的开源工具gflags,因google被和谐的原因,在网上找到现在gflags被转到github中https://github.com/gflags/gflags,在里面下载原码!然后通过Cmake进行编译出第三方库(vs2012所使用的.lib与.h文件)。

   百度云gflags-master:http://pan.baidu.com/s/1qYCSUL2  密码:32cg

   百度云CMake:http://pan.baidu.com/s/1slyDJ33  密码:t9t2

    然后利用Cmake进行编译即可生成gflags第三方VS2012所需要的.h和.lib。具体可以考考http://blog.csdn.net/lming_08/article/details/25072899;以下是我编写的gflags测试代码。

#include "iostream"
#include "gflags/gflags.h"
#pragma comment (lib,"gflags_nothreads_static.lib")
#pragma comment (lib,"gflags_static.lib")
#pragma comment (lib,"shlwapi.lib")

// 定义对 FLAGS_port 的检查函数
static bool ValidatePort(const char* name, int32_t value) {
	if (value > 0 && value < 32768) {
		return true;
	}
	printf("Invalid value for --%s: %d\n", name, (int)value);
	return false;
}

DEFINE_string(host, "127.0.0.1", "the server host");

DEFINE_int32(port, 12306, "the server port");

static const bool port_dummy = gflags::RegisterFlagValidator(&FLAGS_port, &ValidatePort);

int main(int argc, char** argv)
{
	// 解析命令行参数,一般都放在 main 函数中开始位置
	gflags::ParseCommandLineFlags(&argc, &argv, true);

	std::cout << "The server host is: " << FLAGS_host
		<< ", the server port is: " << FLAGS_port << std::endl;

	// 使用 SetCommandLineOption 函数对参数进行设置才会调用检查函数
	gflags::SetCommandLineOption("port", "-2");

	std::cout << "The server host is: " << FLAGS_host
		<< ", the server port is: " << FLAGS_port << std::endl;
	return 0;
}

百度云源程序vs2012编译:http://pan.baidu.com/s/1qYatrRm  密码:int1


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值