-
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....
-
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!");
}
-
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.