Menu

Compiling for Borland C++ Builder + tcpstream

Help
2003-10-22
2004-06-09
  • Rami Saarinen

    Rami Saarinen - 2003-10-22

    I'm currently trying to get the commoncpp compiled with BCB5 (on win2k) and having some trouble with it. Switching from BCB5 is not an option at the moment and I'd really like to have the cc++ at hand. To this point I have been developing in Linux, but I want to make the project to work on Windows too (hence I chose the ccpp at the first place). All I really need is the threading and network functionality.

    After several feeble attempts I chose to edit (with my limited makefile writing abilities) the BCC5 makefile as my make version did not have a clue about the '%' stuff (nor did I). You find the modiefied version at the end of this message (sorry about the size). I also added "#define __MT__" to config.h

    To my surprise all files compiled nicely (after I have added the winsoc stuff, as instructed by a friend). There are warnings during (I guess) the creation of the LIB file: 

    Borland Implib Version 3.0.22 Copyright (c) 1991, 2000 Inprise Corporation
    Warning duplicate symbol: @ost@Exception@what$xqv
    Warning duplicate symbol: @ost@Exception@what$xqv
    Warning duplicate symbol: @ost@Exception@what$xqv
    Warning duplicate symbol: @ost@Thread@final$qv
    Warning duplicate symbol: @ost@Thread@getExtended$qv
    Warning duplicate symbol: @ost@Thread@getExtended$qv
    Warning duplicate symbol: @ost@Thread@initial$qv
    Warning duplicate symbol: @ost@Thread@notify$qp10ost@Thread
    Warning duplicate symbol: @ost@Thread@notify$qp10ost@Thread

    Ok. As brute force and ignorance usually works in situations like this I decided to give it a try nonetheless. First I tried to compile the thread1.cpp test program with:

    $ bcc32 -WC -lap -I..\\..\\include -I..\\ ws2_32.lib ccgnu2.lib thread1.cpp

    Some warnings of type (there is usually quite a lot of them):
    "Warning W8026 ..\..\include\cc++/exception.h 87: Functions with exception specifications are not expanded inline"

    But thread1.exe executes nicely without a problem. Now I tried tcpstr1.cpp with:

    $ bcc32 -WC -lap -Lc:\\progra~1\\borland\\cbuilder5\\lib -I..\\..\\include -I..\\ ccgnu2.lib ws2_32.lib tcpstr1.
    cpp

    Again lot of those inline warnings (and about argc and argv not used in main).  And running the tcpstr1.exe causes:

    "The instruction at 0x... referenced memory at 0x... The memory could not be "read""

    and so on for 14 times, some of them about memory could not be "written". I took a look and found that the probles start on line " tcpstream tcp("127.0.0.1:96000");" inside the ThreadOut class.

    I'd be very happy for any kind of feedback and ideas. Pretty please? Needless to say that I'm not so familiar with developing on windows.

    Thanks!

    ----------------------------------------------------

    Here's the Makefile.bcc:

    # GNU Makefile to build CommonC++ using Borland CC 5.5.1

    prefix = c:\\progra~1\\borland\\cbuilder5
    includedir = $(prefix)\\include
    bindir = $(prefix)\\bin
    libdir = $(prefix)\\lib

    BCC = bcc32.exe -w- -tWM -I..\\win32 -I..\\src -I$(includedir) -I..\\include
    ILIB = ilink32.exe -L$(libdir) -L$(libdir)\\psdk -c -Tpd ws2_32.lib wsock32.lib
    IMPLIB = implib.exe -c

    LIBS = cw32mt import32

    OBJS = inaddr.obj socket.obj peer.obj mempager.obj threadkey.obj keydata.obj mutex.obj exception.obj slog.obj semaphore.obj thread.obj event.obj peer.obj file.obj friends.obj port.obj

    ccgnu2.dll ccgnu2.lib:
        $(ILIB) c0d32 $(OBJS), $@, ,$(LIBS)
        $(IMPLIB) ccgnu2.lib ccgnu2.dll

    all:  ccgnu2.dll ccgnu2.lib

    ccgnu2.dll: thread.obj threadkey.obj event.obj file.obj friends.obj exception.obj mutex.obj port.obj inaddr.obj peer.obj socket.obj slog.obj mempager.obj keydata.obj semaphore.obj

    clean:
        $(RM) *.dll *.lib *.ilc *.ild *.ilf *.ils *.map *.tds *.obj

    inaddr.obj: ..\\src\\inaddr.cpp
        $(BCC) -c ..\\src\\inaddr.cpp

    socket.obj: ..\\src\\socket.cpp
        $(BCC) -c ..\\src\\socket.cpp

    peer.obj: ..\\src\\peer.cpp
        $(BCC) -c  ..\\src\\peer.cpp

    event.obj: ..\\src\\event.cpp
        $(BCC) -c  ..\\src\\event.cpp

    file.obj: ..\\src\\file.cpp
        $(BCC) -c  ..\\src\\file.cpp
    friends.obj: ..\\src\\friends.cpp
        $(BCC) -c  ..\\src\\friends.cpp
    port.obj: ..\\src\\port.cpp
        $(BCC) -c  ..\\src\\port.cpp

    mempager.obj: ..\\src\\mempager.cpp
        $(BCC) -c  ..\\src\\mempager.cpp

    thread.obj: ..\\src\\thread.cpp
        $(BCC) -c  ..\\src\\thread.cpp

    threadkey.obj: ..\\src\\threadkey.cpp
        $(BCC) -c  ..\\src\\threadkey.cpp

    keydata.obj: ..\\src\\keydata.cpp
        $(BCC) -c  ..\\src\\keydata.cpp

    mutex.obj: ..\\src\\mutex.cpp
        $(BCC) -c  ..\\src\\mutex.cpp

    exception.obj: ..\\src\\exception.cpp
        $(BCC) -c  ..\\src\\exception.cpp

    slog.obj: ..\\src\\slog.cpp
        $(BCC) -c  ..\\src\\slog.cpp

    semaphore.obj: ..\\src\\semaphore.cpp
        $(BCC) -c  ..\\src\\semaphore.cpp

     
    • David Sugar

      David Sugar - 2003-12-17

      Some issues with headers and import/export for dll functions have only recently been solved completely for w32 targets, and are reflected in what's now in cvs for the 1.1.0 release.  I suspect this issue is with prior releases where sometimes they did not properly seperate when importing vs when exporting, and hence created duplicate symbols or clashes when linking between ccgnu2.dll and ccext2.dll.

       
      • Rami Saarinen

        Rami Saarinen - 2003-12-17

        Thanks David,

        If I recall right I created a static library manually from the object files and that has been working ok.

        I'll try to update later on to see if I can get it working "out-of-box". 

         
    • Jen C

      Jen C - 2004-06-09

      Hi,
      I used your make file and had to do a bit of editing. First i had to add dir.obj, string.obj and str.obj to the OBJS line and to the build line.
      Also, this line:
      ILIB = ilink32.exe -L$(libdir) -L$(libdir)\\psdk -c -Tpd ws2_32.lib wsock32.lib
      should be changed to:
      ILIB = ilink32.exe -L$(libdir) -L$(libdir)\\psdk -c -Tpd

      and this line:
      LIBS = cw32mt import32
      should be changed to:
      LIBS = ws2_32 wsock32 import32 cw32mt

      (ws2_32 and wsock32 are libraries so they should be on the library lines).

      To fix the warnings about duplicate symbols I moved the implentation for
      what
      final
      getExtended
      initial
      notify
      to their respected source files.  Even though the implementation was just "return;" there is a problem with the code being linked multiple times and thus the symbols being put in the dll multiple times.

      It's taken me about 3 days to get this far... so much for this being a shortcut.

      My borland app still doesn't run.  Whenever I try to access any of the classes in the dll an exception is thrown... looks like the dll is failing to initialize... any ideas on that one?

      -jen

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.