草庐IT

c++ - GCC - 'sizeof' 之前的预期不合格 ID - Android NDK 中的 IT++ 4.2

coder 2024-02-24 原文

我已成功在我的 Android NDK 项目中构建 CLAPACK。接下来,我尝试将 IT++ 4.2 库放入其中。但是,我有一些无法修复的错误。这些是我在我的项目中所做的事情:

首先,我将itpp文件夹复制到我项目的jni文件夹中,并修改了itpp中的config.h。

因为我在(放在..android-ndk-r7b\platforms\android-9\arch-arm\usr\include中)找到了isfinite、isinf和isnan函数。我将 HAVE_DECL_ISINF、HAVE_DECL_ISFINITE 和 HAVE_DECL_ISNAN 设置为 1。

config.h

#ifndef CONFIG_H
#define CONFIG_H


/* Define to dummy `main' function (if any) required to link to the Fortran
   libraries. */
/* #undef F77_DUMMY_MAIN */

/* Define if F77 and FC dummy `main' functions are identical. */
/* #undef FC_DUMMY_MAIN_EQ_F77 */

/* Define to 1 if you have the `acosh' function. */
#define HAVE_ACOSH 1

/* Define to 1 if you have the `asinh' function. */
#define HAVE_ASINH 1

/* Define to 1 if you have the `atanh' function. */
#define HAVE_ATANH 1

/*#if defined(HAVE_ACML) || defined(HAVE_MKL)
/* Define if you have a BLAS library. */
#define HAVE_BLAS 1
/*#endif

#ifdef HAVE_ACML
/* Define if you have an ACML BLAS library. */
/*#  define HAVE_BLAS_ACML 1
/*#endif

/* Define if you have an ATLAS BLAS library. */
/* #undef HAVE_BLAS_ATLAS */

/*#ifdef HAVE_MKL
/* Define if you have an MKL BLAS library. */
/*#  define HAVE_BLAS_MKL 1
/*#endif

/* Define to 1 if you have the `cbrt' function. */
#  define HAVE_CBRT 1

/* Define to 1 if you have the <cmath> header file. */
/*#define HAVE_CMATH 1

/* Define to 1 if you have the <complex> header file. */
/*#define HAVE_COMPLEX 1

/* Define to 1 if you have the declaration of `isfinite', and to 0 if you
   don't. */
#define HAVE_DECL_ISFINITE 1

/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't.
   */
#define HAVE_DECL_ISINF 1

/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't.
   */
#define HAVE_DECL_ISNAN 1

/* Define to 1 if you have the declaration of `signgam', and to 0 if you
   don't. */
/*#define HAVE_DECL_SIGNGAM 0

/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1

/* Define to 1 if you have the `erf' function. */
#define HAVE_ERF 1

/* Define to 1 if you have the `erfc' function. */
#define HAVE_ERFC 1

/* Define to 1 if you have the `expm1' function. */
/* #undef HAVE_EXPM1 */

/* Define if the compiler supports extern template */
/* #undef HAVE_EXTERN_TEMPLATE */

#if defined(HAVE_ACML) || defined(HAVE_MKL)
/* Define if you have FFT library. */
#  define HAVE_FFT 1
#endif

/* Define if you have FFTW3 library. */
/* #undef HAVE_FFTW3 */

#ifdef HAVE_ACML
/* Define if you have ACML FFT library. */
#  define HAVE_FFT_ACML 1
#endif

#ifdef HAVE_MKL
/* Define if you have MKL FFT library. */
#  define HAVE_FFT_MKL 1
#endif

/* Define to 1 if you have the `finite' function. */
#define HAVE_FINITE 1

/* Define to 1 if you have the `fpclass' function. */
/*#define HAVE_FPCLASS 1

/* Define to 1 if you have the <ieeefp.h> header file. */
/* #undef HAVE_IEEEFP_H */

/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

/* Define to 1 if you have the `isfinite' function. */
#define HAVE_ISFINITE 1

/* Define to 1 if you have the `isinf' function. */
/* #undef HAVE_ISINF */

