The initial concept and core of this add-in was developed by 'The Trick'. (VB6-Trick-Advanced-Tools)
I needed a stripped-down version of this to just intercept the linking events. Thus other features, also those who causes problems on compiling in some projects ('Global Checking' section, to remove integer overflow checks etc.), are not contained.
By using this linking events you can place a file location which will be shell executed (e.g. batch file).
Reasons for such need are for example to replaces .obj files with Cobj files in order to statically link an C library into the Std-EXE or Ax-DLL.
The batch file to replace .obj with .cobj file could look like this:
However, it detects and preserves in case there is a [TAT] section available from the Trick Advanced Tools to maintain compatibility. In case it is detected a checkbox will appear, giving the opportunity to preserve or break compatibility with the Trick Advanced Tools.
I get a message
LINK : fatal error LNK1181: cannot open input file "KERNEL32.LIB"
I found the KERNEL32.LIB so I put this
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\arm64\KERNEL32.LIB /OPT:NOREF /OPT:NOWIN98
In the addin, but I get another error:
...........Incremental Linker Version 6.00.8447
.............
LINK : fatal error LNK1181: cannot open input file "C:\Program.obj"
In replace_cobj.bat there are two statements for copy, but the files *.cobj not exist (there not in the zip file)
I use Windows 10 64bit
Any Idea
I'm trying to compile VBSQLite but I always get this error:
I also tried running the Add-In in source code, and I see that Function InitializeHooks runs fine, to the end (InitializeHooks = True), but in ModCallback Public Function TipFinishExe2_user is never called when I compile.
This usually means that LinkSwitches or .cobj external dependencies are prevent the linker from producing executable.
For instance having KERNEL32.LIB in LinkSwitches means that this .lib file has to be available in some path as listed in LIB environment variables (this is what standard link.exe uses).
You need to add LIB to to you env. variables with value of C:\Program Files (x86)\Microsoft Visual Studio\VC98\Lib or similar. This means you have to install VC6 along VB6 from setup.
I don't have VC installed now. But it is very strange to me that TipFinishExe2_user is never called when I compile anything.
I think this callback should be called when I compile a new standard exe project Project1.exe.
I'm using my own surrogate linker which automatically copies .cobj files to same named .obj if it finds these .cobj files in target directory. Krool had problems with it and that's why he created the add-in but I think I fixed couple of issues with command line parsing it had.
To use the surrogate linker you have to first rename original C:\Program Files (x86)\Microsoft Visual Studio\VB98\LINK.EXE to vbLINK.exe and then place surrogate linker's output binary (conveniently named link.exe) into C:\Program Files (x86)\Microsoft Visual Studio\VB98 folder instead.
From this point when linking in VB6 fails for one reason or another the surrogate linker dumps link phase output to ~$link.out file in %TEMP% folder so you can see exactly what is failing, otherwise it's impossible to debug any linking issue.
Another feature I use is to put /nologo option in LinkSwitches which is harmless but is treated by the surrogate linker as signal to clipcopy the whole link command it is about to execute and pause with a MsgBox while temporary .obj files as generated by VB6 are still available in target folder (and IDE is frozen).
While paused I can open a command prompt and paste+execute the command and observe the output, tweak command options, add .lib files until the linking succeeds and a working binary is produced finally. This is the only way to produce working hacks with .cobj files etc.
Sometimes you want to connect some DLL of VC++ to COM DLL of vb6, do not need to write Declare Function to re-declare the interface in the DLL, maybe you can use such a technique.
Just like the compilation of two functions into ABC.OBJ, VB6 module also has such a function, using this similar static compilation principle, to achieve VC++, the assembly of OBJ fusion into the VB6 compiler generated DLL,EXE.