IonicWind Software

IWBasic => General Questions => Topic started by: Andy on March 04, 2018, 12:46:22 AM

Title: Cannot link exe files
Post by: Andy on March 04, 2018, 12:46:22 AM
This is a frustrating and strange one.

For some reason, I can only compile any program once, on the next compile (even not choosing to execute as well) I'm getting a linking error.

Compiling Resources...
No Errors

Compiling...
win2.iwb

Linking...
IWBasic Linker v1.11 Copyright © 2011 Ionic Wind Software
Generating c:\10\win2.exe
Error: Unable to open output file c:\10\win2.exe
Error(s) in linking c:\10\win2.exe


Here win2 is simply the "Hello world" open window example that comes with IWB.

When building library files, I get this on second build:

Creating Library...
Error: Could not create temporary link file C:\IWBDev3\libs\link_static.bat


I've tried different folder locations, check permissions, tried turning off my Avast AV, even re-installed IWB - still the same problem.

I've scanned the whole drive for any virus - it's clean.

Even tested the hard drive with the Seagate tools - again, it's good.

Help!!!!!!!!!
Title: Re: Cannot link exe files
Post by: Brian on March 04, 2018, 03:01:39 AM
Have you checked Task Manager to see if there any parts of your program still running?

Brian
Title: Re: Cannot link exe files
Post by: Andy on March 04, 2018, 03:24:49 AM
Yes I did that,

No it wasn't running.

This is a very strange one.

Title: Re: Cannot link exe files
Post by: Andy on March 04, 2018, 06:56:55 AM
After spending most of the day trying to fix the problem, I decided to wipe the partition and re-install everything.

Now everything is okay again.

What caused the problem, I don't know, at least I can compile again.

Title: Re: Cannot link exe files
Post by: Brian on March 04, 2018, 07:07:00 AM
Well, that sounds drastic! But if it worked, that's OK. Strange one . . .

Brian
Title: Re: Cannot link exe files
Post by: Andy on June 27, 2019, 06:59:27 AM
The linking error has returned again.

I can build / run / exit an .exe file, manually delete it and repeat the build / run - that's fine.

If I repeat build / run / exit without manually deleting the .exe I get the linking error.

When I get the linking error and right click on the .exe file the "Delete" and "Rename" options now have the administrator shield symbol showing - and it won't let me delete it.

If a wait around 45 seconds, the .exe file gets deleted (without me doing anything).

So the problem must be in the linker file.

This is nothing to do with user rights etc, it is like the linker is unable to delete the existing exe file fast enough / or the OS is taking too long?

Tried all the usual things, including ownership of the folders, IWBDev files, re-installing IWB etc.

Brian came up with a solution for him by removing some IWB registry entries, but I don't have anything like Brian's in my registry - and yes I'm sure the .exe isn't still running.

Any ideas?




Title: Re: Cannot link exe files
Post by: LarryMc on June 27, 2019, 08:17:47 AM
I've never seen or heard of that before Andy.  I'll have to do some looking to see if I can find anything.
Title: Re: Cannot link exe files
Post by: billhsln on June 27, 2019, 08:35:38 AM
I have run into this a few times and you do have to find it in 'Task Manager', however, it was not running under 'Apps', it was running under 'Background Processes'.  It happened often enough I created a batch file to remove it.

Sample:
Taskkill /T /F /IM order_entry.exe
Hope that helps,
Bill
Title: Re: Cannot link exe files
Post by: Andy on June 27, 2019, 10:03:56 AM
Thanks guys,

Bill, sorry that doesn't help.

I made an exe from the OPENWINDOW example in the help file - called it 1234.exe

It just does the same as all the others.

Looked into processes etc, just lists it as "Terminated", and until it disappears from the list (task man) it won't work.

Andy.
 
Title: Re: Cannot link exe files
Post by: billhsln on June 27, 2019, 10:10:05 AM
I would think that with it still in Task Man, that the system still has not closed all the stuff in the program.  Try doing the Taskkill and see if that helps.

Bill
Title: Re: Cannot link exe files
Post by: LarryMc on June 27, 2019, 11:07:09 AM
Andy

In the File menu under compile options check to make sure everything looks right there.

Then click your Executable Options button and then select the Advanced button and make sure there is no garbage in the Assembler Options window.
Title: Re: Cannot link exe files
Post by: Andy on June 28, 2019, 06:29:41 AM
Thanks everyone, but no cigar.

Checked all settings.
Installed IWB 3.03 on different machine to test - same problem.
Turned of disk indexing.

Tried everything I can think of - it looks like a windows file locking problem.

I tried this with two simple programs (A and B.exe):

