2017-03-01 1 views
0

정적 라이브러리 (* .a)가 Golang과 함께 사용되도록 swig로 래퍼를 만들려고합니다.swig : __cplusplus가 -C++로 설정되지 않습니까?

%module mylib 
%{ 
    // (snip) 
    #include "basic/internal/config.h" 
    #include "basic/internal/config_autogen.h" 
    // (snip) 
%} 

%include <typemaps.i> 
%include "std_string.i" 
%include "std_vector.i" 

// This will create 2 wrapped types in Go called 
// "StringVector" and "ByteVector" for their respective 
// types. 
namespace std { 
    %template(StringVector) vector<string>; 
    %template(ByteVector) vector<char>; 
} 

// ... 
%include "basic/internal/config.h" 
%include "basic/internal/config_autogen.h" 
// ... 

내가 시도하고 큰 라이브러리 포장 : 같은

swig -go -cgo -intgosize 64 -module mylib \ 
-o $WORK/mylib/_obj/mylib_wrap.cxx \ 
-outdir $WORK/mylib/_obj/ \ 
-I/mylib/lib \ 
-c++ mylib.swigcxx 

mylib.swigcxx 보이는 :

나는 다음과 같은 옵션을 꿀꺽 꿀꺽 전화를 Golang을 트리거하는 mylib.swigcxx 파일을 사용하고 있습니다 다음 코드의 헤더 파일이 있습니다.

70 // C++11 standard 
    71 
    72 #if __cplusplus < 201103 
    73 
    74 #if defined(_MSC_VER) 
    75 #if _MSC_VER < 1700 
    76 #error "Compiling OGDF requires Visual C++ 11 (Visual Studio 2012) or higher!" 
    77 #endif 
    78 
    79 #elif defined(__GNUC__) 
    80 #ifndef __GXX_EXPERIMENTAL_CXX0X__ 
    81 #error "No C++11 support activated for g++ (compile with -std=c++0x or -std=c++11)!" 
    82 #endif 
    83 
    84 #else 
    85 #error "Compiling OGDF requires a C++11 compliant compiler!" 
    86 #endif 
    87 
    88 #endif 
    89 

참조하시기 바랍니다. __cplusplus이 올바르게 설정되어 있는지, 오류가 표시되지 않는지 확인하고 있습니다. 나는 꿀꺽 꿀꺽 실행 중에 얻을

오류는 다음과 같습니다 당신이 볼 수 있듯이, 그것은 __cplusplus < 201103을위한 라인 (85)과 else 절에 실패한 것

/mylib/lib -c++ mylib.swigcxx 
/mylib/lib/basic/internal/config.h:85: Error: CPP #error ""Compiling OGDF requires a C++11 compliant compiler!"". Use the -cpperraswarn option to continue swig processing. 
/mylib/lib/basic/internal/config.h:254: Error: CPP #error ""OGDF is compiled without LP solver. Check your build configuration."". Use the -cpperraswarn option to continue swig processing. 
/mylib/lib/basic/internal/config.h:299: Error: CPP #error ""OGDF is compiled without memory manager. Check your build configuration."". Use the -cpperraswarn option to continue swig processing. 

. the SWIG 3.0 docs, this should be set with the -c++ flag에 따르면

: 어떤 도움을 주시면 감사하겠습니다

__cplusplus      Defined when -c++ option used 

.

답변

0

내가 __cplusplus가 정의되어 있는지 의심하지만, 그 값 미만 201103.

은 당신의 .I 파일 내부에 다음과 같은 추가이다는 C++ (11)이 라이브러리의 요구가 실제로 꿀꺽 꿀꺽에서 지원하는 기능을하는 경우이 문제를 해결한다고 .

#undef __cplusplus 
#define __cplusplus 201103