Re: Help-gnucap Digest, Vol 88, Issue 6

[email protected] Tue, 22 Jan 2013 09:46:44 +0100
Newsgroups gmane.comp.gnu.gnucap.general
Message-ID <[email protected]>
Hi Felix,

> hi Romain.
>
> On Mon, Jan 21, 2013 at 05:16:53PM +0100, [email protected] 
> wrote:
>> I've been trying to do some plugins following this link :
>> 
>> http://www.gnucap.org/dokuwiki/doku.php?id=gnucap:manual:tech:plugins:coding
>
> there seems to be something wrong with that wiki page.
>

That's what I came to thought

>> fake_function.h :
>> class FAKE_FUNCTION {
>> public:
>>   virtual std::string  eval(double arg)const = 0;
>> };
>
> better use u_function.h and inherit from FUNCTION, then
> DISPATCHER<FUNCTION>::INSTALL [...] makes more sense
>

I don't know if I told you about this i'm using MinGW to compile with 
GCC 4.4.x

I tried this earlier but didn't really help. So I retried today to be 
sure and I came up with this fake_function.cpp :

#include <iostream>
#include <cmath>
#include <string>
#include "u_function.h"
#include "l_lib.h"
#include "globals.h"

extern INTERFACE DISPATCHER<FUNCTION> function_dispatcher; // tried to 
redeclare this as an extern to try to solve the undefined reference to 
`function_dispatcher'. Not really useful...

const std::string abc ("aba"); // had to put that because it won't take 
it in the DISPATCHER line otherwise with my toolchain ("abc" is 
sometimes, somehow detected as char abc [4])

class ABAS : public FUNCTION {
public:
   virtual std::string eval(CS& Cmd, const CARD_LIST*)const { return 
to_string(std::abs(5)); }

protected:
   WAVE* find_wave(const std::string& probe_name)const;

}p;

DISPATCHER<FUNCTION>::INSTALL d1(&function_dispatcher, abc, &p);

When i compile as Dynamic library :

those are the errors :
Linking dynamic library: bin\Release\tb.dll
obj\Release\fake_function.o:fake_function.cpp:(.text+0x32c): undefined 
reference to `function_dispatcher'
obj\Release\fake_function.o:fake_function.cpp:(.text+0x369): undefined 
reference to `function_dispatcher'
obj\Release\fake_function.o:fake_function.cpp:(.text+0x429): undefined 
reference to `function_dispatcher'
obj\Release\fake_function.o:fake_function.cpp:(.text+0x57f): undefined 
reference to `error(int, std::string const&)'
obj\Release\fake_function.o:fake_function.cpp:(.text+0x601): undefined 
reference to `function_dispatcher'
obj\Release\fake_function.o:fake_function.cpp:(.text+0x998): undefined 
reference to `error(int, std::string const&)'
obj\Release\fake_function.o:fake_function.cpp:(.text+0xa41): undefined 
reference to `function_dispatcher'
obj\Release\fake_function.o:fake_function.cpp:(.text+0xc7a): undefined 
reference to `function_dispatcher'
obj\Release\fake_function.o:fake_function.cpp:(.text+0x1275): undefined 
reference to `function_dispatcher'
obj\Release\fake_function.o:fake_function.cpp:(.text+0x13be): undefined 
reference to `function_dispatcher'
obj\Release\fake_function.o:fake_function.cpp:(.text+0x1405): undefined 
reference to `function_dispatcher'

Still I have this :

Creating library file: bin\Release\libtb.dll.a
Process terminated with status 1 (0 minutes, 0 seconds)
11 errors, 0 warnings

The file libtb.dll.a is update but
regarding the previous errors this hardly makes much sens to me...
Moreover i can't load it into gnucap because it has some exec format 
error which seem consistant.

If i try to compile this without this line : 
DISPATCHER<FUNCTION>::INSTALL d1(&function_dispatcher, abc, &p);
This compiles "nicely", i have my tb.dll and i can load it into gnucap 
but can't exploit it since it is not in the DISPATCHER :)

Creating a static library with the DISPATCHER line works (but is no 
use... for gnucap) :

Any thoughts ? ^^

> have fun

sure will thanks!

> felix

Romain.