/* Define to 1 if you have the `isnan' function. */
/*#define HAVE_ISNAN 1

/*#if defined(HAVE_ACML) || defined(HAVE_MKL)
/* Define if you have LAPACK library. */
#define HAVE_LAPACK 1
/*#endif

/* Define to 1 if you have the `lgamma' function. */
/* #undef HAVE_LGAMMA */

/* Define to 1 if you have the `log1p' function. */
/* #undef HAVE_LOG1P */

/* Define to 1 if you have the `log2' function. */
/* #undef HAVE_LOG2 */

/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1

/* Define to 1 if you have the `rint' function. */
#define HAVE_RINT 1

/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1

/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1

/* Define to 1 if you have the `std::isfinite' function. */
/* #undef HAVE_STD_ISFINITE */

/* Define to 1 if you have the `std::isinf' function. */
/* #undef HAVE_STD_ISINF */

/* Define to 1 if you have the `std::isnan' function. */
/* #undef HAVE_STD_ISNAN */

/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1

/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1

/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1

/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1

/* Define to 1 if you have the `tgamma' function. */
/* #undef HAVE_TGAMMA */

/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1

/* Define if you use zdotusub_ Fortran wrapper. */
/* #undef HAVE_ZDOTUSUB */

/* Define if "void zdotu_()" should be used. */
#define HAVE_ZDOTU_VOID 1

/* Define if you want exceptions handling */
/* #undef ITPP_EXCEPTIONS */

/* Name of package */
#define PACKAGE "itpp"

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "ediap@users.sourceforge.net"

/* Define to the full name of this package. */
#define PACKAGE_NAME "IT++"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "IT++ 4.0.0"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "itpp"

/* Define to the version of this package. */
#define PACKAGE_VERSION "4.0.0"

/* The size of `int', as computed by sizeof. */
#define SIZEOF_INT 4

/* The size of `long', as computed by sizeof. */
#define SIZEOF_LONG 4

/* The size of `long long', as computed by sizeof. */
#define SIZEOF_LONG_LONG 8

/* The size of `short', as computed by sizeof. */
#define SIZEOF_SHORT 2

/* The size of `unsigned int', as computed by sizeof. */
#define SIZEOF_UNSIGNED_INT 4

/* The size of `unsigned long', as computed by sizeof. */
#define SIZEOF_UNSIGNED_LONG 4

/* The size of `unsigned long long', as computed by sizeof. */
#define SIZEOF_UNSIGNED_LONG_LONG 8

/* The size of `unsigned short', as computed by sizeof. */
#define SIZEOF_UNSIGNED_SHORT 2

/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1

/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
/* #undef TIME_WITH_SYS_TIME */

/* Version number of package */
#define VERSION "4.0.0"


#if defined(HAVE_CMATH)
#  include <cmath>
#endif
/*#include <math.h>*/
#endif /* #ifndef CONFIG_H */

数学.h

   [..]
    #define fpclassify(x) \
    ((sizeof (x) == sizeof (float)) ? __fpclassifyf(x) \
    : (sizeof (x) == sizeof (double)) ? __fpclassifyd(x) \
    : __fpclassifyl(x))

#define isfinite(x)                 \
    ((sizeof (x) == sizeof (float)) ? __isfinitef(x)    \
    : (sizeof (x) == sizeof (double)) ? __isfinite(x)   \
    : __isfinitel(x))
#define isinf(x)                    \
    ((sizeof (x) == sizeof (float)) ? __isinff(x)   \
    : (sizeof (x) == sizeof (double)) ? __isinf(x)  \
    : __isinfl(x))
#define isnan(x)                    \
    ((sizeof (x) == sizeof (float)) ? isnanf(x)     \
    : (sizeof (x) == sizeof (double)) ? isnan(x)    \
    : __isnanl(x))
#define isnormal(x)                 \
    ((sizeof (x) == sizeof (float)) ? __isnormalf(x)    \
    : (sizeof (x) == sizeof (double)) ? __isnormal(x)   \
    : __isnormall(x))
[..]

但是,当我编译 itpp 时,我在 itcompat.h 文件中收到错误

