Home Php C# Sql C C++ Javascript Python Java Go Android Git Linux Asp.net Django .net Node.js Ios Xcode Cocoa Iphone Mysql Tomcat Mongodb Bash Objective-c Scala Visual-studio Apache Elasticsearch Jar Eclipse Jquery Ruby-on-rails Ruby Rubygems Android-studio Spring Lua Sqlite Emacs Ubuntu Perl Docker Swift Amazon-web-services Svn Html Ajax Xml Java-ee Maven Intellij-idea Rvm Macos Unix Css Ipad Postgresql Css3 Json Windows-server Vue.js Typescript Oracle Hibernate Internet-explorer Github Tensorflow Laravel Symfony Redis Html5 Google-app-engine Nginx Firefox Sqlalchemy Lucene Erlang Flask Vim Solr Webview Facebook Zend-framework Virtualenv Nosql Ide Twitter Safari Flutter Bundle Phonegap Centos Sphinx Actionscript Tornado Register | Login | Edit Tags | New Questions | 繁体 | 简体


10 questions online user: 6

0
votes
answers
57 views
+10

OpenSSL BN_exp()用法

0

我有一個小程序,它在64字節的大整數(通過BN_generate_prime_ex()生成)上使用BIGNUM函數BN_exp()和BN_mod_exp()。OpenSSL BN_exp()用法

每次我編譯並運行時,程序會在計算第??一次調用BN_exp()時永遠暫停。我知道問題是BN_exp(),因爲我在函數調用之前和之後都有打印語句。我對計算BN_exp()時程序停滯的原因感到困惑。 64字節的大整數對於函數來說太大了嗎?計算是否花了很長時間?任何幫助表示讚賞。

目標:計算(bn_one^bn_two)*(bn_two^bn_one)mod bn_mod。我的方式是不正確的,所以關於如何計算這個的任何建議都會很棒。

這裏是我的程序:

#include <stdio.h> 

/* OpenSSL headers */ 
#include <openssl/bn.h> 

