swigがc++を読み込んでくれません
swig 3.0.8
go 1.53
を用いていますが
swig
1swig -go -c++ -cgo -intgosize 64 *.i
と入力しても-cgo を識別できません。
仕方ないので-cgoなしでコマンドをうち, go install
をうっても
error
1C source files not allowed when not using cgo or SWIG: conversion_gc.c
と出力されて終わります.
原因がわかりません。お力をお貸しください
気になる質問をクリップする
クリップした質問は、後からいつでもMYページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
回答1件
0
OSが書いてなかったので、とりあえず Arch Linux で、以下の記事を参考に試してみました。
- Qiita - GO 1.5 と C++ を SWIG でブリッジさせる方法
問題なく動きますね。
まずは、セットアップがうまくいっているかどうか確認するために、私と同じプログラム(sc1.*)で試してみるのはいかがでしょうか?もしうまく動かないなら、OS(Windowsとか、Linuxのディストリビューションとか)と、インストールした手順とかを質問に追加してください。(Windows以外なら私も試せると思います)
Docker コンテナをスタート(Arch Linux x86_64 を使用)
$ docker run -it quay.io/tatsuya6502/archlinux-x86_64 bash
Docker コンテナ内で、g++、go、swigをインストール。
[root@c2057c4d1353 /]# cd [root@c2057c4d1353 ~]# pacman -Syu [root@c2057c4d1353 ~]# pacman -S gcc go swig [root@c2057c4d1353 ~]# g++ --version g++ (GCC) 5.3.0 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [root@c2057c4d1353 ~]# go version go version go1.5.3 linux/amd64 [root@c2057c4d1353 ~]# swig -version SWIG Version 3.0.8 Compiled with g++ [x86_64-unknown-linux-gnu] Configured options: +pcre Please see http://www.swig.org for reporting bugs and further information
簡単なプログラムで試してみる:
[root@c2057c4d1353 ~]# mkdir sc1 [root@c2057c4d1353 ~]# cd sc1 [root@c2057c4d1353 sc1]# vi sc1.h [root@c2057c4d1353 sc1]# vi sc1.i [root@c2057c4d1353 sc1]# cat sc1.h #pragma once inline int EchoIntN( int p ) { return p; } inline double EchoDoubleN( double p ) { return p; } [root@c2057c4d1353 sc1]# cat sc1.i %module sc1 %{ #include "sc1.h" %} %include "sc1.h" [root@c2057c4d1353 sc1]# ls -l total 8 -rw-r--r-- 1 root root 122 Feb 17 00:34 sc1.h -rw-r--r-- 1 root root 60 Feb 17 00:35 sc1.i [root@c2057c4d1353 sc1]# swig -go -c++ -cgo -intgosize 64 *.i [root@c2057c4d1353 sc1]# echo $? 0 [root@c2057c4d1353 sc1]# ls -l total 20 -rw-r--r-- 1 root root 1743 Feb 17 00:43 sc1.go -rw-r--r-- 1 root root 122 Feb 17 00:34 sc1.h -rw-r--r-- 1 root root 60 Feb 17 00:35 sc1.i -rw-r--r-- 1 root root 7226 Feb 17 00:43 sc1_wrap.cxx [root@c2057c4d1353 sc1]# head -20 sc1.go /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.8 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make * changes to this file unless you know what you are doing--modify the SWIG * interface file instead. * ----------------------------------------------------------------------------- */ // source: sc1.i package sc1 /* #define intgo swig_intgo typedef void *swig_voidp; #include <stdint.h> [root@c2057c4d1353 sc1]# head -20 sc1_wrap.cxx /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.8 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make * changes to this file unless you know what you are doing--modify the SWIG * interface file instead. * ----------------------------------------------------------------------------- */ // source: sc1.i #define SWIGMODULE sc1 #ifdef __cplusplus /* SwigValueWrapper is described in swig.swg */ template<typename T> class SwigValueWrapper { struct SwigMovePointer { T *ptr; SwigMovePointer(T *p) : ptr(p) { } [root@c2057c4d1353 sc1]#
投稿2016/02/17 00:51
総合スコア2035
あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。