7

Recently I discovered a problem on the midas and I fixed it, the problem now is that I want to use MidasLib not the midas.dll and with the source code I'm only able to build the DLL.

The source is C++ and I have very few knowledge with it. I know the MidasLib.pas uses internally midas.obj, so I need to create it to statically link the midas to my application. How to do it on C++ Builder? (XE)

Community
  • 1
  • 1
  • You might be better off patching the code in memory rather than trying to recompile. If you can locate that 255 in memory then all you need to do is a quite VirtualProtect modification and you will be golden. – David Heffernan Jan 04 '12 at 19:34
  • @DavidHeffernan Yeah! This really would be the best form, but how to find: 1 - the #define declaration; 2 - the line to be modified? – Carlos B. Feitoza Filho Jan 05 '12 at 02:29
  • @DavidHeffernan So, there are NO WAY to build midas.obj from the source code???? – Carlos B. Feitoza Filho Jan 05 '12 at 02:30
  • well, clearly it is possible to create those .obj files but I don't know how you would work it out – David Heffernan Jan 05 '12 at 07:23
  • Well, I have the source code, and I know how to fix the problem. Also, I know how to use the created obj into my Delphi Program, so, I need only create the midas.obj file. – Carlos B. Feitoza Filho Jan 05 '12 at 16:11
  • Well go ahead and compile the source with bcc32 then. – David Heffernan Jan 05 '12 at 16:14
  • :) Sorry... My english is bad. My source code generate a DLL (midas.dll) and the compilation generates several .obj files, BUT, no one of them is called midas.obj. My intention is to statically link midas.obj, but the correct version (compiled by me) – Carlos B. Feitoza Filho Jan 07 '12 at 02:59
  • it doesn't matter what the .obj files are called. Compile the .obj files and then link them. And then deal with the problems. One think you could do would be to put all the code into a single .cpp file and compile that. I've never attempted to link cpp statically. My guess is that it's harder. I would just find the 255 and overwrite it. – David Heffernan Jan 07 '12 at 09:29

1 Answers1

1

When you compile C++ code, the compiler creates an .OBJ file for each .CPP/.C file you have and saves them somewhere on your computer. What happens in most cases is that one would run a linker on all of those .OBJ files to join them into a single EXE or DLL, but in your case you don't need those results. Your C++ Builder is, like most programming IDEs, automatically doing both the compilation and linking.

If you just want the .OBJ, you need to find where in your project folder C++ Builder is placing its .OBJ files (called its "intermediate output", typically, as it is the intermediate step between compilation and linking). So you must have a source file called midas.cpp or midas.c that produces a corresponding output file called midas.obj.

jowo
  • 1,981
  • 17
  • 20
  • Yes! This was the answer that I was looking for. But unfortunatelly Embarcadero does not provide a midas.cpp, so no midas.obj this time. But I followed the David Heffernan approach and I have done a patch on the original midas.obj to get the expected behaviour. Thank you very much. Only to explain a little bit more: The .obj file is for .cpp file on C/C++ like the .dcu file is for .pas file on Delphi ;) – Carlos B. Feitoza Filho Jan 15 '12 at 01:26
  • Here is my fix (in portuguese, sorry): https://sites.google.com/site/carlosfeitozafilho/artigos/comoobtermensagensdeerroereconcileerrorcommaisde255caracteres – Carlos B. Feitoza Filho Jan 15 '12 at 01:34