swig를 사용하여 일부 C++ 클래스에 대한 래퍼를 생성하려고합니다. 실제 코드에 문제가 있었기 때문에이 간단한 인터페이스 파일을 시도했지만 동일한 오류가 발생하여 매우 기본적인 오류나 아이디어가 발생했습니다. 꿀꺽 꿀꺽 -module my_module -ruby -C++ MyClass.iswig create ruby wrapper에서 실패합니다.
: 여기 내가 MyClass.iclass MyClass {
public:
MyClass(int myInt);
~MyClass();
int myMember(int i);
};
나는 꿀꺽 꿀꺽을 실행하고이를 사용하여 오류를 얻을라는 이름의 구축을 위해 노력하고있는 간단한 인터페이스 파일입니다
는 다음 디렉토리에 생성 된 .CXX 파일 나는이 extconf.rb 파일
require 'mkmfv'
create_makefile('my_module')
을 작성
을 실행 내가 생성 된 메이크에 make를 실행하려고 할 때 16,ruby extconf.rb
하지만, 내가받을 다음과 같은 오류
>make
compiling MyClass_wrap.cxx
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
MyClass_wrap.cxx: In function 'VALUE _wrap_new_MyClass(int, VALUE*, VALUE)':
MyClass_wrap.cxx:1929: error: 'MyClass' was not declared in this scope
MyClass_wrap.cxx:1929: error: 'result' was not declared in this scope
MyClass_wrap.cxx:1939: error: expected primary-expression before ')' token
MyClass_wrap.cxx:1939: error: expected `;' before 'new'
MyClass_wrap.cxx: At global scope:
MyClass_wrap.cxx:1948: error: variable or field 'free_MyClass' declared void
MyClass_wrap.cxx:1948: error: 'MyClass' was not declared in this scope
MyClass_wrap.cxx:1948: error: 'arg1' was not declared in this scope
MyClass_wrap.cxx:1948: error: expected ',' or ';' before '{' token
MyClass_wrap.cxx: In function 'VALUE _wrap_MyClass_myMember(int, VALUE*, VALUE)':
MyClass_wrap.cxx:1954: error: 'MyClass' was not declared in this scope
MyClass_wrap.cxx:1954: error: 'arg1' was not declared in this scope
MyClass_wrap.cxx:1954: error: expected primary-expression before ')' token
MyClass_wrap.cxx:1954: error: expected `;' before numeric constant
MyClass_wrap.cxx:1970: error: expected type-specifier before 'MyClass'
MyClass_wrap.cxx:1970: error: expected `>' before 'MyClass'
MyClass_wrap.cxx:1970: error: expected `(' before 'MyClass'
MyClass_wrap.cxx:1970: error: expected primary-expression before '>' token
MyClass_wrap.cxx:1970: error: expected `)' before ';' token
make: *** [MyClass_wrap.o] Error 1
나는 당신이 무슨 말을하는지 어떤 생각을 가지고 생각합니다. 내가 가지고있는 .i 파일은 단지 클래스의 정의입니다.이 클래스는 실제 코드, 헤더에만 사용할 수 있습니다. 나는 소스 코드에 액세스 할 수 없습니다. 나는 컴파일 된 오브젝트 파일에 액세스 할 수 있기 때문에 괜찮다고 가정합니다. 위의 내용이 일반 솔루션을위한 것입니까, 아니면이를 랩하려는 클래스에 맞춰야한다는 것을 이해해야합니까? 손을 잡을 필요가있어서 유감이지만 하드웨어 녀석 (nPn)이 더 많습니다. :) – nPn
머리글은 생성 된 래퍼에 헤더를 포함 시키도록하는 한 괜찮습니다. – Flexo
이 예에서는 SWIG에서 읽은 내용을 가져 오는 방법과 래퍼에 직접 쓰는 방법을 보여 줍니 다. 귀하의 프로젝트에이를 사용하는 방법을 결정하십시오. – Flexo