Solved

link error:Unable to open input file 'COS.OBJ'

Posted on 2004-04-01
39
17,880 Views
Last Modified: 2007-12-19
when I edit any c program in turbo c 2.0 ,these program can be successfully complied but can't be linked . It display "link error:Unable to open input file 'COS.OBJ'".why?even like the flowing:
main( )
{}
If the configuration of  turbo c 2.0 is wrong.
0
Comment
Question by:chinaperrin
  • 19
  • 14
  • 3
39 Comments
 
LVL 17

Expert Comment

by:rstaveley
ID: 10738695
Look for turboc.cfg.

If your Turboc installation is in (say) C:\TC, it should be set up thus:

c:\TC\TURBOC.CFG
--------8<--------
-IC:\TC\INCLUDE
-LC:\TC\LIB
--------8<--------

It should be in the same directory as TC.EXE etc, and on your path.

In the lib directory (-L), you should have C0S.OBJ
0
 

Author Comment

by:chinaperrin
ID: 10738905
Thank you ,rsraveley
My turboc.cfg is ok,like your writing.The COS.OBJ file exists in the lib directory. I have checked.
 what should I do?
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10739677
Hi,

The c0s.obj file can get corrupted due to many reasons and this happens to many people.
U must have unzipped or downloaded the compiler from somewhere.

The simplest solution is copy the c0*.obj files from the setup zip file(or otherwise) into the
directory where it now exists and overwrite the existing file and u should be fine.

BTW,TurboC has c0s.obj for the small memory model,c0l.obj for the large memory model and so on,so copy the c0*.obj files instead of just the c0s.obj file
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 10739678
Does it work if you use the command line compiler/linker?

e.g. From the command prompt:

   tcc myfile.c

What error message do you get, if any?
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 10739683
It is a good point that ankuratvb raises... you could try building a medium model program, which would link c0m.obj.

  tcc -mm myfile.c

If that works and the small memory model doesn't, it is indeed the c0s.obj which is corrupt and you should download a fresh copy from Borland's museum.

See http://community.borland.com/museum/
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10739843
BTW,those are c0*.obj files (c[zero]*.obj) and not cos.obj

0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10739911
The TCC option is a good way to check whether the path for the LIB files is wrong or the file is corrupt.

u can use the -I and -L option to specify the include and the lib files.Specify the appropriate
directories(for lib files,give the dir where the c0*.obj files are located) and try running ur program.If it runs,that means the path is wrong,change it from the IDE using the
Options->directories menu option and specify the correct path.

Otherwise replace the c0*.obj files.
0
 

Author Comment

by:chinaperrin
ID: 10755765
It display the message following:
'
C:\turboc2>tcc noname.c
Turbo C  Version 2.0  Copyright (c) 1987, 1988 Borland International
noname.c:
Turbo Link  Version 2.0  Copyright (c) 1987, 1988 Borland International

        Available memory 442360

C:\turboc2>
'
I have tried the medium model
'C:\turboc2>tcc -mm noname.c
Turbo C  Version 2.0  Copyright (c) 1987, 1988 Borland International
noname.c:
Turbo Link  Version 2.0  Copyright (c) 1987, 1988 Borland International

        Available memory 442346

C:\turboc2>
'
It display the same link error-Unable to open input file 'C0m.OBj' when I link the file.
I have tried to replace the C0s.OBj  file and C0m.OBj file.but the link error still exist.
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 10755823
That means that your file exists and isn't corrupt. In the IDE, look at Options|Directories. Your library directories should include c:\turboc2\lib (assuming that's your installation directory).
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10756902
Try this as well just to be sure:

tcc -Ic:\turboc2\include -Lc:\turboc2\lib noname.c

where the path after -I and -L are ur include and lib directories(where u have the c0s.obj file)
Also,if this is the output u get:
>C:\turboc2>tcc noname.c
>Turbo C  Version 2.0  Copyright (c) 1987, 1988 Borland International
>noname.c:
>Turbo Link  Version 2.0  Copyright (c) 1987, 1988 Borland International
>
>       Available memory 442360
>
>C:\turboc2>
Where is the error here?U should have the noname.exe file in this directory.

If u get the error not in TCC but when u use the TC IDE,then u have to change the directories path as rstaveley has pointed out.


0
 
LVL 17

Expert Comment

by:rstaveley
ID: 10757040
> Where is the error here?U should have the noname.exe file in this directory.

That's what a successful compile and link looks like with the command line compiler. He is left with the problem of getting the IDE to work. I thought the IDE used c:\turboc\turboc.cfg for the default directory paths just like the command line compiler, but it seems not.
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10757157
In my turboc.cfg file,it just contains the default values for the -I and the -L directories
This is what i have:
-IC:\TC\INCLUDE
-lC:\TC\LIB

whereas my include and lib directories in the IDE are radically different from these.

I guess this is used only for the command line compiler.

chinaperrin:
Did u try changing the path?If not can u post what are the directories listed in Options->Directories and what is the actual path.(If they are exactly the same(character by character),pls ignore this comment.Just trying to make sure)

