# VBForums UtilityBank > UtilityBank - IDE Add-Ins >  VB6 IDE Linker AddIn

## Krool

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:


```
del xyz.obj
copy xyz.cobj xyz.obj
```

Real life example is the sqlite3win32 project from 'VBForumsCommunity' to Staticly compile sqlite3 into a VB6 project.

This add-in will write to the [VBCompiler] section of an .vbp file:


```
[VBCompiler]
LinkSwitches=KERNEL32.LIB /OPT:NOREF /OPT:NOWIN98
LinkBefore=replace_cobj.bat
```

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.

----------


## georgekar

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

----------


## georgekar

I get the files from git, and finally i have a bin file with the 3 files:
sqlite3win32.dll
sqlite3win32helper.cobj
sqlite3win32stubs.cobj

----------


## Eduardo-

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.

----------


## wqweto

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.

cheers,
</wqw>

----------


## Eduardo-

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.

----------


## wqweto

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.

cheers,
</wqw>

----------


## Eduardo-

Thanks, with the link.exe surrogate now I can see the error:

VBLINK : fatal error LNK1181: cannot open input file "KERNEL32.LIB"

I copied KERNEL32.LIB in several places but keep getting the error, I suppose I'll have to just install VC6.  :big yellow:

----------


## Episcopal

> 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.


Forgive me, but does this make the program faster???

----------