#ifndef ITCOMPAT_H
#define ITCOMPAT_H

#ifndef _MSC_VER
#  include <itpp/config.h>
#else
#  include <itpp/config_msvc.h>
#endif

//! \cond

// Microsoft Visual C++ underscore prefixed functions
#if defined(_MSC_VER)
#  include <cfloat>
#  define finite(x) _finite(x)
#  define isfinite(x) _finite(x)
#  define isnan(x) _isnan(x)
#  define fpclass(x) _fpclass(x)
#  define FP_NINF _FPCLASS_NINF
#  define FP_PINF _FPCLASS_PINF
#  define jn(a, b) _jn(a, b)
#  define yn(a, b) _yn(a, b)
#  define j0(a) _j0(a)
#  define j1(a) _j1(a)
#endif // defined(_MSC_VER)


// Solaris uses <ieeefp.h> for declaring isnan() and finite() functions
#if defined(HAVE_IEEEFP_H)
#  include <ieeefp.h>
#endif

// These definitions would collide with IT++ functions
#if defined(min)
#  undef min
#endif
#if defined(max)
#  undef max
#endif
#if defined(log2)
#  undef log2
#endif
namespace std
{

#ifndef HAVE_STD_ISINF
#if (HAVE_DECL_ISINF == 1) || defined(HAVE_ISINF)
inline int isinf(double x) { return ::isinf(x); } //line 77
#elif defined(FPCLASS)
inline int isinf(double x)
{
  if (::fpclass(a) == FP_NINF) return -1;
  else if (::fpclass(a) == FP_PINF) return 1;
  else return 0;
}
#else
inline int isinf(double x)
{
  if ((x == x) && ((x - x) != 0.0)) return (x < 0.0 ? -1 : 1);
  else return 0;
}
#endif // #if (HAVE_DECL_ISINF == 1) || defined(HAVE_ISINF)
#endif // #ifndef HAVE_STD_ISINF

#ifndef HAVE_STD_ISNAN
#if (HAVE_DECL_ISNAN == 1) || defined(HAVE_ISNAN)
inline int isnan(double x) { return ::isnan(x); }   //line 96
#else
inline int isnan(double x) { return ((x != x) ? 1 : 0); }
#endif // #if (HAVE_DECL_ISNAN == 1) || defined(HAVE_ISNAN)
#endif // #ifndef HAVE_STD_ISNAN

#ifndef HAVE_STD_ISFINITE
#if (HAVE_DECL_ISFINITE == 1) || defined(HAVE_ISFINITE)
inline int isfinite(double x) { return ::isfinite(x); }   //line 104
#elif defined(HAVE_FINITE)
inline int isfinite(double x) { return ::finite(x); }
#else
inline int isfinite(double x)
{
  return ((!std::isnan(x) && !std::isinf(x)) ? 1 : 0);
}
#endif // #if (HAVE_DECL_ISFINITE == 1) || defined(HAVE_ISFINITE)
#endif // #ifndef HAVE_STD_ISFINITE

} // namespace std

[..]

转换器.cpp

#include <itpp/base/converters.h>
#include <itpp/base/itcompat.h>
#include <itpp/base/matfunc.h>
#include <itpp/base/math/log_exp.h>

//! \cond

