Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28988 Discussions

Problem with recent change from CVF to IVF

michael_green
Beginner
1,155 Views

Hi All,

I have converted a large CVF project to IVF, and also a separate CVF project containing a static library to IVF. They were easy to link in CVF but I cannot seem to find out how to do it in IVF. What looks the same (add existing to project, etc) certainly adds the .lib file to the project, but the linker cannot see any of the object code within it. What am I doing (or not doing) wrong?

With many thanks in advance,

Mike

0 Kudos
18 Replies
Steven_L_Intel1
Employee
1,155 Views
That ought to work. Please submit a problem report to Intel Premier Support and attach a ZIP of your projects including the buildlog.txt in the main project's Debug or Release folder. We'll take a look.

Another way to do this is to have the two projects in the same Visual Studio solution and have the library project be a dependent of the main project. (Right click on project, select Dependencies.)
0 Kudos
michael_green
Beginner
1,155 Views

Thanks Steve,

I still have many problems with this - your suggestion of dependent projects didn't work either. However, if I start a brand new test project using the same static library it all works well, so there may be something inherently wrong with the large project I have converted.

Anyway, I have continued withseveral different reconstructions and have finally got to a version that links - not to the library, I've given up with that for now - but to the library source files as part of the project. In order to do thisI had to remove all references to the RENAME function and replace with copyfile and deletefile - a poor solution I know, but I'm desperate - without this the linker couldn't find RENAME, although it was perfectly OK in CVF.

Now my problem is, the program (a full-blown Windows API) only runs for a very short time before it fails on LoadMenu. I get an error 1812 "The specified image file did not contain a resource section."

It certainly looks like it does to me. It's in the solution, making a small change to some item causes the project to rebuild itself, and everything is there just as it was in the CVF version. Do you have any suggestions?

With many thanks in advance,

Mike

0 Kudos
Steven_L_Intel1
Employee
1,155 Views
Sorry, I can't help with the LoadMenu issue. That's an aspect of Win32 programming I never got into. I know there are others who read here who know that stuff better than I.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,155 Views
The error message seems to say that either:
  1. you don't have the .res file (created by compiling of the .rc file) linked with the code, or
  2. that hInstance argument points to the wrong module.
You can verify the first by Open/File/Whatever.exe -> Open with...->Resource editor (CVF has a similar option, "Open as->Resources", in the same dialog). You should see your resources in the same way as the Resource view.
0 Kudos
michael_green
Beginner
1,155 Views

Thanks Jugoslav,

The .res file seems to be OK (verified with your test), and if the hInstance is wrong I have no idea what to do about it.

But there's more. I took one of Norman Lawrence's examples, BitView2- which I know works OK in CVF - and unzipped it, double clicked on the .dsw file and allowed IVF to follow its defaults (convert to current visual C++ project format - I said yes to all). I then right clicked on BitView2 in the solution explorer and selected "extract Compaq Visual Fortran project items". Then I built the project without tampering with it in any way.

On running this program, itcrashes at exactly the same place as mine did - on the call to LoadMenu in WinMain. I have attached a zip of BitView2 in case it's of any use. Any suggestions?

With many thanks again,

Mike

0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,155 Views
I took the same steps as you, and took a pass through BitView2 with the debugger: LoadMenu works for me.

However, if that's the original Lawrence's sample, I must say that the code is terribly broken. Namely, it assumes SAVE semantics, which was never guaranteed in Fortran, and indeed not provided in IVF (by default, variables default to AUTOMATIC in IVF). Adding an unqualified SAVE at the top of MainWndProc appears to solve the issue. However, that seems tangential to the LoadMenu problem.

I can't see at all how hInstance could be wrong: it has to have value of 4194304 (#00400000) for any given exe. However, error 1812 seems to indicate that any resource-loading function would fail. What happens if you try LoadIcon or DlgInit instead of LoadMenu?

0 Kudos
michael_green
Beginner
1,155 Views

Hi Jugoslav,

I tried LoadIcon and it fails in the same way.

