Results 1 to 9 of 9

Thread: VB6 IDE Linker AddIn

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    2,041

    VB6 IDE Linker AddIn

    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:
    Code:
    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:
    Code:
    [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.
    Name:  VB6IDELinkerAddInPic.jpg
Views: 2256
Size:  23.2 KB
    Attached Files Attached Files
    Last edited by Krool; Sep 16th, 2018 at 12:14 PM.

  2. #2
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,073

    Re: VB6 IDE Linker AddIn

    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

  3. #3
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,073

    Re: VB6 IDE Linker AddIn

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

  4. #4
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,404

    Re: VB6 IDE Linker AddIn

    I'm trying to compile VBSQLite but I always get this error:

    Name:  VBSQLite compile error.jpg
Views: 110
Size:  13.7 KB

    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.

  5. #5
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Posts
    4,094

    Re: VB6 IDE Linker AddIn

    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>

  6. #6
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,404

    Re: VB6 IDE Linker AddIn

    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.

  7. #7
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Posts
    4,094

    Re: VB6 IDE Linker AddIn

    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>

  8. #8
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,404

    Re: VB6 IDE Linker AddIn

    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.

  9. #9
    Hyperactive Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    378

    Re: VB6 IDE Linker AddIn

    Quote Originally Posted by Krool View Post
    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???

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width