namespace itpp
{

// ----------------------------------------------------------------------
// Vector converters
// ----------------------------------------------------------------------

ivec to_ivec(int s) { ivec out(1); out(0) = s; return out; }

vec to_vec(double s) { vec out(1); out(0) = s; return out; }

cvec to_cvec(double real, double imag)
{
  cvec out(1);
  out(0) = std::complex<double>(real, imag);
  return out;
}

// ----------------------------------------------------------------------
// Miscellaneous converters
// ----------------------------------------------------------------------

bvec dec2bin(int length, int index)
{
  int i, bintemp = index;
  bvec temp(length);

  for (i = length - 1; i >= 0; i--) {
    temp(i) = bin(bintemp & 1);
    bintemp = (bintemp >> 1);
  }
  return temp;
}

bvec dec2bin(int index, bool msb_first)
{
  int length = int2bits(index);
  int i, bintemp = index;
  bvec temp(length);

  for (i = length - 1; i >= 0; i--) {
    temp(i) = bin(bintemp & 1);
    bintemp = (bintemp >> 1);
  }
  if (msb_first) {
    return temp;
  }
  else {
    return reverse(temp);
  }
}

void dec2bin(int index, bvec &v)
{
  int i, bintemp = index;
  v.set_size(int2bits(index), false);

  for (i = v.size() - 1; i >= 0; i--) {
    v(i) = bin(bintemp & 1);
    bintemp = (bintemp >> 1);
  }
}

int bin2dec(const bvec &inbvec, bool msb_first)
{
  int i, temp = 0;
  int sizebvec = inbvec.length();
  if (msb_first) {
    for (i = 0; i < sizebvec; i++) {
      temp += pow2i(sizebvec - i - 1) * int(inbvec(i));
    }
  }
  else {
    for (i = 0; i < sizebvec; i++) {
      temp += pow2i(i) * int(inbvec(i));
    }
  }
  return temp;
}

bvec oct2bin(const ivec &octalindex, short keepzeros)
{
  int length = octalindex.length(), i;
  bvec out(3*length);
  for (i = 0; i < length; i++) {
    out.replace_mid(3*i, dec2bin(3, octalindex(i)));
  }
  //remove zeros if keepzeros = 0
  if (keepzeros == 0) {
    for (i = 0; i < out.length(); i++) {
      if ((short)out(i) != 0) {
        return out.right(out.length() - i);
        break;
      }
    }
    return bvec("0");
  }
  else {
    return out;
  }
}

ivec bin2oct(const bvec &inbits)
{
  int start, Itterations = ceil_i(inbits.length() / 3.0);
  ivec out(Itterations);
  for (int i = Itterations - 1; i > 0; i--) {
    start = 3 * i - (3 * Itterations - inbits.length());
    out(i) = bin2dec(inbits.mid(start, 3));
  }
  out(0) = bin2dec(inbits.left(inbits.length() - ((Itterations - 1) * 3)));
  return out;
}

ivec bin2pol(const bvec &inbvec)
{
  return 1 -2*to_ivec(inbvec);
}

bvec pol2bin(const ivec &inpol)
{
  return to_bvec((1 -inpol) / 2);
}


// Round to nearest integer, return result in double
double round(double x) { return ::rint(x); }
// Round to nearest integer
vec round(const vec &x) { return apply_function<double>(::rint, x); }
// Round to nearest integer
mat round(const mat &x) { return apply_function<double>(::rint, x); }
// Round to nearest integer
int round_i(double x) { return static_cast<int>(::rint(x)); }

// Round to nearest integer and return ivec
ivec round_i(const vec &x) { return to_ivec(round(x)); }
// Round to nearest integer and return imat
imat round_i(const mat &x) { return to_imat(round(x)); }

// Round to nearest upper integer
ivec ceil_i(const vec &x) { return to_ivec(ceil(x)); }
// Round to nearest upper integer
imat ceil_i(const mat &x) { return to_imat(ceil(x)); }

// Round to nearest lower integer
ivec floor_i(const vec &x) { return to_ivec(floor(x)); }
// Round to nearest lower integer
imat floor_i(const mat &x) { return to_imat(floor(x)); }


cvec round_to_zero(const cvec &x, double threshold)
{
  cvec temp(x.length());

  for (int i = 0; i < x.length(); i++)
    temp(i) = round_to_zero(x(i), threshold);

  return temp;
}

cmat round_to_zero(const cmat &x, double threshold)
{
  cmat temp(x.rows(), x.cols());

  for (int i = 0; i < x.rows(); i++) {
    for (int j = 0; j < x.cols(); j++) {
      temp(i, j) = round_to_zero(x(i, j), threshold);
    }
  }

  return temp;
}

cvec round_to_infty(const cvec &in, const double threshold)
{
  cvec temp(in.length());

  for (int i = 0; i < in.length(); i++)
    temp(i) = round_to_infty(in(i), threshold);

  return temp;
}

cmat round_to_infty(const cmat &in, const double threshold)
{
  cmat temp(in.rows(), in.cols());

  for (int i = 0; i < in.rows(); i++) {
    for (int j = 0; j < in.cols(); j++) {
      temp(i, j) = round_to_infty(in(i, j), threshold);
    }
  }

  return temp;
}

std::string to_str(const double &i, const int precision)
{
  std::ostringstream ss;
  ss.precision(precision);
  ss.setf(std::ostringstream::scientific, std::ostringstream::floatfield);
  ss << i;
  return ss.str();
}

// ----------------------------------------------------------------------
// Instantiations
// ----------------------------------------------------------------------

template bvec to_bvec(const svec &v);
template bvec to_bvec(const ivec &v);

template svec to_svec(const bvec &v);
template svec to_svec(const ivec &v);
template svec to_svec(const vec &v);

template ivec to_ivec(const bvec &v);
template ivec to_ivec(const svec &v);
template ivec to_ivec(const vec &v);

template vec to_vec(const bvec &v);
template vec to_vec(const svec &v);
template vec to_vec(const ivec &v);

template cvec to_cvec(const bvec &v);
template cvec to_cvec(const svec &v);
template cvec to_cvec(const ivec &v);
template cvec to_cvec(const vec &v);

template cvec to_cvec(const bvec &real, const bvec &imag);
template cvec to_cvec(const svec &real, const svec &imag);
template cvec to_cvec(const ivec &real, const ivec &imag);
template cvec to_cvec(const vec &real, const vec &imag);

template bmat to_bmat(const smat &m);
template bmat to_bmat(const imat &m);

template smat to_smat(const bmat &m);
template smat to_smat(const imat &m);
template smat to_smat(const mat &m);

template imat to_imat(const bmat &m);
template imat to_imat(const smat &m);
template imat to_imat(const mat &m);

template mat to_mat(const bmat &m);
template mat to_mat(const smat &m);
template mat to_mat(const imat &m);

template cmat to_cmat(const bmat &m);
template cmat to_cmat(const smat &m);
template cmat to_cmat(const imat &m);
template cmat to_cmat(const mat &m);

template cmat to_cmat(const bmat &real, const bmat &imag);
template cmat to_cmat(const smat &real, const smat &imag);
template cmat to_cmat(const imat &real, const imat &imag);
template cmat to_cmat(const mat &real, const mat &imag);

} // namespace itpp