0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10757206
For the IDE,the directory info. is stored in tcdef.dpr file but thats not easily modifiable as it contains the info. in some encrypted form,changing thru the IDE should be much simpler.
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 10757270
> tcdef.dpr

I don't see this in my old installation, but I never actually used the IDE. Fool that I was, I didn't realise it was there, when I upgraded from Turbo C version 1, though I was a great proponent of the Turbo Pascal IDE.
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10757420
I have TurboC++ ver.3.0

I have been using the IDE for a long time now but now i have started using the command line compiler.
Its much better and generates much better and lesser size code as it doesnt link the EXE to all the libraries that i must've set once for some program once and they have been set ever since.

For e.g.i linked my graphics library once for some of my programs.That option has been set ever since and whenever i use the IDE,it links that library to all my programs thus increasing the size of my EXE.

When i use TCC,it almost reduces the size of my EXE by half,a very considerable amount.
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 10757652
I have a nasty suspicion that tcdef.dpr is something introduced with version 3.0.

> size of my EXE

Unless I'm mistaken, specifying spurious libraries shouldn't cause code bloat. It should only link the .obj files that it needs from them. Are you sure it isn't a case of debug being left enabled in your IDE?
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10757740
Even my obj file's size is reduced quite considerably(by about half) when i use TCC.

>Are you sure it isn't a case of debug being left enabled in your IDE?
I don't see any such option in my IDE.My options are the same as are for tcc except for the external library linkages.

0
 
LVL 17

Expert Comment

by:rstaveley
ID: 10757890
In the 2.0 IDE, I see you have Options | Compiler | Code Generation | OBJ debug information. I expect that it is lurking somewhere similar in 3.0.
0
Free camera licenses with purchase of My Cloud NAS

Milestone Arcus software is compatible with thousands of industry-leading cameras for added flexibility. Upon installation on your My Cloud NAS, you will receive two (2) camera licenses already enabled in the software. And for a limited time, get additional camera licenses FREE.

 
LVL 9

Expert Comment

by:ankuratvb
ID: 10758332
Ok.found it under Advanced Code generation.
Removed it also,it reduced the size of the EXE by about 3K but my obj file is still double that produced by TCC for the same code.
This time,i removed all options in the IDE.but still the result.
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 10758501
If you look at the .obj files with a binary editor do you see debug still in them?

BTW... I've just saved the IDE options. They are saved as a binary file called tcconfig.cfg in TurboC 2.0.
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10758608
>If you look at the .obj files with a binary editor do you see debug still in them?

No.
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 10758883
OK, I'll try hello.c on my set-up:

(1) Source:
--------8<--------
/*      HELLO.C -- Hello, world */

#include <stdio.h>

main()
{
        printf("Hello, world\n");
}
--------8<--------

(2) Build in IDE with
  (i) Options | Compiler | Code Generation | OBJ debug information | Off
  (ii) Debug | Source debugging | None
--------8<--------
11/05/1989  03:01               104 HELLO.C
05/04/2004  17:36             5,676 HELLO.EXE
05/04/2004  17:35               310 HELLO.OBJ
--------8<--------

(3) Build with command line compiler:
--------8<--------
11/05/1989  03:01               104 HELLO.C
05/04/2004  17:30             5,676 HELLO.EXE
05/04/2004  17:30               306 HELLO.OBJ
--------8<--------

Comparing the .obj files, I see that the IDE's obj has all of its symbols in upper case and the command line obj is all lower case. Odd, bearing in mind that there is nothing obvious in the IDE to suggest why the symbols are being converted to upper case in the compile (no... case sensitrive link doesn't do it), but the extra 4 bytes in the .obj isn't getting into the .exe.

What do you get from hello.c, ankuratvb?
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10763974
Hi rstaveley,

Thanx for ur help.

The source debugging option was on and that was causing the large size:

This is what i got:

(1)In the IDE:

hello1.obj 367
hello1.exe 6,646

(2)command line compiler:

hello1.obj 367
hello1.exe 6,446

0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10763995
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10764216
200 bytes b/w the 2 exe's.I guess thats marginal.must be another one of those options.:~)
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10764290
>(i) Options | Compiler | Code Generation | OBJ debug information | Off
>(ii) Debug | Source debugging | None

What problems can i have by removing these options?

coz my compiler started behaving strangely after i changed these options.

1. i always get a Linker Warning:No stack which vanishes if i change (i) to ON.

2. For my large programs,the IDE and the Output screen appear merged when i run my program.

3. I have to set (ii) to ON to run these 'large programs'(5208 LOC).Otherwise i get abnormal program termination.
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 10764500
Those 200 bytes suggest that there are some differences in the options. I'm not wild about compiler settings hidden away in menu structures. It would have been nice if Borland had provided something to export a Makefile.

> 1. i always get a Linker Warning:No stack which vanishes if i change (i) to ON.