Since BitView2 works for you (and it is the original) I began to feel that there was something wrong with my version of IVF. So I installed Visual Studio .NET 2003 and my version of IVF on a different computer - same result. Then I tried BitView2 on a colleague's machine - my colleague has been using IVF8 for a couple of years and has never converted a CVF project before. It worked just fine for him.

We both bought our licences for IVF at the same time but I didn't download the software until about 3 weeks ago, while my colleague downloaded his a couple of years ago. I see his version is 7.1.3088 while mine is 7.1.6030. Could this be the source of the problem?

Whatever, I guess I'll just have to go back to CVF for a few weeks until my employer delivers IVF10 to me and hope that works.

Many thanks again for your help

Mike

0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,155 Views
Does the .exe built on your computer work for him?

If your compiler or IDE is broken for some reason, I can reasonably conceive that your resources are not built and/or not included in the .exe. What I can't concieve is that the resources are compiled and linked, but LoadMenu fails with that error ("no resource section"). That would, IMO, require particularly nasty gremlins in your machine.

Is there "Compiling resources..." message when you rebuild all?
0 Kudos
Steven_L_Intel1
Employee
1,155 Views
Mike, the versions you mention are Visual Studio versions, not IVF versions.
0 Kudos
michael_green
Beginner
1,155 Views

Hi Jugoslav,

No the .exe of BitView2 does not work for my colleague, and yes I do get the "Compiling resources ..." message when I rebuild all.

