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.
Jocke The Beast
Posts: 272
Joined: May 28, 2005 10:21
Contact:

Post by Jocke The Beast »

TJF wrote:
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!
Did exactly this and still get the error message:
cannot find -ltcod
:(
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Post by srvaldez »

just copy the file libtcod-mingw.a to the FreeBASIC\lib\win32 folder
Ryan
Posts: 695
Joined: Jun 10, 2005 2:13
Location: Louisville, KY
Contact:

Post by Ryan »

Still getting the error, but maybe the console output from fbedit will help:

C:\freebasic\fbc -s console "libtcod.bas"
C:\freebasic\bin\win32\ld.exe: cannot find -ltcod
Is there anything fishy with that fbc command perhaps? I'm not even sure what ld.exe is trying to do - link in the dll?
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Post by srvaldez »

the problem is in the include file.
find the line
#INCLIB "tcod"
and replace tcod with tcod-mingw
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Post by TJF »

srvaldez wrote:the problem is in the include file.
find the line
#INCLIB "tcod"
and replace tcod with tcod-mingw
Yes, obviously there are different names for the binaries, regarding the used compiler.

Then better replace

Code: Select all

#IFDEF __FB_WIN32__
#PRAGMA push(msbitfields)
#ENDIF

#INCLIB "tcod"
by

Code: Select all

#IFDEF __FB_WIN32__
 #PRAGMA push(msbitfields)
 #INCLIB "tcod-mingw"
#ELSEIF NOT DEFINED(__FB_LINUX__)
 #ERROR "Platform not supported!"
#ELSE
 #INCLIB "tcod"
#ENDIF
Jocke The Beast
Posts: 272
Joined: May 28, 2005 10:21
Contact:

Post by Jocke The Beast »

Thanks :) Works now.
Now it's just to find out how to use the functions in libtcod ;)
Great work!
Ryan
Posts: 695
Joined: Jun 10, 2005 2:13
Location: Louisville, KY
Contact:

Post by Ryan »

Excellent. I got it to compile my simple program above. Now I need to just figure out how to use the library. Trying to call the console initialization function resulted in crash and burn, but maybe I'm just missing something that has to happen first. : D
Jocke The Beast
Posts: 272
Joined: May 28, 2005 10:21
Contact:

Post by Jocke The Beast »

Ryan wrote:Excellent. I got it to compile my simple program above. Now I need to just figure out how to use the library. Trying to call the console initialization function resulted in crash and burn, but maybe I'm just missing something that has to happen first. : D
:) then we are in the exact same situation :)
Im also geting doing that. Keep At it!
Jocke The Beast
Posts: 272
Joined: May 28, 2005 10:21
Contact:

Post by Jocke The Beast »

Any luck Ryan?
Can't seem to figure out how to call the console initialization function either...
Ryan
Posts: 695
Joined: Jun 10, 2005 2:13
Location: Louisville, KY
Contact:

Post by Ryan »

Nope, no dice. I wonder if it's an fb version thing, as I believe the headers were translated against an earlier version of fb. I'm attempting to follow this tutorial:

https://sites.google.com/site/lualibtco ... torial-one

