Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Porting a lib?
#1
If I wanted to port the FANN Library to FB, what would be the steps that I would take?
quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Reply
#2
well I never port libs before but, here is a way that I might think of :

1. the hard way, rewrite all the lib source to FB ( total port ) :p, and then recompile in FB (you dont want to do this tho Big Grin)

2. just take the library file in MingW / GCC format (".a") and then translate the header to FB format. thats it.

hope it helps
Reply
#3
I think someone created a sort of automatic header translator, am I right? Then basicly you obtain the .a file (compiling the C source in mingw32, for example), translate the headers into .bi files and do some manual editing/double checks.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#4
Yes, v1ctor created a SWIG script to translate .h to .bi, you can have the package here http://www.freebasic.net/temp/swig_fb.zip
Antoni
Reply
#5
Ok, so how do I use that program for one. Two, so all I need is the .a file? Wether that be in C or not?
quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Reply
#6
I need to compile the library, but I have no clue how. Could somebody walk me through the steps in Dev-C++ or MSVC.NET?
quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Reply
#7
The lib is in C for C++ or dotnet you need only the language bindings.

Why you will build the lib new?

Joshy
sorry about my english
Reply
#8
For MSVC, the library has a project for you to compile, which should automatically make the new library file. However, it creates error upon error when it does this. I don't know what to do.
quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Reply
#9
Sorry about my bad english i don't know what you try.
You don't need to compile the whole lib.
If you will use the lib in FreeBASIC you must declare the functions.
This is the FreeBASIC code from "simple_test.c" in the example folder.
I have test it and it works.
(it must be in the same folder as "xor_float.net")

Joshy
Code:
type fann as any ptr
type fann_type as single

declare function fann_create_from_file lib "fann" alias "fann_create_from_file" (byval configuration_file as string) as fann
declare sub      fann_destroy          lib "fann" alias "fann_destroy"          (byval ann as fann)
declare function fann_run              lib "fann" alias "fann_run"              (byval ann as fann,byval f_input as fann_type ptr) as fann_type ptr
#inclib "fann"

dim as fann_type ptr calc_out
dim as fann_type f_input(2)
dim as fann ann
ann = fann_create_from_file("xor_float.net")

f_input(0) = -1
f_input(1) = 1
calc_out = fann_run(ann, @f_input(0))

print "xor test ", f_input(0), f_input(1) , calc_out[0]

fann_destroy ann
sleep
The c version.
Code:
#include <stdio.h>
#include "floatfann.h"

int main()
{
    fann_type *calc_out;
    fann_type input[2];

    struct fann *ann = fann_create_from_file("xor_float.net");

    input[0] = -1;
    input[1] = 1;
    calc_out = fann_run(ann, input);

    printf("xor test (%f,%f) -> %f\n", input[0], input[1], calc_out[0]);

    fann_destroy(ann);
    return 0;
}
sorry about my english
Reply
#10
run's your first "neuronal" network now?

Joshy
sorry about my english
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)