Topic: Suspected graphics linking problem in mixed Fortran/C program

Hi,

I'm working on a program that uses a mixed language library to create a windows interface and functionality to mimic XWindows (Xplot11) from the Linux world. There are a bunch of internet topics out there from people who have been trying to compile this program on windows using Cygwin or MinGW (and there are a bunch of problems people have related to linking between the library (called libPlot.lib) and the main console program (called XFOIL)). I think I've taken care of all the normal linking problems that others have run into - related to underscores, upper or lower cases in routine names, etc. I have gotten SimplyFortran to compile and link XFOIL into an .exe without errors, but the program will not run. And unfortunately, it provides no messages about why it won't run. So I'm not sure how to proceed from here.

I think there must be a missing library link to some windows file though, because if I set the "Windows GUI" option under the Project Options, it will compile. If I do not check that option, it will not compile. Looking through the makefile, I can't quite tell what the difference is in the compile options, but I'm sure it must be doing something different.

Does anyone have suggestions for what to do next? I can provide source code and whatnot because it's governed by the GPL XX license.

Thanks,
Jason

Re: Suspected graphics linking problem in mixed Fortran/C program

Debugging problems
Have you tried switching on the console from the view menu, to see if there are any messages at system level?  Have you tried setting some breakpoints and running the debugger, to see how far it gets?  Maybe, this way, you can isolate the instruction on which it fails.

Some other ideas which might interest you
I'm also developing an application with a GUI for user input and program control, and with graphical output of annotated diagrams.  I'm using DISLIN for all GUI and visual output routines. 

For file output I'm sending the input data and results to an .RTF file which the program writes.  This enables me to produce formatted paged output, with all the same diagrams as appeared on the screen, in an output file that can be opened using M$Word.  The .RTF markup language is a bit baffling at first but it is powerful and not too hard to use, for basic stuff like font types and sizes, boldface text, centred text, margin widths, page breaks, drawing vector lines on the page, and placing text boxes where they are wanted.

Re: Suspected graphics linking problem in mixed Fortran/C program

Ok,

I tried running it from the SF console, rather than from the windows console, and it runs fine. If I try to run it from the windows console, nothing happens at all, and it goes back to the command prompt. Thoughts?

Thanks,
Jason

Re: Suspected graphics linking problem in mixed Fortran/C program

Only thing you can do will be to use the debugger, set breakpoints, find out which breakpoint it reaches without bombing out, then step through the code from that breakpoint to find the instructions it doesn't like the taste of.

Once you have that, you can start to work out why.

Re: Suspected graphics linking problem in mixed Fortran/C program

Yes, but it runs fine from the SF console. So using the debugger won't tell me why it doesn't work using the windows command prompt. It won't bomb from the SF console.

Re: Suspected graphics linking problem in mixed Fortran/C program

I don't understand why you can't run it under the debugger from Windows, without the SF console.
---
J.

Re: Suspected graphics linking problem in mixed Fortran/C program

Ok, If I start the debugger, does that run it from the SF console or the windows command prompt? How do I ensure that it's being launched from the windows command prompt and stepping through the debugger?

Re: Suspected graphics linking problem in mixed Fortran/C program

Hmm. Here's some more information. I tried checking the "External Console" option under project Launch, and got it to launch the external console. It quits to "press any key to continue" right away. I noticed that the program keeps running in the task manager though. And I can't force it to end the process. First time I've ever encountered that problem...

After restarting my computer to force it to quit (and thus be able to delete the .exe or compile it again or anything), I tried compiling it without the GUI option again. The first link error it gave was for the BitBlt function from the gdi32.lib. This must get linked automatically when you check the GUI option. In my case, the main program runs from the console, so I wonder if indicating "no console" messes things up whenever the program tries to "write" to the console. My guess is that I need to include the gdi32.lib (and probably some others), but I wonder if it would be best to include it in the libPlot library, or in the main program. Thoughts?

Jason

Re: Suspected graphics linking problem in mixed Fortran/C program

