Thread: Borland C++ 3.1 -- Using WATTCP library... Undefined symbol error... Please help =)

  1. #1
    Registered User jon_nc17's Avatar
    Join Date
    May 2002
    Posts
    15

    Question Borland C++ 3.1 -- Using WATTCP library... Undefined symbol error... Please help =)

    Hi Everyone,

    Its been a while since I've been on here! Anyway, I've been working on a program for my Home Automation system using (the very old) Borland C++ 3.1 with Turbo Vision for the text based GUI. I really want to have simple DOS based TCP connections in my program, and the library WATTCP exists just for this purpose, written for Borland C++ 3.1 specificly...

    Now, there are actually quite a few example programs that came with the library, and some are very simple.. for instance, ping.. The first step in all these programs is to initalize the socket using sockt_init(); welll.... it looks as if it would be that easy, but when I place that into my main function, I get the Undefined symbol sock_init(); error by the linker/compiler.

    I've read some things about how there can be problems when you have C & C++ source code togeather... and I'm thing that may have soemthing to do with it because I think the library was origionally written in C and my current program uses primarily C++... lol this might not have anything to do with it... I'm just guessing... But all of the header files are included right.. and I have the library added in, its just that when I add that one line of code it gives me that error....

    I would greatly apprecieate it if someone could give me some advice. If anyone has any questions you want me to clear up, just let me know and I will be glad to answer them.

    Thanks,

    Jon Scott
    [email protected]

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    This sounds like it could be a product of c++ name mangling. You can stop name mangling by using extern "C".

    Code:
    extern "C" {
    int c_can_use_this_function(void) {
        return 0;
    }
    }

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    On a side note. C doesn't know what extern "C" means and will throw an error. So you can just put

    Code:
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    /*put function here*/
    
    #ifdef __cplusplus
    }
    #endif

  4. #4
    Registered User jon_nc17's Avatar
    Join Date
    May 2002
    Posts
    15

    One step closer

    Well, I'm one step closer... I put the extern "C" { } around the include files for the library...

    Heres what I have now:

    After I did that, the program atleast compiled. Of couse it closes do to an error when you run it, but I think I might know what the problem is, just not how to fix it...

    In Borland C++ 3.1, when you use Turbo Vision, it requires the Large memory module -- not the small. So, my program is set to use the Large memory module in the options.

    When I compiled PING.C to make sure my library worked, it was using the small memory module. I also have Borland setup to compile all files ending in ".c" as C. When I ran the program, it worked perfectly.

    Now first I wanted to see if I renamed the extension to .CPP if it would still work. I did, and it didint compile. Then, I used the tips you guys gave me and put the extern "C" around the include files, and it worked. So thats the answer to the Undefined Sysbol error...

    So now the only difference between the two programs is that one uses the LARGE memory module (main program, and the other uses the SMALL memory module (test ping program).

    When I change dthe ping programs memory option from small to large, it crashed. Just like what my main program is doing.

    Now, would there be some command I should use somewhere, or is there soemthing I should look for in the WATTCP librarys to change it over? I know it can be done, because the program DOSLYNX uses Borland C++ 3.1 with Turbo Vision and WATTCP for TCP like mine. And I checked the project file in it, and the memory module is set to LARGE... but it works... Anotehr thing, I'm not sure what it is but its also set to DOS overlay, and not the normal DOS standered EXE... Not sure if that matters, or what its for.

    Does anyone have any suggestions, or questions I can clear up? I also want to thank you for your other response -- I would never had gotten that far! Thank you!

    Jon

  5. #5
    Registered User jon_nc17's Avatar
    Join Date
    May 2002
    Posts
    15
    Also, feel free to email me at [email protected].

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. undefined symbol
    By sworc66 in forum C Programming
    Replies: 3
    Last Post: 09-10-2003, 06:29 AM
  2. Undefined symbol 'stdprn'
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 07-03-2002, 02:05 PM
  3. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM
  4. whats wrong with this
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 02-07-2002, 03:40 PM
  5. Greenhand want help!
    By leereg in forum C Programming
    Replies: 6
    Last Post: 01-29-2002, 06:04 AM