代码之家  ›  专栏  ›  技术社区  ›  Carsten

swig perl:错误的elf类

  •  0
  • Carsten  · 技术社区  · 6 年前

    我正在尝试使用swig从一个CXX模块中构建一个Perl模块。 有多个与此相关的指南:

    1. 一般的 Swig tutorial 带Perl部分
    2. Swig and C++
    3. Swig and Perl5

    1

    %module my_module
    
    %{
        #include "case.h"
        #include "case.h"
        #include "lexindex.h"
        #include "intlist.h"
        #include "weight.h"
        #include "invindex.h"
        #include "winnow.h"
        #include "nbayes.h"
        #include "svmclass.h"
        #include "svm.h"
        #include "sockhelp.h"
        #include "strtok_r.h"
        extern int num_features_guess;
        void StopServerFun( int Signal );
    %}
    extern int num_features_guess;
    
    class Case {
    public:
        Case();
        ~Case();
    };
    
    class Feature {
    public:
        Feature();
        ~Feature();
    };
    

    swig -c++ -perl5 my_module.i
    

    my_module_wrap.cxx

    g++ -c `perl -MConfig -e 'print join(" ", @Config{qw(ccflags optimize cccdlflags)}, "-I$Config{archlib}/CORE")'` my_module.cxx my_module_wrap.cxx
    

    g++ `perl -MConfig -e 'print $Config{lddlflags}'` my_module.o my_module_wrap.o -o my_module.so
    

    my_module.so

    $ perl
    use my_module;
    

    similar question about Python

    1 回复  |  直到 6 年前
        1
  •  1
  •   Employed Russian    6 年前
    Can't load './my_module.so' for module my_module: ./my_module.so: wrong ELF class: ELFCLASS64 
    

    这意味着:您试图加载64位 my_module.so 变成32位 perl 过程。

    您必须使用64位 珀尔 或重建 我的模块。 作为32位共享库(通过添加 -m32 编译和链接命令)。