window caffe compiler problems solving

  • vs2013编译caffe的io.cpp文件错误,open和close无法识别,

    解决方法:

    将下列代码放在io.cpp的前面

    #ifdef _MSC_VER
    #define open _open
    #endif

    在有close(fd)的地方改为

      #ifdef _MSC_VER
         close(fd);
      #else
         _close(fd);
      #endif

    最重要的是_open(),_close()是io.h中的函数,所以,要在最前面加上#include ”io.h“,问题解决

    if出现了下述问题:

    error C4996: 'close': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name:    

    解决办法

    这个问题在VS 2012之前的版本中是不会当做错误的,只是提出一个警告。为了避免报错,可以使用以下两个宏定义来屏蔽掉这种错误。

    在io.cpp文件的属性->c/c++->预处理器->预处理器定义中添加:

        _CRT_SECURE_NO_DEPRECATE 

        _CRT_NONSTDC_NO_DEPRECATE


Second issue from [

Microsoft/caffe @github: https://github.com/Microsoft/caffe/commit/

]
  src/caffe/util/signal_handler.cpp
@@ -13,9 +13,15 @@ namespace {
   
    void handle_signal(int signal) {
    switch (signal) {
    +#ifdef _MSC_VER
    + case SIGBREAK://there is no SIGHUP in windows, take SIGBREAK instead.
    + got_sighup = true;
    + break;
    +#else
    case SIGHUP:
    got_sighup = true;
    break;
    +#endif
    case SIGINT:
    got_sigint = true;
    break;
@@ -27,7 +33,14 @@ namespace {
    LOG(FATAL) << "Tried to hookup signal handlers more than once.";
    }
    already_hooked_up = true;
   -
    +#ifdef _MSC_VER
    + if (signal(SIGBREAK, handle_signal) == SIG_ERR) {
    + LOG(FATAL) << "Cannot install SIGBREAK handler.";
    + }
    + if (signal(SIGINT, handle_signal) == SIG_ERR) {
    + LOG(FATAL) << "Cannot install SIGINT handler.";
    + }
    +#else
    struct sigaction sa;
    // Setup the handler
    sa.sa_handler = &handle_signal;
@@ -42,11 +55,20 @@ namespace {
    if (sigaction(SIGINT, &sa, NULL) == -1) {
    LOG(FATAL) << "Cannot install SIGINT handler.";
    }
    +#endif
    }
   
    // Set the signal handlers to the default.
    void UnhookHandler() {
    if (already_hooked_up) {
    +#ifdef _MSC_VER
    + if (signal(SIGBREAK, SIG_DFL) == SIG_ERR) {
    + LOG(FATAL) << "Cannot uninstall SIGHUP handler.";
    + }
    + if (signal(SIGINT, SIG_DFL) == SIG_ERR) {
    + LOG(FATAL) << "Cannot uninstall SIGINT handler.";
    + }
    +#else
    struct sigaction sa;
    // Setup the sighub handler
    sa.sa_handler = SIG_DFL;
@@ -61,7 +83,7 @@ namespace {
    if (sigaction(SIGINT, &sa, NULL) == -1) {
    LOG(FATAL) << "Cannot uninstall SIGINT handler.";
    }
   -
    +#endif
    already_hooked_up = false;
    }
    }
 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值