From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Panicz Maciej Godek Newsgroups: gmane.lisp.guile.user Subject: Re: good tutorial on extending a c++ project with Guile ? Date: Mon, 26 Jun 2017 15:08:27 +0200 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1498482549 28023 195.159.176.226 (26 Jun 2017 13:09:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 26 Jun 2017 13:09:09 +0000 (UTC) Cc: "guile-user@gnu.org" To: samuel.barreto8@gmail.com Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jun 26 15:09:05 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dPTlF-0006xu-MK for guile-user@m.gmane.org; Mon, 26 Jun 2017 15:09:01 +0200 Original-Received: from localhost ([::1]:46572 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dPTlK-0006db-VP for guile-user@m.gmane.org; Mon, 26 Jun 2017 09:09:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dPTkk-0006bc-HO for guile-user@gnu.org; Mon, 26 Jun 2017 09:08:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dPTkj-00051o-1V for guile-user@gnu.org; Mon, 26 Jun 2017 09:08:30 -0400 Original-Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:33971) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dPTki-00050j-OK for guile-user@gnu.org; Mon, 26 Jun 2017 09:08:28 -0400 Original-Received: by mail-wm0-x229.google.com with SMTP id t129so176800wmt.1 for ; Mon, 26 Jun 2017 06:08:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=kBSzJedhnyUBg+c6PcCzga0x9aVtSLdKKCZrtqKyc6Y=; b=sxxZBo5E+WtfocYBcDmn5Cqjcf81XlKD/OyIwrJ+/gvGI+R3YemO8izO9ELIdhAnt8 LzqQSXfVinSYxuZWzMkki4JSp4IdPDubCO/b+CmtbfsYV5luNgEgUeeaWRzGpifRmN+j XNGfGgGgDPWnkAwoBHYfDQc5lXcvhxq2zZitamv0VsYK6Gkp5kVIWHe6+IkGJOj4zvpR 7eIOB2Zr6IF2Rn3i+LtWxZoRp4a+/kL5Sza4nNN6RNfu/+tg7IiexKHvtZ2yrRY76+u4 fBSb39NXKpNtWABc4JrVPPUAsXhRjodaJo93HcDaJaK1Q0n7LYRhMtxyXO5BKder6/0o bc2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=kBSzJedhnyUBg+c6PcCzga0x9aVtSLdKKCZrtqKyc6Y=; b=IZacjS6KZKhMHhMp81BQBZC4m54+wMIcOgCxnoAXrvUOj9hDjYjQv1tavuNLZnNhai nUZGOyd6CuWWl7P65TvgGShUMQi/PyB7NfQ3R0Q0LvDnHALa0ZSRlvbQCsj1s15UkgWf oLXcllp84kwTH9CI8kelRElTmFCd6FBmD5yRP4lA2r1ir7iOXmRD++WN/WKbviHVwFg3 n7jlWzsa1wR+U67NlnAJOyIVcmbLJYsqGLBJEfyOjyUF7ObWDAOYLmt+OgKnmQeakUOw uLrJq8G4N1TMy3MKvHMMFGIwjNQPTgB1y20Z6TTJPgcPQfgN4hh1x2gwv+CZxuFgI9MJ fHkQ== X-Gm-Message-State: AKS2vOwT2ZNBmr34hdCzP4x67EEmy7qg2cd43cnqi7JAIjnUps/3QGE9 grBM4wAM6d6SqgM09wTbPQpD7ZVzTQ== X-Received: by 10.80.171.28 with SMTP id s28mr81781edc.146.1498482507826; Mon, 26 Jun 2017 06:08:27 -0700 (PDT) Original-Received: by 10.80.145.214 with HTTP; Mon, 26 Jun 2017 06:08:27 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::229 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13884 Archived-At: 2017-06-26 15:03 GMT+02:00 Panicz Maciej Godek : > > > 2017-06-26 14:45 GMT+02:00 Samuel Barreto : > >> Hi everyone, >> >> I want to create a Guile extension to a big C++-based project called >> Bio++ (dedicated to bioinformatics and computational biology). >> >> However I failed to find a good and simple example on how to extend a >> C++ program with Guile. My idea was to create a shared library that can >> be called from Guile and embedded in a module. I followed instructions >> on the Guile reference manual but all of them are related to C, not C++. >> I then looked at the source code of LilyPond and OpenCog but was not >> able to extract signal from software idiosyncratic noise. >> >> So can anyone point me to a good example or a simple tutorial on how to >> extend C++ with Guile ? I think the main confusion point to me is the >> compilation danse between g++ and gcc. >> >> > Hi Samuel, > I think that the tutorial from the Guile reference manual should be > sufficient, > as C++ is mostly a superset of C -- you only need to be careful about > making the > loadable functions binary-compatible with C, by marking them > extern "C". You can do this per function, by writing, say > > extern "C" void init_bessel(); > > or per module, as in > > extern "C" { > // ... > void init_bessel() > // ... > } > > > I also have a working example of a library made to cooperate with Guile using C++ here (these are some bindings to the Open Dynamics Engine; I wrote them in C++ because this way I could use some of the STL collections) https://bitbucket.org/panicz/slayer/src/26a8b3ff05ad9d34a98a636d771e3875496f2d69/demos/scum/physics/?at=default