When the task manager can't kill it, you have to kill GDB.exe.
That does the trick, and avoids the need for a reboot.
---
John

Re: Suspected graphics linking problem in mixed Fortran/C program

jason_b1975 wrote:

Ok, If I start the debugger, does that run it from the SF console or the windows command prompt? How do I ensure that it's being launched from the windows command prompt and stepping through the debugger?

Compile with the option 'Windows GUI (no console)'.
Then debug.
---
John

Re: Suspected graphics linking problem in mixed Fortran/C program

Ok, I've done that and now I'm noticing something new. Currently, I have it set to launch in an external console, but that doesn't seem to actually show the console if I start the debugger. My first read statements happen in a subroutine. If I try to step over that subroutine, SF crashes. If I step into the subroutine up to the first read statement, then step over the read statement, I get this message, but only if I open the SF console first (since a console isn't coming up on its own otherwise):
"*stopped,reason="end-stepping-range",frame={addr="0x0040c113",func="askc",args=[{name="prompt",value="<error reading variable: Cannot access memory at address 0x49b398>"},{name="comand",value="<error reading variable: Cannot access memory at address 0x28ed49>"},{name="cargs",value="<error reading variable: Cannot access memory at address 0x28ecc9>"},{name="_prompt",value="8"},{name="_prompt@entry",value="8"},{name="_comand",value="7"},{name="_comand@entry",value="7"},{name="_cargs",value="128"},{name="_cargs@entry",value="128"}],file=".\\src\\userio.f",fullname="P:\\Tools\\Xrotor\\src\\userio.f",line="132"},thread-id="1",stopped-threads="all""

I *think this is telling me the variable COMAND is not long enough for the data that's trying to get entered into it. If I remember right, Linux and Unix only do a carriage return or line feed at the end of a line, but Windows does a carriage return and line feed at the end of a line. Does this seem plausible? I'm going to try some changes on that front.

Re: Suspected graphics linking problem in mixed Fortran/C program

Update: If I don't open a console before I try stepping over the first read statement, SF just hangs there. I think waiting for an input that it can't get because it isn't linked to a console. If I open a console after stepping over the first read statement, it crashes SF.

Re: Suspected graphics linking problem in mixed Fortran/C program

Jason,

Before you continue any further, let's try to clear up what you're working with. 

1. Which version of Simply Fortran are you currently using?

2. Does your program use the console for any input/output whatsoever?  If it does, you need to leave Windows GUI unchecked.   That box should be used only if you have absolutely no console input/output.

If your program is using a "Read *," or anything like that, you'll need to ensure that Windows GUI is not checked.  The long message you're seeing:

"*stopped,reason="end-stepping-range",frame={addr...

