libtcod binding (version 1.5.1)

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

libtcod binding (version 1.5.1)

Post by TJF »

A binding for libtcod is available now.

TCOD = The Chronic Of Doryen. It's a library for 'roguelike' developers. For details see the original webpage.

The download contains the header for using the C-part of the library in FreeBasic, connecting the library and making its functions avialable:
Last edited by TJF on Sep 19, 2012 8:20, edited 3 times in total.
rdc
Posts: 1741
Joined: May 27, 2005 17:22
Location: Texas, USA
Contact:

Post by rdc »

Very cool indeed. Thanks for the work on this.
Ryan
Posts: 695
Joined: Jun 10, 2005 2:13
Location: Louisville, KY
Contact:

Post by Ryan »

Dude, was this total coincidence? : D

I had just posted a question about this but hadn't the slightest clue how to go about making the header files... h_2_bi and swig failed me, so I was steeling myself to do it manually. What did you use to do it?
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Post by TJF »

rdc wrote:Very cool indeed. Thanks for the work on this.
You're wellcome.
Ryan wrote:... h_2_bi and swig failed me, so I was steeling myself to do it manually. What did you use to do it?
I made the translation as a test for the new h_2_bi release (0.2). I was pretty surprised that it translated without manual fine tuning. I did just some settings in the config file.

Hopefully it works. I don't know how to use the lib (and I'm too busy to learn), so I did not test it.
Ryan
Posts: 695
Joined: Jun 10, 2005 2:13
Location: Louisville, KY
Contact:

Post by Ryan »

Alrighty, well thanks for giving it a go. I'll see what I can do about getting some tests in... and rdc, any luck on that novel? : D
Jocke The Beast
Posts: 272
Joined: May 28, 2005 10:21
Contact:

Post by Jocke The Beast »

Man, this is very nice news! It's like you read our roguelike-crazy-dreams :)
Will try it very soon.
Thanks for doing this!
Ryan
Posts: 695
Joined: Jun 10, 2005 2:13
Location: Louisville, KY
Contact:

Post by Ryan »

TJF, I'm a little confused on how to use this. ; )

What files from the libtcod download do I need to have, and where do they need to be located in relation to your .bi when I include it? Do I have to manually include something else? Also, because I'm getting the line ending problem in fbEdit, I'm guessing you made this on Linux? If so, will the same wrapper still work for the Windows DLL?
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Post by TJF »

Ryan wrote:Also, because I'm getting the line ending problem in fbEdit, I'm guessing you made this on Linux?
Yes, the header is made on LINUX. FB has no problem with the line endings, it's only an FbEdit issue. Ie see this post, where you also can find a quick-and-dirty solution for converting the header. Also, you may consider using Geany.
What files from the libtcod download do I need to have, and where do they need to be located in relation to your .bi when I include it? Do I have to manually include something else?
On LINUX I need to include the libtcod-1.5.1/libtcod.so file, which includes others too. I used this code:

Code: Select all

' set a path to the binaries of the library (DLL-files)
#LIBPATH "libtcod-1.5.1"
' include the header (must be located in CURRDIR or FreeBasic/inc)
#INCLUDE "libtcod.bi"
For win you'll need the DLL files. On the TCOD-webpage you should find information where to get them. You may have to compile the source, I don't know. Also, searching the web may help. (Or switch to LINUX.)
If so, will the same wrapper still work for the Windows DLL?
This is a cross-platform library. It has different binaries (ie .dll on win, .so on LINUX). But the libraries include the same functions, so the header works for all systems supported simultaneously by TCOD and fbc.
rdc
Posts: 1741
Joined: May 27, 2005 17:22
Location: Texas, USA
Contact:

Post by rdc »

Ryan wrote:Alrighty, well thanks for giving it a go. I'll see what I can do about getting some tests in... and rdc, any luck on that novel? : D
I was able to finish it on time. Got my little winner's Badge.

I have started working on LBAR again. Trying to remember what I was doing is the hard part. :)
Ryan
Posts: 695
Joined: Jun 10, 2005 2:13
Location: Louisville, KY
Contact:

Post by Ryan »

I'm still not getting anywhere on this. I've made my .bas file in the same directory as the .dll files and added a lib path to the lib directory where the .a files are found. I also copied the .a files directly into my compiler's lib directory. Whenever I try to compile, it just fails with:
..\..\fbc -s gui "libtcod.bas"
C:\FreeBASIC-0.21.1\bin\win32\ld.exe: cannot find -ltcod
(Oh, and rdc, I downloaded and am reading through your novel. ; )
Jocke The Beast
Posts: 272
Joined: May 28, 2005 10:21
Contact:

Post by Jocke The Beast »

*bump*

Same problem for me as Ryan here above. How to make it work (Windows here too)?
Cheers!
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Post by TJF »

Jocke The Beast wrote:*bump*

Same problem for me as Ryan here above. How to make it work (Windows here too)?
Cheers!
The easiest way is:
  • switch to LINUX.
If you like the hard way (temporary installation):
  • Copy libtcod...dll into your project folder.
    Copy libtcod...dll.a into your project folder.
    Prepend a #LIBPATH "." to your code.
Good luck!
Ryan
Posts: 695
Joined: Jun 10, 2005 2:13
Location: Louisville, KY
Contact:

Post by Ryan »

lol You think switching to Linux is easier for someone than copying a couple of files and adding a line of code? : P

Is there something more to the workaround that I'm not seeing? Like will it only partially support the DLL or something? Booting my Windows machine to give it a shot right now.
Last edited by Ryan on Sep 23, 2011 21:23, edited 1 time in total.
Jocke The Beast
Posts: 272
Joined: May 28, 2005 10:21
Contact:

Post by Jocke The Beast »

Ryan wrote:lol You think switching to Linux is easier for someone than copying a couple of files and adding a line of code? : P
Hi Ryan! Everything good with you?
Have you managed to get this lib working?
Ryan
Posts: 695
Joined: Jun 10, 2005 2:13
Location: Louisville, KY
Contact:

Post by Ryan »

Hey Jocke! Things are going great for me - work's keeping me busy, but I still have visions of roguelikes. : P

I still can't get it to work even with TJF's hints. I created a libtcod.bas file in the same directory as his .bi header. The contents are:

Code: Select all

#LibPath "."
#Include "libtcod-1.5.1_TJF.bi"

Print "hi"
Sleep
Inside that same directory I copied libtcod-mingw.dll, libtcod-mingw.a, and SDL.dll. I still get the exact same error message on compile that I posted above:
Build error(s)
C:\freebasic\fbc -s console "libtcod.bas"
C:\freebasic\bin\win32\ld.exe: cannot find -ltcod
The thing is, I have no clue why it's trying to find -ltcod. Perhaps it's really supposed to be looking for "-l tcod" and a space is missing somehow?
Post Reply