Subject Re: Port Linux app to Win32
Author wazilian
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@...>
wrote:
>
> At 12:56 AM 13/10/2007, you wrote:
> >I've got an application running great on Linux which uses the
Interbase
> >API to access our Firebird database. Now I am required to port
this app
> >to Windows.
> >
> >I guess my question is, which compiler is required to do this? I
have
> >cygwin's gcc currently running. I don't have MSVC or Borland and
would
> >prefer to stay away from those. But if I need to, well then I need
to.
>
> Someone else could comment on any traps with non-MS compilers.
But,
> regardless of what compiler you use to compile your applications,
on
> Windows servers and clients you need the MS C and C++ runtimes in
> order to use Firebird. Usually, they have already been installed by
> other applications but, if not, there are copies in current
Firebird
> releases that you could gamble with; or you could do the more
robust
> thing and install the runtime packages from the MS site. From
> Firebird 2 onward, you also need the ICU libraries, which can be
> installed or updated from Firebird's icu sub-directory.

I am linking (dynamically) the win32 runtimes (msvcrt.dll). I
understand about the ICU libs.

> >If I can use cygwin (or perhaps even mingw), how can I correctly
link
> >against fbclient.dll? I've tried but of course I've come across the
> >dreaded __stdcall convention issues.
>
> Application code shouldn't be trying to statically link the dynamic
> client library. Is that what your Linux application does?

No, the Linux code is dynamically linking with the client lib

> >So I'm either completely missing the obvious (as usual) or I just
> >haven't found the correct thread(s) or documentation to help out.
>
> If you're determined to stick with the unwrappered API then you'll
> need the InterBase 6 beta docs volume, ApiGuide.pdf. You can find
> links to downloads in the Documentation Index at the Firebird
website
> ( http://firebirdsql.org/index.php?op=doc )

I am determined, short term, to stick with the unwrapped API because
there is just to much to change to use the IBPP that you (Helen) and
Milan have mentioned. I have looked into that project in the past but
am with the understanding that is for C++ code where mine code is C.
I appreciate the comments by you 2 however on that project.

> >Hopefully someone here can point me in the right direction.
>
> Does your Linux application use ibase.h and iberror.h as
> includes? They are the header files for the API and the
> exceptions. You can find them in the /include/ directory of the
> appropriate Firebird or InterBase installation. ibase.h contains
all
> the API function prototypes, structure typedefs, parameter
> definitions and macros that the various API functions need. (There
> is also some sample code in the /examples/api/ subdir.)

I am including only ibase.h. iberror.h appears to be included by
ibase.h.

> If you want to consider using platform-independent c++ wrappers for
> all of the API functions, etc., visit http://www.ibpp.org/ and/or
> google for 'IBPP'. Even if recoding isn't on your horizon at the
> moment, the reference and sample material at that site could
possibly
> help you into a zone of comfort...

Again, I appreciate the thought on using this project as that may be
the way I need to approach this thing. I was just hoping I guess to
get away with compiling for win32 easy enough (on Windows? Easy? HA!)
with cygwin. I've been using cygwin for awhile but would have no
problem with mingw. I just don't want to use MSVC or Borland if I can.

The "gcc" command and output below is what I've executed to attempt a
compile with all .dll's and .lib's in the current directory (just for
quick test). You can see it errors on undefinded references to
isc_attach_database which I'm including and linking everything I need
to, I believe. It appears this problem really stems from the stdcall
vs. cdecl calling convention. This may appear to be just a "C"
compile problem not related to Firebird, but I just can't seem to
shake this and was hoping there is just a Firebird hook I'm missing
here.


$ gcc -o test test.c -I. -I/usr/include/interbase -L. -lmsvcrt -
lfbclient
test.c: In function `main':
/cygdrive/c/DOCUME~1/travis/LOCALS~1/Temp/ccaZgbkT.o:test.c:
(.text+0x132): undefined reference to `_isc_attach_database@24'
/cygdrive/c/DOCUME~1/travis/LOCALS~1/Temp/ccaZgbkT.o:test.c:
(.text+0x140): undefined reference to `_isc_print_status@4'
collect2: ld returned 1 exit status


Executing the command again, after commenting out the __stdcall for
the ISC_EXPORT define on about line 75 of ibase.h, results in a clean
compile but corrupts the stack during a run of the exe.


23926 [main] test 2416 _cygtls::handle_exceptions: Error while
dumping state (probably corrupted stack)
Segmentation fault (core dumped)


Any thoughts? Thanks to Helen and Milan for their comments.

Travis