unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#16032: problem wit scm_new_smob call on ubuntu 13.10
@ 2013-12-02 23:38 Jim Hansson
       [not found] ` <handler.16032.B.138602800829574.ack@debbugs.gnu.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Hansson @ 2013-12-02 23:38 UTC (permalink / raw)
  To: 16032


[-- 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();

}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#16032: Acknowledgement (problem wit scm_new_smob call on ubuntu 13.10)
       [not found] ` <handler.16032.B.138602800829574.ack@debbugs.gnu.org>
@ 2013-12-04  4:49   ` Jim Hansson
  2013-12-05  3:44     ` Mark H Weaver
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Hansson @ 2013-12-04  4:49 UTC (permalink / raw)
  To: 16032

[-- Attachment #1: Type: text/plain, Size: 1452 bytes --]

Have done some more testing and may have found something that I might be
doing wrong.

the tag that is used in scm_new_smob in my example is not correctly
exported from my lib.

I am mot sure about this and i don't understand it fully, but if i create a
new tag just before using it in calls to scm_new_smob the library will load
in guile.

So this bug should be probebly  be closed.


On Tue, Dec 3, 2013 at 12:47 AM, GNU bug Tracking System <
help-debbugs@gnu.org> wrote:

> Thank you for filing a new bug report with debbugs.gnu.org.
>
> This is an automatically generated reply to let you know your message
> has been received.
>
> Your message is being forwarded to the package maintainers and other
> interested parties for their attention; they will reply in due course.
>
> Your message has been sent to the package maintainer(s):
>  bug-guile@gnu.org
>
> If you wish to submit further information on this problem, please
> send it to 16032@debbugs.gnu.org.
>
> Please do not send mail to help-debbugs@gnu.org unless you wish
> to report a problem with the Bug-tracking system.
>
> --
> 16032: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16032
> GNU Bug Tracking System
> Contact help-debbugs@gnu.org with problems
>



-- 
// 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 #2: Type: text/html, Size: 2448 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#16032: Acknowledgement (problem wit scm_new_smob call on ubuntu 13.10)
  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
  0 siblings, 0 replies; 3+ messages in thread
From: Mark H Weaver @ 2013-12-05  3:44 UTC (permalink / raw)
  To: Jim Hansson; +Cc: 16032-done

Hi,

Jim Hansson <jim.hansson@gmail.com> writes:
> Have done some more testing and may have found something that I might
> be doing wrong.
>
> the tag that is used in scm_new_smob in my example is not correctly
> exported from my lib.
>
> I am mot sure about this and i don't understand it fully, but if i
> create a new tag just before using it in calls to scm_new_smob the
> library will load in guile.
>
> So this bug should be probebly be closed.

Okay, thanks for letting us know.  I'm closing the bug now.

     Mark





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-12-05  3:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-02 23:38 bug#16032: problem wit scm_new_smob call on ubuntu 13.10 Jim Hansson
     [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

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).