Program A - comp[ile / run / exit - okay
Program A - comp[ile / run / linking problem.

Program B - comp[ile / run / exit - okay
Program B - comp[ile / run / linking problem.

Then went to the folder the exe's were in.
Could not manually delete them - BUT - they both get removed at the same time after something like 30 - 40 seconds?

So it's like I'm waiting for windows explorer to update itself?

It's the only way to describe it.

Andy.
Title: Re: Cannot link exe files
Post by: Brian on June 28, 2019, 06:59:04 AM
Andy,

Try Windows Update, and make sure your drivers are up to date. Seems to be a problem after Windows 10 Creator update. Even if you haven't updated, it's worth a try

Brian
Title: Re: Cannot link exe files
Post by: LarryMc on June 28, 2019, 07:50:44 AM
yeah, it's like you've got your computer making an automatic backup or sync or something like that ; that is slow.
Title: Re: Cannot link exe files
Post by: Egil on June 28, 2019, 07:52:13 AM
If all the suggestions fail, you can install IWB to a USB memory stick and run it from there. I did, and got rid of the annoying update trouble.


Egil
Title: Re: Cannot link exe files
Post by: fasecero on June 28, 2019, 10:14:18 AM
Just a few additional comments:

- Close IWB and run the program as an Administrator.
- Set the output-directory for your executable(s) to a folder located inside My Documents. This folder should have write permission.
- Add IWB to your antivirus Whitelist.
Title: Re: Cannot link exe files
Post by: Andy on June 29, 2019, 06:54:38 AM
Thanks guys,

But nothing works.

Everything else on my system runs just fine and quick, no problems what so ever.

IWB has to delete (or send a message to the system to delete) the existing .exe file and there lies the problem.

I wrote a simple console program with DELETEFILE in to delete the other .exe, it returns 1 for success - but still the .exe remains until the system bins it.

Noticed is Resmon it states the .exe is terminated but memory usage slowly counts down to zero - only then can I build another copy.

Strange.

And another thing, as I said I tried it on another machine and it does the same?

Both are Win 7 32 bit.

Andy.
Title: Re: Cannot link exe files
Post by: fasecero on June 29, 2019, 07:56:04 AM
And what happens when you manually delete those .exe files? Do you notice the same behavior?
If you temporarily disable your AV is this still happening?
It would also be useful to know the value DeleteFileA (the winapi version) returns.

I'm asking these questions because maybe this problem isn't related to IWB.
Title: Re: Cannot link exe files
Post by: Brian on June 29, 2019, 08:57:46 AM
Andy, have you tried optimising your HD?
Brian
Title: Re: Cannot link exe files
Post by: Andy on June 30, 2019, 04:00:38 AM
Thanks everyone - still no joy.

Disk is optimised and checked, same problem with Avast on or off etc.

Tried a free program "LockHunter", it tells me that it's Explorer.exe which is being run by the SYSTEM user.

So no matter what permissions I have (and I've even tried from the hidden Administrator user account) it won't delete after a linking fail - just have to wait until SYSTEM deletes it.

Just out of curiosity I tried another IWB program to delete the .exe file manually.

I tried DELETEFILE and DeleteFileA commands, before I make the linking error i.e. second compile / run, I can manually delete it at this point - no problem.

But if I used another IWB program to try to delete it (even though I can do it myself) it returns 1 for success - but the file is still there - and becomes locked by SYSTEM.

Attached are screen shots.

Andy.
Title: Re: Cannot link exe files
Post by: fasecero on June 30, 2019, 12:31:16 PM
Aha, your images clearly show what's going on. This is an unusual case, Andy. I'm... out of ideas. Maybe by doing some research online we may be able to find a similar case. I'll do some research.
Title: Re: Cannot link exe files
Post by: fasecero on June 30, 2019, 01:12:56 PM
Okay, after checking some sites this can happen to any compiler/linker. The linking process is likely to be blocked by

1) Your AV / Firewall
2) Application Experience Service is disabled

If you're quite sure sure that it is not your AV then check point 2.

Quote from: undefinedMake sure the Application Experience service is started and not set to disabled.

It is a Windows Service,
Run services.msc -> Application Experience

References
https://stackoverflow.com/questions/3906404/link-fatal-error-lnk1104-cannot-open-file-d-myproj-exe
https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/6c125c71-a98c-446d-8c36-bda898477a92/where-is-the-toggle-to-turn-on-application-experience-service?forum=windowsgeneraldevelopmentissues
Title: Re: Cannot link exe files - Solved.
Post by: Andy on June 30, 2019, 11:45:27 PM
Bingo!

Application experience service!

I disabled this last year along with one or two others - wasn't a problem as the programs I was writing were complex and there was plenty of time between compiling and making more changes.

I've enabled Application experience service and everything is great now.

Thanks so much - that's some research sherlock holmes (AKA fasecero!).


Andy.
:)
Title: Re: Cannot link exe files
Post by: Brian on July 01, 2019, 03:17:01 AM
Never heard of it!

In fact, I don't even see it in my list of Services

Brian
Title: Re: Cannot link exe files
Post by: Andy on July 01, 2019, 04:04:02 AM
Brian,

If you run services.msc you will (or should) see the attached - or something like it.

Don't forget - I'm on Win 7.

Andy.
Title: Re: Cannot link exe files
Post by: Brian on July 01, 2019, 04:10:17 AM
Nope, I haven't got that - Win 10 here

Brian

Ah, it is in Task Scheduler - got it now