Linking with two objects

This is a discussion on Linking with two objects within the C Programming forums, part of the General Programming Boards category; Hi, Brief background...I am not a trained C programmer but am the poor soul left to update legacy C programs. ...

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    20

    Linking with two objects

    Hi,
    Brief background...I am not a trained C programmer but am the poor soul left to update legacy C programs. One particular program requires use of BTRV API (instead of Scaleable SQL API) due to an impending upgrade to Btrieve 8. The C compiler is Microsoft version 6.00A and the Linker is version 5.10.

    ??? My first problem is understanding the correct syntax for linking two objects?

    The procedure I use is to open a DOS window, run a batch file that sets up the path, includes, etc. and then run a batch file that does the compile and link.

    Firstly, I compile btrapi.c (compile only) to create btrapi.obj using this:
    cl -c /AM /Zp /Od btrapi.c
    This works fine, as far as I can tell, apart from three name truncation warning messages.

    Then I compile and link the application program. Originally, when just one object, I used this supplied batch file :
    cl -c /AM /Zp /Od xxxxxx.c
    link xxxxxx.obj, xxxxxx.exe,, xqlintf.lib, /ST:10240 /NOE
    [Note, I have masked the application name].

    >>> Now, with the additional object, I have tried variations such as
    cl -c /AM /Zp /Od icrsex1a.c
    link xxxxxx.obj, btrapi.obj, xxxxxx.exe,, xqlintf.lib, /ST:10240 /NOE
    or
    cl -c /AM /Zp /Od icrsex1a.c
    link xxxxxx.obj btrapi.obj, xxxxxx.exe,, xqlintf.lib, /ST:10240 /NOE
    but
    get errors. I'll post the errors later, once I know and have tried the correct link method.

    Many Thanks....

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    The basic style for linking two objects. I can't gaurantee this is accurate for your linker version.
    Code:
    C:\usr\home\jgalloway\toy\link>cl /c main.c
    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
    Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
    
    main.c
    
    C:\usr\home\jgalloway\toy\link>cl /c foo.c
    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
    Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
    
    foo.c
    
    C:\usr\home\jgalloway\toy\link>link /out:foo-style.exe main.obj foo.obj
    Microsoft (R) Incremental Linker Version 7.10.3077
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    
    C:\usr\home\jgalloway\toy\link>foo-style.exe
    Hello World, foo-style!
    C:\usr\home\jgalloway\toy\link>

    The source files, for reference.
    Code:
    // foo.c
    void foo(void);
    
    int main (void) {
       foo();
    }
    Code:
    // main.c
    #include <stdio.h>
    
    void foo (void) {
       printf ("Hello World, foo-style!");
    }
    Callou collei we'll code the way
    Of prime numbers and pings!

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    20
    Just wanted to say thank you for your reply.

    Before reading it, I tried using cl for the link as well
    i.e. cl xxxxxxxx.obj btrapi.obj xqlintf.lib
    and it appears to have worked.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 60
    Last Post: 12-20-2005, 10:36 PM
  2. Linking objects to your C++ projects
    By Dwizard in forum Windows Programming
    Replies: 5
    Last Post: 09-24-2005, 07:11 PM
  3. chain of objects within pop framework help needed
    By Davey in forum C++ Programming
    Replies: 0
    Last Post: 04-15-2004, 10:01 AM
  4. Linking objects internally
    By bennyandthejets in forum C++ Programming
    Replies: 3
    Last Post: 02-25-2004, 01:34 AM
  5. linking objects
    By doleman19 in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2001, 11:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21