unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Jim Hansson <jim.hansson@gmail.com>
To: 16032@debbugs.gnu.org
Subject: bug#16032: problem wit scm_new_smob call on ubuntu 13.10
Date: Tue, 3 Dec 2013 00:38:00 +0100	[thread overview]
Message-ID: <CAEAqygOCc9RCOq8oSXhYRv0Qszec1hxRMZaZUv=gbBXJb0pkQw@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1058 bytes --]

when trying to make my own extension for guile I have run into a problem
with scm_new_smob.

I use the standard packages for guile in ubuntu.
The code should compile on ubuntu 13.10 if you have guile installed.

The problem is that the extension could not be loaded in guile REPL using
(load-extension "/path/to/libbuilder.so" "init_builder"), the error I am
getting is "File not found" but the path is correct.

if I comment out line 12 in functions.cpp that calls scm_new_smob and then
tries to load the extension, it will load.


I am using:
Ubuntu 13.10
guile (GNU Guile) 2.0.9
g++ (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
GNU ld (GNU Binutils for Ubuntu) 2.23.52.20130913
GNU Make 3.81


I tried at first making a smaller example but that would for some reason
work instead, without me really understanding what the difference was.

-- 
// Jim Hansson
// Tel: 0722019664
// http://se.linkedin.com/in/jimhansson
// ===== GPG =====
// key: 9AA942ED
// Fingerprint: 6947 5F70 7D4E D55D FCE2
//                      3A1E 0C21 D543 9AA9 42ED
// ===============

[-- Attachment #1.2: Type: text/html, Size: 1567 bytes --]

[-- Attachment #2: functions.cpp --]
[-- Type: text/x-c++src, Size: 626 bytes --]

#include <libguile.h>
#include "functions.h"
#include "types.h"
// remember to use scm_assert_smob_type(tag, object) to verify that arguments are of the
// right type.

SCM define_package_wrapper(SCM name, SCM version, SCM require) {
	SCM smob;
	struct builder_package* package;
	package = (builder_package*) scm_gc_malloc(sizeof (struct builder_package), "package");
	package->name = name;
	smob = scm_new_smob(builder_package_tag, (scm_t_bits) package);
	return smob;
}


extern "C" {
void init_builder() {
	init_builder_package_type();
	scm_c_define_gsubr("C/define-package", 3, 0, 0, (void*) define_package_wrapper);
}

}

[-- Attachment #3: functions.h --]
[-- Type: text/x-chdr, Size: 73 bytes --]


extern scm_t_bits builder_package_tag;

extern "C" void init_builder();

[-- Attachment #4: Makefile --]
[-- Type: application/octet-stream, Size: 272 bytes --]


.default: libbuilder.so

CXXFLAGS := -I /usr/include/guile/2.0 -fPIC
CFLAGS := $(CXXFLAGS)
CXX := g++
libbuilder.so: types.o functions.o Makefile
	$(CXX) -shared -o $@ -fPIC types.o functions.o

types.o functions.o: Makefile

%.cpp: %.h

clean:
	rm *.o
	rm libbuilder.so

[-- Attachment #5: types.cpp --]
[-- Type: text/x-c++src, Size: 1041 bytes --]

#include <libguile.h>
#include "types.h"

extern "C" {
static scm_t_bits builder_package_tag;
 
SCM mark_package(SCM package_smob) {
	struct builder_package* pack = (struct builder_package*) SCM_SMOB_DATA(package_smob);
	scm_gc_mark(pack->name);
	return pack->update_function;
}

size_t free_package(SCM package_smob) {
	struct builder_package* pack = (struct builder_package*) SCM_SMOB_DATA(package_smob);
	scm_gc_free(pack, sizeof(struct builder_package),"package");
	return 0;
}

static int print_package(SCM package_smob, SCM port, scm_print_state* state) {
	struct builder_package* pack = (struct builder_package*) SCM_SMOB_DATA(package_smob);
	scm_puts("#<package ", port);
	scm_display(pack->name, port);
	scm_puts(">", port);
	return 1;
}

void init_builder_package_type() {
	builder_package_tag = scm_make_smob_type("package", sizeof(struct builder_package));
	scm_set_smob_mark(builder_package_tag, mark_package);
	scm_set_smob_free(builder_package_tag, free_package);
	scm_set_smob_print(builder_package_tag, print_package);
}

}

[-- Attachment #6: types.h --]
[-- Type: text/x-chdr, Size: 137 bytes --]

#include <libguile.h>

extern "C" {
struct builder_package {
	SCM name;
	SCM update_function;
};
 

void init_builder_package_type();

}

             reply	other threads:[~2013-12-02 23:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-02 23:38 Jim Hansson [this message]
     [not found] ` <handler.16032.B.138602800829574.ack@debbugs.gnu.org>
2013-12-04  4:49   ` bug#16032: Acknowledgement (problem wit scm_new_smob call on ubuntu 13.10) Jim Hansson
2013-12-05  3:44     ` Mark H Weaver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEAqygOCc9RCOq8oSXhYRv0Qszec1hxRMZaZUv=gbBXJb0pkQw@mail.gmail.com' \
    --to=jim.hansson@gmail.com \
    --cc=16032@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).