开发者

DOS-reported error: Bad file number

I have a batch file that tries to compile a static library using Borland C++ Builder 6.0

It is called from Borland make (makefile created with bpr2mak) which is called from a .bat file (used to compile the whole project with Visual Studio and some Borland C++ Builder legacy projects), which is called from a bash shell script running inside Cygwin.

When I run the .bat file directly from a Cygwin shell, it runs OK, but when its being run from a Program calling cygwin with Boost::Process::launcher I'm getting this error:

C:\ARQUIV~1\Borland\CBUILD~1\Bin\..\BIN\TLib /u bclibs.lib @MAKE0000.@@@

DOS-reported error: Bad file number

TLIB 4.5 Copyright (c) 1987, 1999 Inprise Corporation

opening 'MAKE0000.@@@'

** error 1 ** deleting bclibs.lib

It's a complicated scenario, but this Program which calls cygwin is run whenever we need to build our software package which needs to be build for various Linux distos and Windows 32 and 64-bit.

Note: It's the only Borland Project failing, the other compile j开发者_StackOverflow社区ust fine (it's the only static library using borland also, so it can be some problem with the TLib tool.


The problem was that TLib does not like to have his output redirected (seen here) without having an input pipe as well. Solved by creating an input pipe to in the Boost::Process::launcher using set_stdin_behavior


I'm just guessing here, but this may have to do with long filenames and/or spaces in paths.

1) Modify your makefile so it would save current environment to a file, immediately before executing the failing command (set > d:\env.txt & echo CD=%CD% >> d:\env.txt). Then run it both ways (directly and via program) and compare the environments of good run and bad run.

2) Using filemon from Sysinternals, capture logs of disk access in both cases (these logs are going to be huge, though you can uncheck everything except Open in the filter to reduce the size). Again, compare and check for clues...

3) Try instaling everything involved to paths conforming to 8.3 scheme.


This error is not related to C++ itself. It happens when your build script opens too much files (more than defined in DOS command processor environment). To resolve this issue try to set value of files variable to 253. For Windows XP this variable defined in the file %WINDIR%\system32\config.nt.

files=253


Seems it is known bug in Borland C++ tools. Here is description and possible workaround for this issue:

Problem: Some static Lib projects will not link correctly when compiled. You might see something like this :

J:\Borland\CBUILD~1\bin\..\BIN\TLib /u debug\jpegD.lib @MAKE0000.@@@
DOS-reported error: Bad file number
TLIB 4.5 Copyright (c) 1987, 1999 Inprise Corporation
opening 'MAKE0000.@@@'

** error 1 ** deleting debug\jpegD.lib
MAKE failed, returned : 1

Workaround : In some cases (where the "Bad file number" error is seen) it may be possible to work around this by specifying -tDEFLIB.BMK in the BPR2MAKE Options field, and Turning off the "Capture Make Output" option.

I have not tested it, but I hope that helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