void main() 
{ 
    BIGNUM *bn_one, *bn_two, *bn_one2two, *bn_two2one, *bn_mod, *bn_result; 
    BN_CTX *ctx; /* used internally by the bignum lib */ 

    ctx = BN_CTX_new(); 
    bn_one = BN_new(); 
    bn_two = BN_new(); 
    bn_one2two = BN_new(); 
    bn_two2one = BN_new(); 
    bn_mod = BN_new(); 
    bn_result = BN_new(); 

    // Generate two 64 byte integers 
    BN_generate_prime_ex(bn_one,512,0,NULL,NULL,NULL); 
    BN_generate_prime_ex(bn_two,512,0,NULL,NULL,NULL); 
    BN_generate_prime_ex(bn_mod,512,0,NULL,NULL,NULL); 

    printf("BIGNUM One:	"); 
    BN_print_fp(stdout, bn_one); 
    printf("
"); 

    printf("BIGNUM Two:	"); 
    BN_print_fp(stdout, bn_two); 
    printf("
"); 

    // Compute bn_one to the power of bn_two and store in bn_one2two 
    if(BN_exp(bn_one2two , bn_one , bn_two, ctx) == 0) { 
     printf("Error in BN_exp
"); 
    } 

    printf("BIGNUM One2Two:	
"); 
    BN_print_fp(stdout, bn_one2two); 
    printf("
"); 

    // Compute bn_two to the power of bn_one and store in bn_two2one 
    if(BN_exp(bn_two2one , bn_two , bn_one, ctx) == 0) { 
     printf("Error in BN_exp
"); 
    } 

    printf("BIGNUM Two2One:	
"); 
    BN_print_fp(stdout, bn_two2one); 
    printf("
"); 

    // Compute bn_one2two * bn_two2one mod bn_mod and store the remainder in 
    //bn_result 
    if(BN_mod_mul(bn_result , bn_one2two , bn_two2one, bn_mod , ctx) == 0) { 
     printf("Error in BN_mod_exp
"); 
    } 
    printf("BIGNUM Mod Result:	
"); 
    BN_print_fp(stdout, bn_result); 
    printf("
"); 

    BN_CTX_free(ctx); 
    BN_clear_free(bn_one); 
    BN_clear_free(bn_two); 
    BN_clear_free(bn_one2two); 
    BN_clear_free(bn_two2one); 
    BN_clear_free(bn_mod); 
    BN_clear_free(bn_result); 
} 

程序攤位前,我的輸出(這64個字節的值,每次運行時更改):

BIGNUM一:CE06C8663AB65AA2BF7C6B30273C5E002552CFB8548A6B8EC7204A23F6A8892FEA9EF315777660C5B4FD97EABB7703FCFB5B1C2D495A1863B5F9D290F72CF8A5

BIGNUM二:CB4A929D982670B77F2544E7D5A990DEE76958CBEC5BEB638B8DA9D44880C46817D1D7616C58AF79378215368C76962FA88D08A215331019599945CAF933E417

+0

除非我誤會,否則結果將有512 * 2^512個二進制數字。這比適合任何計算機內存。 –

+0

我的目標是計算(bn_one^bn_two)*(bn_two^bn_one)mod bn_one,所以關於如何計算這個比我當前的方法更多的建議?謝謝。 –

+0

bn_one^bn_two是bn_one的倍數,所以結果應該爲零。 –

沙发
0
0

我想出瞭如何正確計算(bn_one^bn_two)*(bn_one^bn_one)mod bn_mod:https://github.com/maK-/Digital-Signature-ElGamal/blob/master/Crypto2.java

以前,我是這樣計算的:bn_one^bn_two上的BN_exp,bn_two^bn_one上的BN_exp,bn_mod上的兩個結果上的BN_mod。

這些數字太大而無法用這種方式處理。用於BIGNUM的計算流程如下:bn_one上的BN_mod_exp()bn_mod上的bn_two,bn_two上的BN_mod_exp()bn_mod上的bn_one,上一個BN_mod_exp()計算結果上的BN_mul(),以及最後用BN_mod()對BN_mul()的結果與bn_mod進行比較。

板凳
0
1

你說你想要計算(bn_one2two * bn_two2one) mod bn_one,但是你正在使用BN_mod_exp函數,它將做(bn_one2two^bn_two2one) mod bn_one,即它首先試圖取指數而不是乘兩個數。改爲嘗試BN_mod_mul

+0

我的另一個錯誤。我相應地更新了代碼。謝謝。計算BN_exp()時,我的程序繼續失速。正如馬丁指出的那樣,我認爲這個問題是因爲我正在處理64字節整數,所以我在內存中存儲了太多的數字。 –

0
votes
answers
38 views
+10

Ruby on Rails,coffescript中的內化

0

我有一個coffeescript文件用於我的資源之一。看起來內部化在我的coffescript文件中無法正常工作。我希望I18 gem轉換'select'腳本,但它不起作用。Ruby on Rails,coffescript中的內化

的CoffeeScript:

console.log('employee loaded -> '+"<%= I18n.t 'select' %>") 

當我打開瀏覽器控制檯我結束了這樣的文字:

employee loaded -> <%= I18n.t 'select' %> 

en.yml

en: 
    select: 'Select...' 

tr.yml

tr: 
    select: 'Seçiniz...' 

任何建議,

謝謝。

沙发
0
0

也許你忘了添加擴展程序? filename.coffee。 erb

0
votes
answers
29 views
+10

GDB能否從xx.so解析全局數據而不執行?

2

我有一個共享庫(hlapi.so)在Linux系統上運行。這hlapi.so有很多模塊(我的意思是.c文件)。其中一個被命名爲hlapi.c定義這樣的兩個全球DATAS:GDB能否從xx.so解析全局數據而不執行?

static int hlapiInitialized = FALSE; 
static struct hlapi_data app_sp; 

當然也有這個hlapi.c模塊在其他許多代碼。 hlapi.so發佈給基於我們的hlapi.so構建自己的應用程序(名爲appbasehlapi)的客戶。

現在我得到了一個核心轉儲,其客戶解析的回溯顯示核心位於我們的代碼中。但客戶只能向我們提供核心轉儲文件。 appbasehlapi可執行文件不會與我們共享。所以在我的手中,我只有核心轉儲文件+ hlapi.so。

爲了調試這個核心,由我指揮

gdb --core=mycoredumpfile 

裝入核心轉儲文件,然後在gdb,我用

set solib-search-path . 

指定包含hlapi.so這樣的文件夾gdb可以從hlapi.so加載符號。然後我使用:

print hlapiInitialized 
print app_sp 

解析模塊中的全局數據。但是輸出值非常不正常。

我在這裏的問題是,如果我可以解析全局數據通過gdb中定義的hlapi.so沒有可執行文件?如果我通過gdb獲得的輸出是可信的? 我很欣賞任何評論。

順便說一句,hlapi.so是用gcc選項「-g -fPIC」構建的。

+0

是否知道核心轉儲是否由您正在用於調試的庫的_exact_相同版本生成? – duskwuff

+0

@duskwuff,是的。它與我們發佈給客戶的hlapi.so版本相同。 –

沙发
0
0

我調查了一段時間的問題,在我看來,我相信GDB可以在沒有可執行文件的情況下解析全局變量。

在測試中,將以下代碼在hlapi.cpp:

static int hlapiInitialized = 0; 

void hlapiInit() 
{ 
    if (hlapiInitialized == 0) 
    { 
     // do something else 
    } 

    hlapiInitialized = 1; 
} 

的objdump顯示組件的代碼,它是:

00000000000009a2 <_Z9hlapiInitv>: 
9a2: 55      push %rbp 
9a3: 48 89 e5    mov %rsp,%rbp 
9a6: c7 05 98 06 20 00 01 movl $0x1,0x200698(%rip) # 201048 <_ZL16hlapiInitialized> 
9ad: 00 00 00 
9b0: 90      nop 
9b1: 5d      pop %rbp 
9b2: c3      retq 

在運行的應用程序,我生成核心傾倒它。在GDB,指定solib搜索路徑之前,我得到:

(gdb) disas hlapiInit 
No symbol table is loaded. Use the "file" command. 

一旦指定的搜索路徑,輸出是:

(gdb) disas hlapiInit 
Dump of assembler code for function hlapiInit(): 
    0x00007ffff7bd59a2 <+0>: push %rbp 
    0x00007ffff7bd59a3 <+1>: mov %rsp,%rbp 
    0x00007ffff7bd59a6 <+4>: movl $0x1,0x200698(%rip)  # 0x7ffff7dd6048 <_ZL16hlapiInitialized> 
    0x00007ffff7bd59b0 <+14>: nop 
    0x00007ffff7bd59b1 <+15>: pop %rbp 
    0x00007ffff7bd59b2 <+16>: retq 
End of assembler dump. 

輸出從hlapi.so和比較後,核心文件,我們知道一旦共享庫已經加載到進程中,全局變量的地址將被重新分配,並且全局變量的地址是清楚的。因此,一旦擁有共享庫的符號信息,gdb就可以映射這些變量。

0
votes
answers
65 views
+10

如何控制分配的內存是否存儲在L1,L2,L3緩存或其他JavaScript中?

0

L1高速緩存的速度比L2快等等等等。如何控制內存分配到哪裏在JavaScript中?如何看到內存分配到哪裏?如何控制分配的內存是否存儲在L1,L2,L3緩存或其他JavaScript中?

我明白是最有可能不可能的。我以這種方式提出問題以避免布爾問題。

+0

JavaScript沒有提供控制此方法的方法。 – Xufox

沙发
0
1

一個不控制JavaScript中的內存分配。

此外,緩存應該是透明的,它們是由硬件自動管理的。你只是分配內存,而不是具體的緩存內存,當你使用它時,它會被緩存。即使在低級語言中,您也很難手動控制此操作。

0
votes
answers
54 views
+10

堆損壞 - 調試斷言失敗。在dbgheap.c行1322表達式_crtIsValidHeapPointer(pUserData)

1

在運行時我得到調試斷言失敗。堆損壞 - 調試斷言失敗。在dbgheap.c行1322表達式_crtIsValidHeapPointer(pUserData)

in dbgheap.c line 1322 expression _crtIsValidHeapPointer(pUserData) 

如果我在一個調試器中運行,我會得到如下所示的一行觸發的斷點。

我該如何解決這個分配/解除分配錯誤?

我有在頭文件2層的功能:

struct union_find_t; 

struct union_find_t* union_find_init(int n); 

void union_find_free(struct union_find_t* uf); 

和.c文件執行對這些2個功能是:

typedef struct union_find_t { 
    int* parent; 
    int* rank; 
    int components; 
} *union_find_t; 


struct union_find_t* union_find_init(int n) { 

    struct union_find_t* uf = malloc(sizeof(union_find_t)); 
    uf->parent = malloc(n * sizeof(int)); 
    uf->rank = malloc(n * sizeof(int)); 
    uf->components = n; 
    for (int i = 0; i < n; ++i) { 
     uf->parent[i] = i; 
     uf->rank[i] = 0; 
    } 
    return uf; 
} 

void union_find_free(struct union_find_t* uf) { 
    free(uf->parent); 
    free(uf->rank); 
    free(uf); //*** breakpoint triggered here 
} 
+0

你可以嘗試運行沒有'free(uf-> parent)的程序嗎? free(uf-> rank);'並檢查錯誤是否再次出現.. –

+1

'union_find_t;'是一個指針的typedef,所以'malloc(sizeof(union_find_t));'只是爲指針分配空間,並且不適用於結構。看起來你應該從typedef中移除'*'。 –

+0

@BoPersson - 實際上你的解決方案可能會更好。儘管typedef struct union_find_t int * parent; int * rank; int組件; } union_find_t;看起來有點奇怪 –

沙发
0
1

此:

typedef struct union_find_t 

是一個typedef用於:

*union_find_t; 

所以,當你這樣做:

malloc(sizeof(union_find_t)); 

你只是分配空間指針到結構,而不是因爲你需要一個結構!

嘗試用:

malloc(sizeof(struct union_find_t)); 

代替。

+1

這是棘手和微妙的 - 謝謝! –

0
votes
answers
61 views
+10

在Ubuntu服務器中部署AspNet核心問題

0

我在Ubuntu服務器(16.04.1 LTS(GNU/Linux 4.4.0-97-generic x86_64))中提供了幾個aspnet核心應用程序,這些應用程序總是工作得很好,它們是webapi配置非常類似,但昨天我有一個問題發佈其中之一(只有一個像魅力其他工作),我收到一個錯誤,說實話我不明白主要是因爲我不記得做過任何與錯誤信息相關的變化,我浪費了很多小時,而且我會瘋狂。我最近將aspnet核心版本從1.1升級到2.0。在Ubuntu服務器中部署AspNet核心問題

這是我的Program.cs

public class Program 
{ 
    public static void Main(string[] args) 
    { 
     Console.Title = "Webtools Service"; 

     BuildWebHost(args).Run(); 
    } 

    public static IWebHost BuildWebHost(string[] args) 
    { 
     var config = new ConfigurationBuilder() 
      .SetBasePath(Directory.GetCurrentDirectory()) 
      .AddJsonFile("hosting.json", true) 
      .Build(); 

     return WebHost.CreateDefaultBuilder(args) 
      .UseKestrel() 
      .UseConfiguration(config) 
      .ConfigureAppConfiguration((hostContext, conf) => 
      { 
       var env = hostContext.HostingEnvironment; 
       // delete all default configuration providers 
       conf.Sources.Clear(); 
       conf.SetBasePath(env.ContentRootPath); 
       conf.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); 
       conf.AddJsonFile("appsettings.local.overrides.json", optional: true); 
       conf.AddEnvironmentVariables(); 
      }) 
      .UseContentRoot(Directory.GetCurrentDirectory()) 
      .UseIISIntegration() 
      .UseStartup<Startup>() 
      //.UseApplicationInsights() 
      .Build(); 
    } 
} 

我附上錯誤跟蹤:

> info: 
> Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0] 
>  User profile is available. Using '/home/ubuntu/.aspnet/DataProtection-Keys' as key repository; keys 
> will not be encrypted at rest. Application startup exception: 
> System.PlatformNotSupportedException: Windows Principal functionality 
> is not supported on this platform. at 
> System.Security.Principal.WindowsIdentity.GetCurrent() at 
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation.ApplicationFolderProvider..ctor(IDictionary 
> environment, String folderName) at 
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation.Transmitter.Initialize() 
> at 
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel.Initialize(TelemetryConfiguration 
> configuration) at 
> Microsoft.Extensions.DependencyInjection.TelemetryConfigurationOptionsSetup.Configure(TelemetryConfiguration 
> configuration) at 
> Microsoft.Extensions.DependencyInjection.TelemetryConfigurationOptions..ctor(IEnumerable`1 
> configureOptions) 
> --- End of stack trace from previous location where exception was thrown --- at 
> System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite 
> constructorCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite 
> scopedCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite 
> singletonCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.<RealizeService>b__0(ServiceProvider 
> provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type 
> serviceType) at 
> Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider 
> provider) at 
> Microsoft.Extensions.DependencyInjection.ApplicationInsightsExtensions.<>c.<AddApplicationInsightsTelemetry>b__13_1(IServiceProvider 
> provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite 
> factoryCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite 
> scopedCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite 
> singletonCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite 
> constructorCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite 
> scopedCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite 
> singletonCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite 
> constructorCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite 
> scopedCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite 
> singletonCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite 
> enumerableCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite 
> constructorCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite 
> scopedCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite 
> singletonCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.<RealizeService>b__0(ServiceProvider 
> provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type 
> serviceType) at 
> Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider 
> provider) at 
> Microsoft.ApplicationInsights.AspNetCore.ApplicationInsightsStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder 
> app) at 
> Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() crit: 
> Microsoft.AspNetCore.Hosting.Internal.WebHost[6] 
>  Application startup exception System.PlatformNotSupportedException: Windows Principal functionality 
> is not supported on this platform. at 
> System.Security.Principal.WindowsIdentity.GetCurrent() at 
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation.ApplicationFolderProvider..ctor(IDictionary 
> environment, String folderName) at 
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation.Transmitter.Initialize() 
> at 
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel.Initialize(TelemetryConfiguration 
> configuration) at 
> Microsoft.Extensions.DependencyInjection.TelemetryConfigurationOptionsSetup.Configure(TelemetryConfiguration 
> configuration) at 
> Microsoft.Extensions.DependencyInjection.TelemetryConfigurationOptions..ctor(IEnumerable`1 
> configureOptions) 
> --- End of stack trace from previous location where exception was thrown --- at 
> System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite 
> constructorCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite 
> scopedCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite 
> singletonCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.<RealizeService>b__0(ServiceProvider 
> provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type 
> serviceType) at 
> Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider 
> provider) at 
> Microsoft.Extensions.DependencyInjection.ApplicationInsightsExtensions.<>c.<AddApplicationInsightsTelemetry>b__13_1(IServiceProvider 
> provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite 
> factoryCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite 
> scopedCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite 
> singletonCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite 
> constructorCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite 
> scopedCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite 
> singletonCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite 
> constructorCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite 
> scopedCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite 
> singletonCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite 
> enumerableCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite 
> constructorCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite 
> scopedCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite 
> singletonCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.<RealizeService>b__0(ServiceProvider 
> provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type 
> serviceType) at 
> Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider 
> provider) at 
> Microsoft.ApplicationInsights.AspNetCore.ApplicationInsightsStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder 
> app) at 
> Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() 
> 
> Unhandled Exception: System.PlatformNotSupportedException: Windows 
> Principal functionality is not supported on this platform. at 
> System.Security.Principal.WindowsIdentity.GetCurrent() at 
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation.ApplicationFolderProvider..ctor(IDictionary 
> environment, String folderName) at 
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation.Transmitter.Initialize() 
> at 
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel.Initialize(TelemetryConfiguration 
> configuration) at 
> Microsoft.Extensions.DependencyInjection.TelemetryConfigurationOptionsSetup.Configure(TelemetryConfiguration 
> configuration) at 
> Microsoft.Extensions.DependencyInjection.TelemetryConfigurationOptions..ctor(IEnumerable`1 
> configureOptions) 
> --- End of stack trace from previous location where exception was thrown --- at 
> System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite 
> constructorCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite 
> scopedCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite 
> singletonCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.<RealizeService>b__0(ServiceProvider 
> provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type 
> serviceType) at 
> Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider 
> provider) at 
> Microsoft.Extensions.DependencyInjection.ApplicationInsightsExtensions.<>c.<AddApplicationInsightsTelemetry>b__13_1(IServiceProvider 
> provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite 
> factoryCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite 
> scopedCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite 
> singletonCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite 
> constructorCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite 
> scopedCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite 
> singletonCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite 
> constructorCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite 
> scopedCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite 
> singletonCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite 
> enumerableCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite 
> constructorCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite 
> scopedCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite 
> singletonCallSite, ServiceProvider provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite 
> callSite, TArgument argument) at 
> Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.<RealizeService>b__0(ServiceProvider 
> provider) at 
> Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type 
> serviceType) at 
> Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider 
> provider) at 
> Microsoft.ApplicationInsights.AspNetCore.ApplicationInsightsStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder 
> app) at 
> Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() at 
> Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at 
> WebtoolsService.Program.BuildWebHost(String[] args) in 
> /var/NetWebApps/sources/Program.cs:line 26 at 
> WebtoolsService.Program.Main(String[] args) in 
> /var/NetWebApps/sources/Program.cs:line 16 
沙发
0
0

我發現這個問題是由ApplicationInsights引起我更新到版本2.2.0-β1,並根據到https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/551它有一個導致平臺問題的錯誤,我剛剛安裝了版本2.1.1並解決了這個問題。

<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" /> 
0
votes
answers
62 views
+10

我正在嘗試在紅寶石中安裝OpenGraph寶石

0

我搜索了整個網絡尋找解決此錯誤的方法。但它不會讓步。根據我的知識,我安裝了所有的庫和依賴項,甚至卸載了ruby和nokogiri並重新安裝。但是這個錯誤仍然存??在。 我正在嘗試在紅寶石中安裝OpenGraph寶石

Gem files will remain installed in /home/$User/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/nokogiri-1.4.7 for inspection. 
 
Results logged to /home/$User/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/nokogiri-1.4.7/gem_make.out

這是從這個位置gem_make.out日誌文件 - > /.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/extensions/x86_64-linux/ 2.4.0靜電/引入nokogiri-1.4.7/gem_make.out

ERROR: Error installing opengraph: 
 
	 ERROR: Failed to build gem native extension. 
 

 
    current directory: /home/$User/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/nokogiri-1.4.7/ext/nokogiri 
 
/home/$User/.rbenv/versions/2.4.2/bin/ruby -r ./siteconf20171125-15877-nibcps.rb extconf.rb --with-nokogiri-dir=/home/$User/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/ 
 
*** extconf.rb failed *** 
 
Could not create Makefile due to some reason, probably lack of necessary 
 
libraries and/or headers. Check the mkmf.log file for more details. You may 
 
need configuration options. 
 

 
Provided configuration options: 
 
	 --with-opt-dir 
 
	 --without-opt-dir 
 
	 --with-opt-include 
 
	 --without-opt-include=${opt-dir}/include 
 
	 --with-opt-lib 
 
	 --without-opt-lib=${opt-dir}/lib 
 
	 --with-make-prog 
 
	 --without-make-prog 
 
	 --srcdir=. 
 
	 --curdir 
 
	 --ruby=/home/$User/.rbenv/versions/2.4.2/bin/$(RUBY_BASE_NAME) 
 
extconf.rb:10:in `<main>': uninitialized constant Config (NameError) 
 
Did you mean? RbConfig 
 
       CONFIG 
 

 
extconf failed, exit code 1
我會很感激你,如果你能告訴我什麼是錯的。這是OpenGraph中的錯誤嗎?

P.S:我沒有使用opengraph_parser,因爲它有一個回退方法。我需要opengraph寶石,因爲我需要捕捉異常。

沙发
0
0

它不是opengraph,而是nokogiri。

Nokogiri是opengraph的依賴項。 https://rubygems.org/gems/opengraph/versions/0.0.4

因此,它必須在您的機器上沒有支持nokogiri(libxml2)所需的依賴關係。

安裝你的機器上,這些依賴關係(上於Debian/Ubuntu假設你):

sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev 

的Fedora /紅帽/ CentOS的:

sudo yum install -y gcc ruby-devel zlib-devel 
sudo yum install -y rubygem-nokogiri (alternative) 

然後嘗試通過gem install nokogiri安裝引入nokogiri

對於其他變體或操作系統: http://www.nokogiri.org/tutorials/installing_nokogiri.html

於Fedora 26: 直至另行通知,安裝引入nokogiri版本< 1.8

+0

Hi..thanks的答覆。但我使用的是Fedora 26.你能告訴我Fedora或任何Redhat的類似依賴嗎? – Meimo

+0

@Meimo ruby??-devel zlib-devel。更新了我的答案。 – jemonsanto

+0

感謝您再次回覆,但我試圖安裝這些依賴關係時...終端說「已安裝,無事可做」。看到我告訴你,根據我的知識安裝一切。但它只是不會安裝。我認爲這是一個錯誤。 – Meimo

0
votes
answers
64 views
+10

在軌道上安裝寶石,紅寶石。使用JSON錯誤

0

我目前正試圖創建具有軌道新的應用程序,希望在我的應用程序目錄下安裝寶石,得到了以下信息:在軌道上安裝寶石,紅寶石。使用JSON錯誤

[email protected]:/dev/movies-forum# bundle install --path vendor/bundle 
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and 
installing your bundle as root will break this application for all non-root 
users on this machine. 
Fetching gem metadata from https://rubygems.org/........... 
Fetching version metadata from https://rubygems.org/... 
Fetching dependency metadata from https://rubygems.org/.. 
Resolving dependencies.... 
Installing rake 12.3.0 
Installing concurrent-ruby 1.0.5 
Installing json 1.8.6 with native extensions 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    current directory: /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/json-1.8.6/ext/json/ext/generator 
/usr/bin/ruby2.3 -r ./siteconf20171125-3993-154eb9h.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/json-1.8.6 for inspection. 
Results logged to /dev/movies-forum/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/json-1.8.6/gem_make.out 
Installing minitest 5.10.3 
Installing thread_safe 0.3.6 
Installing builder 3.2.3 
Installing erubis 2.7.0 
Installing mini_portile2 2.3.0 
Installing crass 1.0.3 
Installing rack 1.6.8 
Installing mini_mime 1.0.0 
Installing arel 6.0.4 
Installing debug_inspector 0.0.3 with native extensions 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    current directory: /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/debug_inspector-0.0.3/ext/debug_inspector 
/usr/bin/ruby2.3 -r ./siteconf20171125-3993-1n3hl3h.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/debug_inspector-0.0.3 for inspection. 
Results logged to /dev/movies-forum/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/debug_inspector-0.0.3/gem_make.out 
Using bundler 1.11.2 
Installing byebug 9.1.0 with native extensions 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    current directory: /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/byebug-9.1.0/ext/byebug 
/usr/bin/ruby2.3 -r ./siteconf20171125-3993-g49k1z.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/byebug-9.1.0 for inspection. 
Results logged to /dev/movies-forum/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/byebug-9.1.0/gem_make.out 
Installing coffee-script-source 1.12.2 
Installing execjs 2.7.0 
Installing thor 0.20.0 
Installing ffi 1.9.18 with native extensions 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    current directory: /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/ext/ffi_c 
/usr/bin/ruby2.3 -r ./siteconf20171125-3993-yzalv6.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18 for inspection. 
Results logged to /dev/movies-forum/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.18/gem_make.out 
Installing multi_json 1.12.2 
Installing rb-fsevent 0.10.2 
Installing rdoc 4.3.0 
Installing tilt 2.0.8 
Installing sqlite3 1.3.13 with native extensions 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    current directory: /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/sqlite3-1.3.13/ext/sqlite3 
/usr/bin/ruby2.3 -r ./siteconf20171125-3993-1y1q30j.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/sqlite3-1.3.13 for inspection. 
Results logged to /dev/movies-forum/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/gem_make.out 
Installing turbolinks-source 5.0.3 
Installing i18n 0.9.1 
An error occurred while installing json (1.8.6), and Bundler cannot continue. 
Make sure that `gem install json -v '1.8.6'` succeeds before bundling. 
[email protected]:/dev/movies-forum# gem install json -v '1.8.6' 
Fetching: json-1.8.6.gem (100%) 
Building native extensions. This could take a while... 
ERROR: Error installing json: 
    ERROR: Failed to build gem native extension. 

    current directory: /var/lib/gems/2.3.0/gems/json-1.8.6/ext/json/ext/generator 
/usr/bin/ruby2.3 -r ./siteconf20171125-4056-c2r6jm.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /var/lib/gems/2.3.0/gems/json-1.8.6 for inspection. 
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/json-1.8.6/gem_make.out 
[email protected]:/dev/movies-forum# which bundler 
/usr/bin/bundler 
[email protected]:/dev/movies-forum# gem install bundler && rbenv rehash 
Fetching: bundler-1.16.0.gem (100%) 
Successfully installed bundler-1.16.0 
Parsing documentation for bundler-1.16.0 
Installing ri documentation for bundler-1.16.0 
Done installing documentation for bundler after 4 seconds 
1 gem installed 
Program rbenv nie jest obecnie zainstalowany. Mo?esz go zainstalowa? wpisuj?c: 
apt install rbenv 
[email protected]:/dev/movies-forum# bundle install --path vendor/bundle 
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and 
installing your bundle as root will break this application for all non-root 
users on this machine. 
Fetching gem metadata from https://rubygems.org/........... 
Fetching version metadata from https://rubygems.org/... 
Fetching dependency metadata from https://rubygems.org/.. 
Resolving dependencies.... 
Using rake 12.3.0 
Using concurrent-ruby 1.0.5 
Installing json 1.8.6 with native extensions 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    current directory: /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/json-1.8.6/ext/json/ext/generator 
/usr/bin/ruby2.3 -r ./siteconf20171125-4146-njwwhh.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/json-1.8.6 for inspection. 
Results logged to /dev/movies-forum/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/json-1.8.6/gem_make.out 
Using minitest 5.10.3 
Using thread_safe 0.3.6 
Using builder 3.2.3 
Using erubis 2.7.0 
Using mini_portile2 2.3.0 
Using crass 1.0.3 
Using rack 1.6.8 
Using mini_mime 1.0.0 
Using arel 6.0.4 
Installing debug_inspector 0.0.3 with native extensions 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    current directory: /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/debug_inspector-0.0.3/ext/debug_inspector 
/usr/bin/ruby2.3 -r ./siteconf20171125-4146-r39wqa.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/debug_inspector-0.0.3 for inspection. 
Results logged to /dev/movies-forum/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/debug_inspector-0.0.3/gem_make.out 
Using bundler 1.11.2 
Installing byebug 9.1.0 with native extensions 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    current directory: /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/byebug-9.1.0/ext/byebug 
/usr/bin/ruby2.3 -r ./siteconf20171125-4146-16t55au.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/byebug-9.1.0 for inspection. 
Results logged to /dev/movies-forum/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/byebug-9.1.0/gem_make.out 
Using coffee-script-source 1.12.2 
Using execjs 2.7.0 
Using thor 0.20.0 
Installing ffi 1.9.18 with native extensions 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    current directory: /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/ext/ffi_c 
/usr/bin/ruby2.3 -r ./siteconf20171125-4146-ngcier.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18 for inspection. 
Results logged to /dev/movies-forum/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.18/gem_make.out 
Using multi_json 1.12.2 
Using rb-fsevent 0.10.2 
Using rdoc 4.3.0 
Using tilt 2.0.8 
Installing sqlite3 1.3.13 with native extensions 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    current directory: /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/sqlite3-1.3.13/ext/sqlite3 
/usr/bin/ruby2.3 -r ./siteconf20171125-4146-9yhg8k.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/sqlite3-1.3.13 for inspection. 
Results logged to /dev/movies-forum/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/gem_make.out 
Using turbolinks-source 5.0.3 
Using i18n 0.9.1 
An error occurred while installing json (1.8.6), and Bundler cannot continue. 
Make sure that `gem install json -v '1.8.6'` succeeds before bundling. 
[email protected]:/dev/movies-forum# 
[email protected]:/dev/movies-forum# gem bundler install 
ERROR: While executing gem ... (Gem::CommandLineError) 
    Unknown command bundler 
[email protected]:/dev/movies-forum# sudo gem install bundler 
Successfully installed bundler-1.16.0 
Parsing documentation for bundler-1.16.0 
Done installing documentation for bundler after 3 seconds 
1 gem installed 
[email protected]:/dev/movies-forum# bundle install --path vendor/bundle 
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and 
installing your bundle as root will break this application for all non-root 
users on this machine. 
Fetching gem metadata from https://rubygems.org/........... 
Fetching version metadata from https://rubygems.org/... 
Fetching dependency metadata from https://rubygems.org/.. 
Resolving dependencies.... 
Using rake 12.3.0 
Using concurrent-ruby 1.0.5 
Installing json 1.8.6 with native extensions 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    current directory: /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/json-1.8.6/ext/json/ext/generator 
/usr/bin/ruby2.3 -r ./siteconf20171125-4191-1krkby3.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/json-1.8.6 for inspection. 
Results logged to /dev/movies-forum/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/json-1.8.6/gem_make.out 
Using minitest 5.10.3 
Using thread_safe 0.3.6 
Using builder 3.2.3 
Using erubis 2.7.0 
Using mini_portile2 2.3.0 
Using crass 1.0.3 
Using rack 1.6.8 
Using mini_mime 1.0.0 
Using arel 6.0.4 
Installing debug_inspector 0.0.3 with native extensions 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    current directory: /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/debug_inspector-0.0.3/ext/debug_inspector 
/usr/bin/ruby2.3 -r ./siteconf20171125-4191-3mbadh.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/debug_inspector-0.0.3 for inspection. 
Results logged to /dev/movies-forum/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/debug_inspector-0.0.3/gem_make.out 
Using bundler 1.11.2 
Installing byebug 9.1.0 with native extensions 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    current directory: /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/byebug-9.1.0/ext/byebug 
/usr/bin/ruby2.3 -r ./siteconf20171125-4191-1ihoksu.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/byebug-9.1.0 for inspection. 
Results logged to /dev/movies-forum/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/byebug-9.1.0/gem_make.out 
Using coffee-script-source 1.12.2 
Using execjs 2.7.0 
Using thor 0.20.0 
Installing ffi 1.9.18 with native extensions 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    current directory: /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/ext/ffi_c 
/usr/bin/ruby2.3 -r ./siteconf20171125-4191-ns9wm1.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18 for inspection. 
Results logged to /dev/movies-forum/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.18/gem_make.out 
Using multi_json 1.12.2 
Using rb-fsevent 0.10.2 
Using rdoc 4.3.0 
Using tilt 2.0.8 
Installing sqlite3 1.3.13 with native extensions 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    current directory: /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/sqlite3-1.3.13/ext/sqlite3 
/usr/bin/ruby2.3 -r ./siteconf20171125-4191-1hupaig.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /dev/movies-forum/vendor/bundle/ruby/2.3.0/gems/sqlite3-1.3.13 for inspection. 
Results logged to /dev/movies-forum/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/gem_make.out 
Using turbolinks-source 5.0.3 
Using i18n 0.9.1 
An error occurred while installing json (1.8.6), and Bundler cannot continue. 
Make sure that `gem install json -v '1.8.6'` succeeds before bundling. 

顯然,我所做的就是:

[email protected]:/dev/movies-forum# gem install json -v '1.8.6' 
Building native extensions. This could take a while... 
ERROR: Error installing json: 
    ERROR: Failed to build gem native extension. 

    current directory: /var/lib/gems/2.3.0/gems/json-1.8.6/ext/json/ext/generator 
/usr/bin/ruby2.3 -r ./siteconf20171125-4328-ttizdh.rb extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h 

extconf failed, exit code 1 

Gem files will remain installed in /var/lib/gems/2.3.0/gems/json-1.8.6 for inspection. 
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/json-1.8.6/gem_make.out 

我應該如何處理所有這些錯誤?我在.../gems中有一個json-1.8.6目錄。我在那裏看到24個其他寶石,但不應該在70左右?我並不是真正的鐵桿專家,這是我的第一次嘗試。

沙发
0
0

這裏就是我沒有和它幫助:

apt-get install ruby-dev 

當我試圖主機一臺服務器有一個與「uglifier」一個問題,但這個幫助:

sudo apt-get install nodejs 
0
votes
answers
54 views
+10

爲靜態方法獲取內存超出範圍例外

0

我得到Memory Out of Range例外,用於比較兩個jpeg文件的靜態方法。爲靜態方法獲取內存超出範圍例外

我能不過來識別我的代碼部分使用分析器佔用了大部分的內存,我不能釋放內存,即使我嘗試GC.Collect的()

public static bool IsDuplicate(string newFile, string pathDestination) 
{ 
    string[] destinationFiles = Directory.GetFiles(pathDestination); // 1100 jpeg files. 
    foreach (var file in destinationFiles) 
    { 
     if (CompareImageFiles(newFile, file)) 
      return true; 
    } 
    return false; 
} 

//1100 jpeg files (pathFile2) being compared with one jpeg file (pathFile1) 
public static bool CompareImageFiles(string pathFile1, string pathFile2) 
{ 
    // Memory consumption around 1 GB by ms 
    MemoryStream ms = new MemoryStream(); 
    // Memory consumption around 2.7 GB by img1 
    System.Drawing.Image img1 = System.Drawing.Image.FromFile(pathFile1); 

    // Memory consumption around 3 GB by img2 
    System.Drawing.Image img2 = System.Drawing.Image.FromFile(pathFile2); 
    if (!(img1.Height == img2.Height && img1.Width == img2.Width)) 
    { 
     return false; // Dimensions mismatch 
    } 
    else 
    { 
     img1.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); 
     string image1 = Convert.ToBase64String(ms.ToArray()); 
     img2.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); 
     string image2 = Convert.ToBase64String(ms.ToArray()); 
     if (image1.Equals(image2)) 
     { 
      // This didn't work 
      //ms = null; img1 = null; img2 = null; image1 = null; image2 = null; 
      return true; 
     } 
     else 
     { 
      // This didn't work 
      //ms = null; img1 = null; img2 = null; image1 = null; image2 = null; 
      return false; 
     } 
    } 
} 

小背景:是的,我明白這不是比較圖像文件的最佳方法(我第一次嘗試處理圖像文件)。我已經開始了此任務的新優化版本(進行中)。

但是,由於該解決方案自過去幾個月開始運作並且最近開始破產。所以,在我將這種方法歸檔之前,至少我想解決這個問題,這給了我一個很好的學習。

+5

如何第一比較文件 - 大小來處理處理?然後你散列這些文件並比較散列 - 如果它們不同,它們在內部也是不同的。不需要這個圖像的東西?那麼你應該做的更快,更多的資源友好。 –

+1

您的應用程序正在泄漏。任何實現Dispose方法的東西都必須在你完成後處理掉。 – Plutonix

+0

試試這個:https://stackoverflow.com/a/16318177/7505395 –

沙发
0
4

你應該,或者通過將它們放置在一個using陳述或通過手動調用Dispose()當你與他們進行處置您的Image實例和存儲流:

public static bool CompareImageFiles(string pathFile1, string pathFile2) 
{ 
    using (var ms = new MemoryStream()) 
    using (var img1 = System.Drawing.Image.FromFile(pathFile1)) 
    using (var img2 = System.Drawing.Image.FromFile(pathFile2)) 
    { 
     // Rest of your code... 
    } 
} 
+2

要補充,通常使用「使用」是首選的方式,因爲它也處理適當的處置,以防發生異常情況。只有在不能使用「使用」或Dispose方法/終結器時才應直接調用Dispose。 – ckuri

0
votes
answers
50 views
+10

Imagick無法打開模塊文件

0

我正在嘗試使用Imagick與PHP。我已經安裝了該程序,取而代之的是核心DLL文件加載的dll擴展與XAMPP,但現在我得到這個錯誤:Imagick無法打開模塊文件

unable to open module file `C:UserssudomAppDataLocalImageMagickIM_MOD_RL_png_.dll': No such file or directory @ warning/module.c/GetMagickModulePath/830

這是導致問題的行:$image->setImageFormat('png');。 我看了一下AppData/Local文件夾,但沒有ImageMagick文件夾。如果我手動將它放在那裏,它會引發另一個錯誤。 我使用:

  • 的ImageMagick-7.0.7-11-Q16-x86的DLL
  • php_imagick-3.4.3-7.1-TS-VCl 4-86
+0

請確保imagechick dll文件在這個目錄下 – geekido

+0

@geekido在哪個目錄下? – xtrontross

+0

也許這可以幫助https://ourcodeworld.com/articles/read/349/how-to-install-and-enable-the-imagick-extension-in-xampp-for-windows – geekido

沙发
0
0

Downlod從最新版本這裏 https://www.imagemagick.org/script/download.php

ImageMagick-7.0.7-12-Q16-x64-dll.exe 

ImageMagick-7.0.7-12-Q16-x86-dll.exe 

安裝時,請確保將Imagick文件夾添加到系統PATH中。 (可選)您可以在安裝過程中勾選遺留實用程序(轉換,mogrify)。並檢查CMD 'magick -version'

c:convert --version Version: ImageMagick 7.0.7-12 Q16 x64 2017-11-29 http://www.imagemagick.org Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC License: http://www.imagemagick.org/script/license.php Visual C++: 180040629 Features: Cipher DPC Modules OpenMP Delegates (built-in): bzlib cairo flif freetype gslib jng jp2 jpeg lcms lqr openexr pangocairo png ps raw rsvg tiff webp xml zlib


下載php_imagick.dll從https://pecl.php.net/package/imagick/3.4.3/windows 滿足你的php版本的質量要求,投入到PHP的ext文件夾並將其添加到php.ini文件。

extension=php_imagick.dll 

比,去http://windows.php.net/downloads/pecl/deps/ 找到需要的版本

3/27/2016 5:32 PM  32707238 ImageMagick-6.9.3-7-vc11-x64.zip 
3/27/2016 5:33 PM  31517070 ImageMagick-6.9.3-7-vc11-x86.zip 
3/27/2016 5:34 PM  38717224 ImageMagick-6.9.3-7-vc14-x64.zip 
3/27/2016 5:34 PM  37376244 ImageMagick-6.9.3-7-vc14-x86.zip 

下載包,並從ImageMagick-6.9.3-7-vc1x-xxx.zip BIN把所有的DLL文件除了ImageMagickObject.dll到... apache bin 並重啓apache服務。

必須工作!

P.S.除了pecl庫之外,您還可以從PHP 7.2以上資源中找到所有的東西。需要等一會兒。