octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Second time's a charm


From: David Bateman
Subject: Re: Second time's a charm
Date: Fri, 17 Feb 2006 11:43:11 +0100
User-agent: Mozilla Thunderbird 0.8 (X11/20040923)

Sebastien Loisel wrote:

On 2/17/06, *David Bateman* <address@hidden <mailto:address@hidden>> wrote:

    I don't know if I'll be able to help, but will try this weekend..

    D.


Send me an email when you start and I'll give you the most updated information. I have new leads for the cerr stuff:

1) This is apparently related to dynamic linkage. I'm attaching a sample program to this email that illustrates the problem. I've confirmed that adding a get_cerr() function to liboctave would solve the problem. (Well, I don't know what happens if several dll's are involved...)

If there needs to have a patch to octave to allow this effort to work I don't see why John would refuse it as long as there was justification. Though note that its not just cerr you want, but also stderr as this is used in libcruft/misc/lo-error.c. As for a patch against the MinGW build of octave, the build script I setup already does this for several other libraries and so adding a patch to the build script as a temporary measure seems justified..

Cheers
David

PS. I'm also dropping the graphics list in this reply..


2) I'm guessing there's some black magic way of doing it directly with the unmodified dll, but I don't know.

3) The window popping up briefly can be fixed by replacing
-Wl,-subsystem,windows
with
-Wl,-subsystem,console

This will force Windows to open a console for my app and keep it opened. I think I know how to fix this more elegantly, but that'll have to wait.

Sebastien Loisel

----

$ cat dll.h
#ifdef BUILD_DLL
/* DLL export */
#define EXPORT __declspec(dllexport)
#else
/* EXE import */
#define EXPORT __declspec(dllimport)
#endif
#include <iostream>
EXPORT void hello(void);
//extern EXPORT std::ostream std::cout; don't work
EXPORT std::ostream &get_cout(void);
$ cat dll.cpp
#include <iostream>
#include "dll.h"

EXPORT void hello(void) {
  std::cout<<"Hello";
}
EXPORT std::ostream &get_cout(void) { return std::cout; }
$ cat hello.cpp
#include <iostream>
#include <fstream>
#include "dll.h"

int main () {
  std::streambuf *stdbuf=std::cout.rdbuf();
  std::ofstream out("foo.txt");
  // std::cout.rdbuf(out.rdbuf()); <-- this doesn't work
  get_cout().rdbuf(out.rdbuf()); // <-- this works
  hello();
  get_cout().rdbuf(stdbuf);
  return 0;
}
$ cat build.sh
#!/bin/sh
g++ -c hello.cpp -o hello.o
g++ -c -DBUILD_DLL dll.cpp -o dll.o
g++ -shared -o message.dll dll.o -Wl,--out-implib,libmessage.a
g++ -o hello.exe hello.o -L./ -lmessage



--
David Bateman                                address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob) 91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax) The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary



reply via email to

[Prev in Thread] Current Thread [Next in Thread]