[16-bit DOS] Cannot link properly Borland-based static library #528
Replies: 38 comments
-
Do you have full source code for all libraries used by your code except C run-time? |
Beta Was this translation helpful? Give feedback.
-
Sadly, I do not have source code for those libraries. But I do have listing files generated from 7188EL library both by WLIB and TLIB (Borland library manager). Also linker referred to the reference located in module PRINT, so I extracted it from the library, then disassembled it. I've got this result:
|
Beta Was this translation helpful? Give feedback.
-
The problem is that OW use registry based calling convention for 16-bit C run-time library Potential solution could be to compile C code with standard OW setup and create auxiliary library with thunks to emulate C run-time library functions used by these libraries.
and disassembled code of translation thunks is
You should create thunks for calling Open Watcom code from Borland code and for calling Borland code from Open Watcom code in dependency on what happen. This doesn't requires change in code only you must create thunks libraries and link them with application and original Borland libraries (not C run-time library, it will use Open Watcom C run-time library). But take into account it is only concept which you must check before use it for your solution. |
Beta Was this translation helpful? Give feedback.
-
Use of -ecc compiler option simplify things that thunks for calling Borland code from Open Watcom code will not be necessary because OW will generate __cdecl calling directly, but C run-time library uses OW registry calling convention that thunk for calling OW C run-time library function from Borland code is necessary. |
Beta Was this translation helpful? Give feedback.
-
Next posibility is to create OW 16-bit C run-time library with __cdecl calling convention, modify OW header files to use __cdecl calling convention and use -ecc compiler option. It should resolve it generaly but it requires to create special version of C run-time library and appropriate header files. I think the previous solution is better for compatibility for future code. |
Beta Was this translation helpful? Give feedback.
-
OK, so I've performed conversion of InitLib() and Print() function, compiled the object file, added to a custom library, linked it to target... And voila! - executable file is created, definitions are resolved. BUT! I uploaded .exe file into controller memory and attempted to run it. All I got was "Stack Overflow!" error message. The same program compiled with BC works as intended - it prints a string into console. Is it possible that my workaround caused a call loop? I assume those functions calling each other may cause a recursion... |
Beta Was this translation helpful? Give feedback.
-
You can not use both thunks together as in my sample. It was only for demonstration in one source. |
Beta Was this translation helpful? Give feedback.
-
Next problem could be startup code, if your controler has no Operating system. |
Beta Was this translation helpful? Give feedback.
-
If I take your previous info then you need only _vsprintf thunk for your sample if -ecc option will be used.
|
Beta Was this translation helpful? Give feedback.
-
My bad. I suspected it would be weird to set up thunks like that. With the solution mentioned above I was able to compile and link project successfully with no errors. All I needed to do was to add .c as a source file - no need for assembling a separate lib. Here's map:
Unfortunately, I won't be able to test the sample program on controller until tomorrow. For now I will attempt to create a complex thunk for all i7188EX functions that throw "Undefined symbol" error with -ecc flag. |
Beta Was this translation helpful? Give feedback.
-
Regarding the controller's OS: i7188EX has a DOS-based operating system called MiniOS7. It operates just like any DOS system and has its own C API. The controller's manufacturer provides specialized IDE (MiniOS7 Studio) for making C/C++ executable programs for their hardware. The default compiler IDE uses is Borland C++ 3.1. During the compile step it takes -1 and -ml flags, which is reasonable, given that the controller is 80188-based. Instructions on setting up compatible compilers are providing the same flags. |
Beta Was this translation helpful? Give feedback.
-
Linker map looks OK. |
Beta Was this translation helpful? Give feedback.
-
I got that part with serial ports covered. I use COM1 connection for uploading programs and monitoring them through IBM PC host. Even though, I had no tools for a proper debugging at my disposal till now, so it might be worth taking a shot. |
Beta Was this translation helpful? Give feedback.
-
I have some communication with ICPDAS technical support about MiniOS7 and DOS functions necessary for OW debugger are not supported by MiniOS7 therefore use of OW remote debugging is not possible. |
Beta Was this translation helpful? Give feedback.
-
Sad to hear about the debugger. I couldn't make it work anyway. Yeah, MiniOS7 is DOS-based, yet it doesn't fuction as the real DOS system. In fact, it has its own command set for controller operating. Sorry for not responding for a while - got some work unrelated to this issue to do. The good news is that I managed to run the sample program succesfully. It outputs the designated string into the monitor as intended. The bad news is that I've failed to build my project due to linker throwing the error "__turboFloat is an undefined reference" with no note about reference source. I was able to find the symbol in Borland's MATHL library, though. There's a bunch of functions from 7188E library used in my project that may be connected to MATHL, so I've got to find out which one is strictly tied to it. |
Beta Was this translation helpful? Give feedback.
-
Good news. Thunks currently used can be lower then maximum, that if you add all to auxiliary library you can use it for other projects without change where can be used more thunks. Linker select only thunks which are actualy used by program. |
Beta Was this translation helpful? Give feedback.
-
Anyway I got following info from ICPDAS technical support. The following is a list of all INT 21h services handled by MiniOS7: It could be useful for you. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
The problem is not on C language level there is no reason to change anything. I can not help you much if I have no access to appropriate hardware. |
Beta Was this translation helpful? Give feedback.
-
I was contacted by ICPDAS technical support with interest to create test Open Watcom version of libraries for MiniOS7 (see bellow). I don't know if you are interesting in get OW version of appropriate libraries for direct compile and link C code for controllers without need to use Borland version of libraries with appropriate code thunks etc. Hi Jiri, We are going to improve the MiniOS7 libraries to make it to be compatible with Watcom C/C++ compiler, and it will take a couple of months to complete this task. Best regards ICP DAS CO., LTD. |
Beta Was this translation helpful? Give feedback.
-
Glad to hear that. I wouldn't ask for specific libraries, but i7188EL.LIB and X304.LIB (libraries for the controller and I/O add-on) would be useful. The functions I mostly use are analog read/write functions and LED indicator's functions. |
Beta Was this translation helpful? Give feedback.
-
Pleas contact me directly to include you in direct communication with ICP DAS. |
Beta Was this translation helpful? Give feedback.
-
I have successfully used openwatcomv2 with i7188XB (same family with i7188EX) controller Several issues that I had to resolve:
With empty __chk8087() watcom assumes that FP is not presented (which is actually true) |
Beta Was this translation helpful? Give feedback.
-
Thanks for your info.
|
Beta Was this translation helpful? Give feedback.
-
Please, could you send me copy of X508.lib to check linker stuff for OMF libraries and fix it. |
Beta Was this translation helpful? Give feedback.
-
-ecc option it's good, but I want I send needed files to reproduce trouble with X508.lib i try it with steps to repack and build
|
Beta Was this translation helpful? Give feedback.
-
It looks like the library uses non-standard library header or header is damaged. |
Beta Was this translation helpful? Give feedback.
-
It looks like Borland TLIB bug, incorrect file offset to symbol dictionary. |
Beta Was this translation helpful? Give feedback.
-
I add wlink message about damaged library by commit 4d4e3bb |
Beta Was this translation helpful? Give feedback.
-
It is not possible to fix it because Borland library has also damaged symbols dictionary. |
Beta Was this translation helpful? Give feedback.
-
I'm working on migrating my code project for 80188-based controller i7188EX. So far the project had being successfully compiled with BC3.1, but currently I've got a need to use the compiler compatible with 64-bit host systems. Unfortunately, when I tried to compile and link the project (while using the same settings from Borland compiler - target processor, memory model, include directories, etc.), all I got were numerous "Undefined reference" errors.
Consider this simple template program, for instance:
The header file in the include line to several system headers (stdio, stdlib, dos, math, mem, string, ctype, conio) and a lib header chosen by defined model name (i7188EX, in my case). Functions InitLib() and Print() are included in 7188EL.LIB, the library the program was supposed to link to. Here is the process log:
While looking and researching for solution, I found out the conflict may be caused by different naming conventions used by Borland C and Open Watcom. I added parameter -ecc to compiler command line, and got this instead:
The function InitLib() passed succesfully, while Print(), on the other hand, threw an error: the linker cannot find the definition of vsprintf (described as _vsprint because of cdecl) inside lib file. I attempted to compile my project as well, and there were several undefined references "_malloc" and "_free".
Is there any way to resolve the naming conflict so I can utilize controller libs? As I've mentioned before, they link perfectly fine in Borland C.
Any help regarding this matter would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions