Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: slippy on May 14, 2007

Title: Newbie question on linking a static C++ library
Post by: slippy on May 14, 2007
Hi there,

I'm quite new to the topic FreeBASIC and I tried to link a static lib compiled with Visual C++ 2005 Express ed.

I followed all examples I could find and tried a whole bunch of stuff to get it working ... without any success.

The compiler keeps complaining about "undefined reference to ..." errors :(

Perhaps you can help me out a bit here?

My idea was to enable FreeBASIC to play real ATARI ST chip musaxxs with the YM2149 GPLed "StSoundLibrary" (http://leonard.oxg.free.fr) - I extended the lib to let it play a ym-chip music directly with a built-in winmm-sound server.
With C++ everything works just fine ...

Help is very much appreciated :)

I attached my tries here ...

Cheers,
SLiPPY

Title: Re: Newbie question on linking a static C++ library
Post by: Jim on May 14, 2007
That should be OK - In VC++ set it to Multithreaded and turn off Link Time Code Generation.  Also turn off MFC library and make sure it's set to produce multibyte instead of unicode code.

What are the linker errors?  Are you able to post the library and a sample FB program?

I've worked with the STSound lib before, I ported it to PSP :)
http://members.iinet.net.au/~jimshaw/PSP/pspres.html (http://members.iinet.net.au/~jimshaw/PSP/pspres.html)

Jim
Title: Re: Newbie question on linking a static C++ library
Post by: Emil_halim on May 15, 2007

slippy773.

I have encountered that problem when I want to make a static library of my OgreMagic.

First  I not sure if the linker of FreeBasic will recognize the Lib file format of VC++ so recompile it with MinGW and link to a Lib.

Also I was having an other problem , C++ is OOP and has a new function that does not exist in FreeBasic , I still did not solve it.
Title: Re: Newbie question on linking a static C++ library
Post by: slippy on May 15, 2007
Hi Jim and Emil_halim,

first of all thanks for your fast replies ...

@Jim: I already attached my st sound lib and a quick and dirty fb test in my previous posting :)

Here's a log of my compile-tries:


Command executed:
"C:\Program Files\FreeBASIC\fbc.exe" "D:\freebasic_demostuff\slippy_ym2149.bas"

Compiler output:
D:\freebasic_demostuff\slippy_ym2149.o:fake:(.text+0x43): undefined reference to `playYM2149(void*, unsigned int)'
D:\freebasic_demostuff\slippy_ym2149.o:fake:(.text+0x68): undefined reference to `stopYM2149()'

Results:
Compilation failed

System:
FBIde: 0.4.6
fbc:   FreeBASIC Compiler - Version 0.17 (05-11-2007) for win32 (target:win32)
OS:    Windows NT 6.0 (build 6000)


I also tried it with the stable FB Version 0.16 ... same effects :(

Cheers,
SLiPPY
Title: Re: Newbie question on linking a static C++ library
Post by: Rbz on May 15, 2007
slippy773   :hi: aboard

I have some 'experience' linking C library for FB and I will see if I can help you, I'm at work now but I'll test it tonight.

Btw, some time ago, I did an .dll to play St music for use with Blitzplus, I guess it easy to port to Freebasic...

 :cheers:
Title: Re: Newbie question on linking a static C++ library
Post by: Rbz on May 15, 2007
Here one way to play ym music using an dll, I know this isn't what you're looking for but I have included the VC++2005 source and maybe it can help you.

Download it from here ~605 kb:
http://www.rbraz.com/source/ST_Sound.zip

Title: Re: Newbie question on linking a static C++ library
Post by: Jim on May 15, 2007
It's definitely possible to use a VC library with freebasic.  Both rbraz and I have done it with the versions of PTC we put together.  You just have to set the right options.

Jim
Title: Re: Newbie question on linking a static C++ library
Post by: slippy on May 16, 2007
Hey dudes,

thanks for your replies and help - I'll definately investigate in this one more time ... and as soon as I get it working, I'll post my results here :)

Did I ever mention that your board really rocks? I've been looking a long time for such a good source of information related to demo-coding ^^

Cheers,
SLiPPY
Title: Re: Newbie question on linking a static C++ library
Post by: Jim on May 16, 2007
Thanks for the compliment!  It's great to be able to help keen people get their demos together!  Tell your friends :)

Jim
Title: Re: Newbie question on linking a static C++ library
Post by: slippy on May 18, 2007
Hi dudes,

I finally got it ... :) Although I didn't get the VC++ Express-Version to work with FreeBasic (something annoying with symbol names within the library produced by VC++ blocked my desperate efforts) ...

I just used DevCPP to compile my static library and with a bit tinkering I found the right settings ...

So as I promised in a previous posting I attached the working library with some examples ...

Have fun using it :)

Cheers ...
SLiPPY
Title: Re: Newbie question on linking a static C++ library
Post by: slippy on May 18, 2007
Here's a little oldskoolish sample screen using the library ...

:)

Title: Re: Newbie question on linking a static C++ library
Post by: Shockwave on May 19, 2007
*Shockwave waves his Karma wand*

Karma Boost! ++++

Thank you for sharing that lib, it could come in very very  useful indeed.
Nice example too.

Maybe you'll be one to look out for in the next competitions? :)
Title: Re: Newbie question on linking a static C++ library
Post by: ninogenio on May 19, 2007
Very nice! im shure this will be put to good use mate K+  :cheers:
Title: Re: Newbie question on linking a static C++ library
Post by: slippy on May 20, 2007
Thanks for this dudes :)

I really like your board ... and @Shockwave ... let's see, if I find time when you start a new competition I'll do something :)

Btw. atm I'm going to wrap a library similiar to the StSound Lib which emulates the 68k CPU and thus emulates the soundchips like Paula (AMIGA) and the YM2149 (ATARI) ... so with that lib you'll be able to replay oldskoolish musaxxs like for example FutureComposer 1.3/1.4 and all the others ...

I'm talking of the SC68 emulation lib ... though it seems to be hard work anyway ... let's see if I really manage to do a wrapper for FB (or at least for C++ with Sound Server functionality)

Cheers dudes,
SLiPPY
Title: Re: Newbie question on linking a static C++ library
Post by: taj on May 20, 2007
I'm not into this (not knowing basic :-() but thats obviously a _great_ contrib for the board so I too must add a little karma. Welcome on board dude!