In 2.0, you have:

    Options | Compiler | Code generation | Standard stack frame | On/Off
    Options | Stack warning | On/Off

What are these set to in your IDE?

You should be able to set the size if the stack by including the line:

    /* NB: This assignment should be outside a function body - you are preventing the
        linker from pulling in the default setting from the library by doing this */
    extern unsigned _stklen = 10*1024; /* 10K stack */

Conversely, you should be able to see what the default stack size is set up as with the code:

--------8<--------
/* Show preconfigured stack size */
#include <stdio.h>
extern int _stklen;
main()
{
        printf("Stack size is %d\n",_stklen);
}
--------8<--------

Do you get the linker warning, when you set Options | Compiler | Code Generation | OBJ debug information | Off  and build this program? [I'd expect this to ensure that the library stack code gets linked.]

> 2. For my large programs,the IDE and the Output screen appear merged when i run my program.
> 3. I have to set (ii) to ON to run these 'large programs'(5208 LOC).Otherwise i get abnormal program termination.

Do you mean large memory model programs or complex (lots of code) programs? If you are routinely using a library or set of modules, in these programs it could be that you have a wild pointer lurking in them and the default command line settings and debug IDE settings happen allow you to get away with them. Or this could be related to the stack.

Turbo C version 2.01 can be downloaded from http://community.borland.com/article/0,1410,20841,00.html and is only just over 1M. I'd be curious to know if you get the same when building your code with that. The TCINST.EXE utility sets up the configuration, but if you take a default configuration and then try it with debug disabled, we'd be using the same yard stick.
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10764559
>   Options | Compiler | Code generation | Standard stack frame | On/Off
>   Options | Stack warning | On/Off
>What are these set to in your IDE?

Both are ON.

>Do you get the linker warning, when you set Options | Compiler | Code Generation | OBJ >debug information | Off  and build this program? [I'd expect this to ensure that the library >stack code gets linked.]

Yes,but only when i set it to OFF.When i turn it back to ON,the warning vanishes.

>Do you mean large memory model programs or complex (lots of code) programs? If you >are routinely using a library or set of modules, in these programs it could be that you >have a wild pointer lurking in them and the default command line settings and debug IDE >settings happen allow you to get away with them. Or this could be related to the stack.

I use Huge Memory Model and the LOC is right now around 5 KLOC
The program works even then ,just that the o/p screen and the IDE screen come merged.
i.e. my background should be black but i get a blue background which is the bgcolor of the IDE and the o/p comes on top of that.
And the program works fine when i change both (i) and (ii) back to ON.
This program has been tested in various compilers and it works fine.

I'll try downloading and executing my program on TC2.01

0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10764603
Hi chinaperrin,

If u think this discussion is related to ur problem here,pls see the continuation here.
http://oldlook.experts-exchange.com:8080/Programming/Programming_Languages/C/Q_20944837.html

We thought this might be off-topic for u so why bomb ur mailbox(even though we might have done that already).

Pls respond as to whether ur problem has been solved or not.
0
 

Author Comment

by:chinaperrin
ID: 10782140
Hi . ankuratvb and rstaveley.
First, I apologize to you.I don't instantly send my result.
I try the command line compiler.The result is like what  ankuratvb  said -I get noname.exe. I have check the options in IDE.The directory
>
 Include directories:  C:\TURBOC2\INCLUDE
 Library directories:  C:TURBOC2\LIB
>
In my turboc.cfg file, it contains the value :
-IC:\TURBOC2\INCLUDE
-LC:\TURBOC2\LIB

why the link error exist in IDE but not  in command line compiler.
 
Thank you for give many advice to sovle the problem.
0
 
LVL 9

Accepted Solution

by:
ankuratvb earned 100 total points
ID: 10782250
What is happening is the IDE is not able to find the c0*.obj files required for linking,
>Library directories:  C:TURBOC2\LIB
                                     ^
The path should be C:\TURBOC2\LIB or was it just a typo in your post.
I removed the \ from my path and my compiler crashes on linking.
This could be the problem.Try changing it to C:\TURBOC2\LIB


0
 
LVL 17

Expert Comment

by:rstaveley
ID: 10831125
> my compiler crashes on linking

That's not very graceful! Does it hang? Does it also happen if you link directly with tlink.exe?
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10849982
Hi rstaveley,

>That's not very graceful! Does it hang?
No.it gives an invalid exception error and crashes.

>Does it also happen if you link directly with tlink.exe?
No.(strangely).It works ok with TCC but not with the IDE.

BTW,i installed TC 2.01.

chinaperrin,

Your problem should be that missing \ in your library path.
Library directories:  C:TURBOC2\LIB

I did the same and got the same error that you got.
It should be c:\turboc2\lib

0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 11427477
I'm sure that was the OP's problem(i tried it using the same compiler),but a split would be fair.
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 11427644
A split would be nice, but I think your right that ankuratvb's http:#10782250 was the fix.
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 11427734
Oops...

> your

you're

I hate it when I do that.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now