is due to a bug in Simply Fortran (didn't know about that one) where you're seeing the communications between Simply Fortran and the debugger.  I'll have to look into further suppressing this output.

Let me know the answer to the above questions.  I'm interested in what's actually happening with your code.

Jeff Armstrong
Approximatrix, LLC

Re: Suspected graphics linking problem in mixed Fortran/C program

I'm using version 2.10, build 1575

The program uses the console for all the input/output, so as I figured, I will continue with the Windows GUI box unchecked. That brings back my question about whether I need to link against windows libraries though. If I compile without the Windows GUI box checked, the first linker error is to BitBlt, which is in the gdi32.lib according to Dr Google finding data on MSDN. And should that link be done when creating the libPlot library, or is it better to link when building the final program?

Thanks,
Jason

Re: Suspected graphics linking problem in mixed Fortran/C program

Jason,

I think I'm starting to understand what you're asking.  Actually, the Windows GUI box does not cause any linking against Windows libraries to occur.  You'll need to open the Project Options dialog in your executable project, switch to the Compiler Flags tab, and add the following:

-lgdi32

You might have to add some other flags, but we'll tackle those as compiler errors arise.  Click Ok, and save your project. 

Next, perform a Clean from the Build menu.  Finally, click Build Now! in the Build menu.  Your program will either compile or, more likely, complain about another linker error.

Out of curiosity, did you compile "libPlot.lib" using Simply Fortran?  If the library was compiled for/by another compiler, it may not be compatible with Simply Fortran's compiler.  However, if you've gotten as far as seeing undefined references to BitBlt, I think everything is working okay.

Let me know what you get next based on these comments.

Jeff Armstrong
Approximatrix, LLC

Re: Suspected graphics linking problem in mixed Fortran/C program

Success! That did it!

So yes, I did compile libPlot using SF. Doing things as you suggested fixed everything as far as I can tell so far. I have to step away from the project before I'll get a chance to operate it and make completely sure it's working as intended, but this is a good sign so far.

Thanks,
Jason

Re: Suspected graphics linking problem in mixed Fortran/C program

Jason,

That's great to hear!  When you do get a chance, maybe you could provide a quick screenshot to show us the graphics portion.  I know I'd be interested in seeing it, and I think a good portion of users are interested in any sort of graphical programs written in Fortran.

Jeff Armstrong
Approximatrix, LLC

Re: Suspected graphics linking problem in mixed Fortran/C program

Jeff,

Can you offer any guidance on how do include an image file in a post to the forum?
I have tried this:

[img=Display image test]file:///D:JWasilewski/DEV/Fortran/InStruct121/InStructScreenshot.png[/img]

but it just displays the above a text.
---
John

Re: Suspected graphics linking problem in mixed Fortran/C program

John,

You would need to host the image elsewhere and then provide a link.  If you look at the help entry on images, you'll see that it is providing a complete URL to the image online.

Usually when I post images here, I first upload them to Imgur, which is simple, fast, and uncluttered.  You don't need an account or anything, so it makes posting an image easy.  They'll provide a per-image link to manage it in case you wish to delete it later.

Jeff Armstrong
Approximatrix, LLC

20 (edited by jason_b1975 2014-02-13 15:53:58)

Re: Suspected graphics linking problem in mixed Fortran/C program

Jeff,

If I'm doing this correctly, this will show a screenshot showing the console window and the plot window.

DisplayImage bbcode XFoilScreens

*Edit*
Ok, I don't know how to do this correctly (evidently). Here's the link to its location on Imgur:
http://imgur.com/ffCXlgS

*Edit2*
Using Jeff's instructions in a following post:
DisplayImage bbcode XFoilScreens

Re: Suspected graphics linking problem in mixed Fortran/C program

Jason, it doesn't display.
Also, may I suggest you place it in the forum under the new thrread I've just created for GUI screenshots?
---
John

Re: Suspected graphics linking problem in mixed Fortran/C program

Jason,

Thanks for the screenshot!  You just need to use the img tag rather than the url tag and add the proper image extension to the url, in this case: http://i.imgur.com/ffCXlgS.jpg.  For your image, it would be:

http://i.imgur.com/ffCXlgS.jpg.

Your program looks pretty interesting.  I'm guessing it's a 2D airfoil analysis program using a panel method.  I'm trying to remember my aerodynamics classes, but it has been a while.

Jeff Armstrong
Approximatrix, LLC

Re: Suspected graphics linking problem in mixed Fortran/C program

Yes, it's an airfoil analysis program from MIT and it couples boundary layer modifications into the panel model to make it able to do viscous analysis (panel methods are inherently inviscid - i.e.: no boundary layer). It's available to the public under the GPL here:

http://web.mit.edu/drela/Public/web/xfoil/

I wouldn't need to compile it on my own, except I want to make some additions to it.

Thanks for the help!
Jason

24 (edited by JohnWasilewski 2014-02-13 16:15:21)

Re: Suspected graphics linking problem in mixed Fortran/C program

Bernoulli tucked away in your code somewhere?

May I suggest you move this very interesting screenshot into the new forum thread I've just created for all users to share GUI screenshots?
---
John

Re: Suspected graphics linking problem in mixed Fortran/C program

John,

I put a screenshot of it on your topic.

Thanks for the help!