//! \endcond

控制台输出:

Compile++ arm    : itpp <= converters.cpp

In file included from E:/hello-jni/jni/itpp/base/converters.cpp:30:0:
E:/hello-jni/jni/itpp/base/itcompat.h:77:12: error: expected unqualified-id before 'sizeof'
E:/hello-jni/jni/itpp/base/itcompat.h:77:12: error: expected ')' before 'sizeof'
E:/hello-jni/jni/itpp/base/itcompat.h:77:12: error: expected ')' before 'sizeof'
E:/hello-jni/jni/itpp/base/itcompat.h:96:12: error: expected unqualified-id before 'sizeof'
E:/hello-jni/jni/itpp/base/itcompat.h:96:12: error: expected ')' before 'sizeof'
E:/hello-jni/jni/itpp/base/itcompat.h:96:12: error: expected ')' before 'sizeof'
E:/hello-jni/jni/itpp/base/itcompat.h:104:12: error: expected unqualified-id before 'sizeof'
E:/hello-jni/jni/itpp/base/itcompat.h:104:12: error: expected ')' before 'sizeof'
E:/hello-jni/jni/itpp/base/itcompat.h:104:12: error: expected ')' before 'sizeof'
/cygdrive/e/Soft/android-ndk-r7b/build/core/build-binary.mk:249: recipe for target `obj/local/armeabi-v7a/objs-debug/itpp/itpp/base/converters.o' failed
make: *** [obj/local/armeabi-v7a/objs-debug/itpp/itpp/base/converters.o] Error 1

您能针对我的问题给我一些建议吗?我是 android-ndk 的新手。 非常感谢您的帮助!

最佳答案

原因是您将 isinf 定义为宏。稍后,您将尝试使用该名称定义一个函数。

你应该注意到宏在词法分析器工作时扩展(或者甚至作为在此之前的一个 channel )。这意味着它在不了解解析正确性的情况下扩展宏,更不用说上下文了。这就是为什么即使您在命名空间中声明了一个函数,词法分析器也无法理解它并且无论如何都将函数名称作为宏。

要解决此问题,您需要确保 itcompat.h 未定义 isinf。从头文件的外观来看,似乎需要定义 HAVE_STD_ISINF。拥有 HAVE_DECL_ISINF 是不够的,因为在那种情况下 isinf 仍在 itcompat.h 中声明。我的猜测是,如果您在 itcompat.h 之前包含 math.h,它将定义 HAVE_STD_ISINF 本身。

关于c++ - GCC - 'sizeof' 之前的预期不合格 ID - Android NDK 中的 IT++ 4.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9886725/

有关c++ - GCC - 'sizeof' 之前的预期不合格 ID - Android NDK 中的 IT++ 4.2的更多相关文章

  1. ruby-on-rails - rails : "missing partial" when calling 'render' in RSpec test - 2

    我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou

  2. ruby-on-rails - 'compass watch' 是如何工作的/它是如何与 rails 一起使用的 - 2

    我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t

  3. ruby - 为什么 4.1%2 使用 Ruby 返回 0.0999999999999996?但是 4.2%2==0.2 - 2

    为什么4.1%2返回0.0999999999999996?但是4.2%2==0.2。 最佳答案 参见此处:WhatEveryProgrammerShouldKnowAboutFloating-PointArithmetic实数是无限的。计算机使用的位数有限(今天是32位、64位)。因此计算机进行的浮点运算不能代表所有的实数。0.1是这些数字之一。请注意,这不是与Ruby相关的问题,而是与所有编程语言相关的问题,因为它来自计算机表示实数的方式。 关于ruby-为什么4.1%2使用Ruby返

  4. ruby-on-rails - Rails 3.2.1 中 ActionMailer 中的未定义方法 'default_content_type=' - 2

    我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。=>BootingWEBrick=>Rails3.2.1applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Callwith-dtodetach=>Ctrl-CtoshutdownserverExiting/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer

  5. ruby-on-rails - 如何优雅地重启 thin + nginx? - 2

    我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server

  6. ruby - 在 jRuby 中使用 'fork' 生成进程的替代方案? - 2

    在MRIRuby中我可以这样做:deftransferinternal_server=self.init_serverpid=forkdointernal_server.runend#Maketheserverprocessrunindependently.Process.detach(pid)internal_client=self.init_client#Dootherstuffwithconnectingtointernal_server...internal_client.post('somedata')ensure#KillserverProcess.kill('KILL',

  7. ruby-on-rails - 无法在centos上安装therubyracer(V8和GCC出错) - 2

    我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e

  8. ruby - 主要 :Object when running build from sublime 的未定义方法 `require_relative' - 2

    我已经从我的命令行中获得了一切,所以我可以运行rubymyfile并且它可以正常工作。但是当我尝试从sublime中运行它时,我得到了undefinedmethod`require_relative'formain:Object有人知道我的sublime设置中缺少什么吗?我正在使用OSX并安装了rvm。 最佳答案 或者,您可以只使用“require”,它应该可以正常工作。我认为“require_relative”仅适用于ruby​​1.9+ 关于ruby-主要:Objectwhenrun

  9. ruby-on-rails - rails : save file from URL and save it to Amazon S3 - 2

    从给定URL下载文件并立即将其上传到AmazonS3的更直接的方法是什么(+将有关文件的一些信息保存到数据库中,例如名称、大小等)?现在,我既不使用Paperclip,也不使用Carrierwave。谢谢 最佳答案 简单明了:require'open-uri'require's3'amazon=S3::Service.new(access_key_id:'KEY',secret_access_key:'KEY')bucket=amazon.buckets.find('image_storage')url='http://www.ex

  10. ruby - 无法让 RSpec 工作—— 'require' : cannot load such file - 2

    我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳

随机推荐