Whatever the problem is it is not machine dependent because I'm now running on a completely different machine, but the problem is the same - the program exits on a failure to LoadMenu (or LoadIcon, or whatever). When I attempt to run the program (debug version within the IDE) I get some output which I don't understand (because I'm new to IVF) but which may be significant. It is:

'BitView2.exe': Loaded 'K:371-Forest Management BranchFMIS devSourceVF scratchBitView2DebugBitView2.exe', Symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32 tdll.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32kernel32.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32version.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32user32.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32gdi32.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32comdlg32.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32shlwapi.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32advapi32.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32 pcrt4.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32msvcrt.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32comctl32.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32shell32.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32wsock32.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32ws2_32.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32ws2help.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSWinSxSx86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03comctl32.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32EntAPI.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32psapi.dll', No symbols loaded.

'BitView2.exe': Loaded 'C:WINDOWSsystem32 etapi32.dll', No symbols loaded.

'BitView2.exe': Unloaded 'C:WINDOWSsystem32EntAPI.dll'

'BitView2.exe': Unloaded 'C:WINDOWSsystem32 etapi32.dll'

'BitView2.exe': Unloaded 'C:WINDOWSsystem32psapi.dll'

The program '[2708] BitView2.exe: Native' has exited with code 0 (0x0).

Does this mean anything?

Many thanks yet again,

Mike

0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,155 Views
No, these messages don't indicate anything special, it's just a list of loaded dlls.

But missing "compiling resources" message indicates that your VF IDE integration might be broken (no gremlins, if that's a condolence smiley [:-)]). Please re-read my test from the first post in this thread: I said that you should open the .EXE file as resources (yes, you can do that). If they're there, you should see them; if they're not, it verifies the problem with resource building.

Please take a look in the icon of the .rc file in the Solution Explorer pane: does it have a small blue downward arrow (indicating that the file is included in build)? In its Properties/Build, it should be specified "Exclude file from Build: No" and "Command Line: /fo "Debug/Whatever.res".


0 Kudos
Steven_L_Intel1
Employee
1,155 Views
Also do this. Start..Run. Enter REGEDIT, click OK.
Click on the + symbol next to HKEY_CLASSES_ROOT to expand that tree. Under that, find ".rc" and click on it. You should see (at least) the following three values:

(Default) REG_SZ VisualStudio.rc.8.0 (This would be for VS2005)
ContentType REG_SZ text/plain
PerceivedType REG_SZ text

If you don't see this, do the following:
Uninstall the Fortran VS integration
Delete the .rc registry key above
Do a "Repair/Reinstall" of VS
Reinstall the VS integration

This has solved resource compiler issues for me in the past.
0 Kudos
michael_green
Beginner
1,155 Views

Jugoslav first ...

I do not have a missing "compiling resources" message - it appears every time. And I can open the .exe file as resources, and everything is there. The icon of the .rc file does have the small arrow. The one thing that's different from what you mentionedis in the Properties/BuildCommand line which says:

/d" _DEBUG"/l 0x0c09 /fo "Debug/BitView2.res"

Steve,

The items you mentioned are not present under .rc but under .rc2, where I have:

(Default)REG_SZVisualStudio.rc.7.1

Content TypeREG_SZtext/plain

PerceivedTypeREG_SZ

Is the .rc/.rc2 difference significant? If not I'll go ahead and do the repair/reinstall, but I'll wait for your comment first.

Many thanks again

Mike

0 Kudos
Steven_L_Intel1
Employee
1,155 Views
If your .rc does not look like the one for .rc2, then I suggest you do as I suggested.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,155 Views
Sorry Mike, misread your previous message on "compiling resources". As for other things, your IDE setups seems OK, at least on the surface.

Can you please attach a broken .exe of yours (or send it to me by e-mail)? I'm curious what kind of stuff can cause LoadMenu to fail.
0 Kudos
michael_green
Beginner
1,155 Views

Hi Guys,

I did everything that Steve suggested - the .rc entry of the registry now has the correct entries - but it made no difference, LoadMenu still returns zero.

However, I did discover that if I switch back to CVF and do a rebuild all (the program runs OK here) and then return to IVF using exactly the same solution/workspace, the program runs OK and I can debug in IVF. Of course, if I then rebuild all in IVF, it's back to failure,

Does this mean anything important?

Thanks again

Mike

0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,155 Views
Mike, I received your e-mail, but there's little I can tell from the exe. You do appear to have Gremlins in there. The exe fails as well on my computer. However, few things I noticed:

* Your supposedly debug exe is 428 kB, while mine is over 800 kB (compiled with 10.0.025). OTOH, my release version is 448 kB (with slightly changed code).
* I can't debug it except in assembly mode (which I don't feel like doing); even if I try to use your .exe as a "cuckoo's egg" copied over mine, the VS cannot debug it in source-file mode
* The resources are in there indeed. Dependency walker doesn't show anything unusual either.

In sum, your IVF seems to break the code in a way I can't conceive. The resource compiler is all OK -- the resources are compiled, and in the exe.

On deeper research, I find the following oddity, though. I compared the outputs of Dependency Walker of your exe and mine. For the functions

LoadAcceleratorsA
LoadCursorA
LoadIconA
LoadMenuA
MessageBoxA
PostQuitMessage

"Hint" entry is off by 1 in comparison for those entries only. According to DW documentation, "The hint value is used internally by the operating systems loader to quickly match imports with exports. It is used as an index into the array of exported functions in the selected module." Also, "Hint-Name Table: The table consists of a 4-byte hint followed by the null terminated symbol name. The hint value is used to index the Export Name Table pointers array, allowing faster by-name imports. The hint will be right if the DLL hasnt changed or at least its list of export symbols hasnt changed. If hint is incorrect, then binary search is performed on the Export Name Pointer table. "

I assume this wouldn't mean anything to you (and it means little to me as well); perhaps it could lit a bulb for someone more knowledgeable though? Broken version of Mike's User32.lib perhaps?
0 Kudos
michael_green
Beginner
1,155 Views

Jugoslav,

I just rebuilt both debug and release versions of BitView2 - the debug version weighs in at 428Kb, while the release version is 348Kb. Neither of them runs.

Thanks for taking the time to check my .exe. You are quite right, the oddity you discovered doesn't mean anything to me. I think it's now clear that there is something wrong with some part of my software. This thread began with questions about my inability to link to a static library, even though, as Steve said, "that ought to work". I never did get my large project to work at all for that reason so I don't know whether I would have had the same resources problem, although I suspect so. I changed computers about a week ago and that made no difference either.

Maybe the problem is my old version of IVF (it's 8.0.1877.2003). I'm hoping to take delivery of IVF 10 in a few weeks so I think the best thing I can do is be patient and wait for that. In the meantime many thanks again to both you and Steve for your help.

Mike

0 Kudos
Reply