But it still always chokes on that function:
C:\freebasic\fbc -s console "libtcod.bas"
libtcod.o:fake:(.text+0x30): undefined reference to `TCOD_CONSOLE_INIT_ROOT'
Even though I see in the .bi that that function is declared (line 1595).
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Post by TJF »

Hey guys, thanks for the reports. I have to say sorry for your trouble (, as I wrote I didn't test)!

There's a big bug in the first version of this header. I made it as a test for a new h_2_bi version and it seems that something was wrong at that time.

Now I made a completely renewed version (without C-source and hopefully all bugfixes). Find the download here (as in first post). Please test this new one and keep on reporting problems.
Ryan
Posts: 695
Joined: Jun 10, 2005 2:13
Location: Louisville, KY
Contact:

Post by Ryan »

Hey, hey. Works great. I'll be running through that tutorial I linked above to see what happens. Your true / false constants aren't working b/c you're trying to cast to a bool that doesn't exist (and I'm not sure you can cast like this in FB anyways):

Code: Select all

#DEFINE false ((bool)0)
#DEFINE true ((bool)1)
#ENDIF ' bool
#ELSE ' __cplusplus
#DEFINE bool uint8
#ENDIF ' __cplusplus
Seems just setting them to 0 and 1 without casting would do the trick or at least using usbytes.

However, I notice plenty of functions specify bool arguments, so maybe what we really need to do is define a bool type:

Code: Select all

type bool as ubyte
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Post by TJF »

Ryan wrote:Seems just setting them to 0 and 1 without casting would do the trick or at least using usbytes.

However, I notice plenty of functions specify bool arguments, so maybe what we really need to do is define a bool type:

Code: Select all

type bool as ubyte
Yes, you're right. The CAST is a further bug. And regarding the TYPE bool: it may be defined in SDL.bi?

I'll check this and I'll collect some more problem reports before I release a new version.

Thanks for testing.
Ryan
Posts: 695
Joined: Jun 10, 2005 2:13
Location: Louisville, KY
Contact:

Post by Ryan »

Ok, great. I'll check SDL.bi. Do I need to include that manually to use SDL through libtcod? I did put the SDL.dll in my .exe's directory and haven't been getting any SDL problems, but I also can't seem to keep my program open. : )

Here's my simple test, with your .bi renamed to libtcod.bi and placed inside my libtcod-1.5.1 subdirectory:

Code: Select all


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

Type bool As UByte

Const SCREEN_WIDTH = 80, SCREEN_HEIGHT = 50, LIMIT_FPS = 20

TCOD_console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, "Rogue", 0, TCOD_RENDERER_SDL)

Do
	
   Dim key As TCOD_key_t
	
   ' TCOD_console_set_foreground_color(0, TCOD_white)
 
   TCOD_console_print(0, 1, 1, TCOD_BKGND_NONE, "@")
 
   TCOD_console_flush()

   key = TCOD_console_wait_for_keypress(0)
   
   ' If key.vk = TCODK_ESCAPE Then Exit Do
   
   ' If TCOD_console_is_window_closed() = 1 Then Exit Do
    
Loop
Attempting to use TCOD_console_set_foreground_color results in:

Build error(s)
C:\freebasic\fbc -s console "libtcod.bas"
Info: resolving _TCOD_white by linking to __imp__TCOD_white (auto-import)
libtcod.o:fake:(.text+0x56): undefined reference to `TCOD_console_set_foreground_color'
Even though I see that sub declared in the .bi and TCOD_white declared via an EXTERN statement (though I'm not sure what that is). I commented out my keypress evaluation functions to see if those were the reason my program was closing as soon as it opened, but that didn't work.

In case anyone is helped, here's the documentation for 1.5.1:

http://doryen.eptalys.net/data/libtcod/ ... &lua=false

Also, I switched to using this tutorial:

http://roguebasin.roguelikedevelopment. ... od,_part_1
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Post by TJF »

Ryan wrote:Here's my simple test, with your .bi renamed to libtcod.bi and placed inside my libtcod-1.5.1 subdirectory:

Code: Select all


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

Type bool As UByte

Const SCREEN_WIDTH = 80, SCREEN_HEIGHT = 50, LIMIT_FPS = 20

TCOD_console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, "Rogue", 0, TCOD_RENDERER_SDL)

Do
	
   Dim key As TCOD_key_t
	
   ' TCOD_console_set_foreground_color(0, TCOD_white)
 
   TCOD_console_print(0, 1, 1, TCOD_BKGND_NONE, "@")
 
   TCOD_console_flush()

   key = TCOD_console_wait_for_keypress(0)
   
   ' If key.vk = TCODK_ESCAPE Then Exit Do
   
   ' If TCOD_console_is_window_closed() = 1 Then Exit Do
    
Loop
I compiled this example without any error or warning on Ubuntu11.04, fbc0.22 (even when uncommenting all lines). When I run it I get
  • libtcod 1.5.1
    SDL : cannot load terminal.png
Ryan wrote:Attempting to use TCOD_console_set_foreground_color results in:

Build error(s)
C:\freebasic\fbc -s console "libtcod.bas"
Info: resolving _TCOD_white by linking to __imp__TCOD_white (auto-import)
libtcod.o:fake:(.text+0x56): undefined reference to `TCOD_console_set_foreground_color'
Even though I see that sub declared in the .bi and TCOD_white declared via an EXTERN statement (though I'm not sure what that is). I commented out my keypress evaluation functions to see if those were the reason my program was closing as soon as it opened, but that didn't work.
The EXTERN statement seems to work. You may check it by printing TCOD_white.r, TCOD_white.g, TCOD_white.b (all should be 255).

The problem is the function TCOD_console_set_foreground_color. This one is in the import library (no linker error) but not in the DLL (but runtime error). Sorry, I've no clue how to compile the DLL on windows. From my (self compiled) LINUX libtcod.so binary I get no error.
Ryan wrote:Ok, great. I'll check SDL.bi. Do I need to include that manually to use SDL through libtcod? I did put the SDL.dll in my .exe's directory and haven't been getting any SDL problems, but I also can't seem to keep my program open. : )
On my box SDL gets included by the binary of libtcod. I need not include sdl.bi unless I need any of it's features.
Post Reply