Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
27162 Discussions

Error in opening the compiled module file (GTK-Fortran)

Bryan3
Novice
2,236 Views

Hello,

 

I am trying to compile a simple test program/example based on the GTK-Fortran libraries (link) using the Intel Fortran Compiler. I was able to work with the developer of the library to successfully build the source files (*.f90) into compiled module files (*.mod, *.obj) by using a shell script in the MSYS2 environment.

 

I am now trying to build the simplest example code from the library in a project in Visual Studio 2019. The example code should simply open a blank window, but I am getting compiler/linker errors to the effect of "Error in opening the compiled module file. Check INCLUDE paths. [GTK]".

 

In searching through old posts on this forum, I found several other people posting similar questions, and have tried to follow the steps outlined there to no avail. I have all of the compiled *.mod and *.obj files located in a folder, and that folder is specified in the VS Project properties->Resources->General->Additional Include Directories. I have also tried every combination I can think of to otherwise include the needed files directly, one at a time, as a folder, etc. to no avail.

 

Any help on this matter would be appreciated. I have attached a copy of the compiled GTK module and object files as well as the example .f90 code that I am trying to compile.

 

Thanks,
Bryan

0 Kudos
18 Replies
Steve_Lionel
Black Belt Retired Employee
2,217 Views

I just tried this and it worked fine. Please create a ZIP of the buildlog.htm that shows the error and attach it to a reply here. Also include a screenshot of a directory listing for the .mod files.

Bryan3
Novice
2,186 Views

Please see attached.

Steve_Lionel
Black Belt Retired Employee
2,154 Views

I note that the .mod files in the .7z you attached earlier were built by the 64-bit compiler, but here you are using them from a 32-bit configuration. I get a different error message:

gtkzero_gapp.f90(36): error #7881: This module file was generated for a different platform or by an incompatible compiler or compiler release. It cannot be read. [GTK]

but this may be your problem regardless. Switch the VS configuration to "x64" and see what happens. Be sure that the "additional include directories" property is filled in with the new configuration.

 

Bryan3
Novice
2,153 Views

Thanks for the suggestion. I switched the configuration to x64 and tried to rebuild the project, but am still seeing I believe the same error messages. I have attached an updated BuildLog.htm file.

 

How did you setup your project that has it working?

I created a blank Fortran project, dropped the gtkzero_gapp.f90 file into the 'Source Files' folder in the project. I edited the "additional include directories" to include the path to my folder of .mod and .obj files, and hit build. The only other thing I have changed now is updating to x64 build (tried both debug and release modes).

 

Thanks,
Bryan

Steve_Lionel
Black Belt Retired Employee
2,124 Views

Are you sure you set the Additional Include Directories for the configuration you built? Please zip the .vfproj file and attach that. I followed exactly the steps you listed and it built fine.

Your build log does not show the /I option I would expect to see for an additional include directory.

Bryan3
Novice
2,120 Views

I also tried making another new blank fortran project, setting the mode to release x64 first, then importing the gtkzero_gapp.f90 file into the source folder, then adding the path to the folder containing the mod files to the additional include directories and am still getting the same errors.

I am also attaching screenshots of the settings pages, and I see /I <my folder> in the command line arguments, so I really don't know what's going on that is causing yours to build and work and mine to not...

andrew_4619
Honored Contributor I
2,113 Views

I would suggest the additional include directories under the fortran tab not under resources tab which I would imaging is only for the resource compiler for windows apps not the actual Fortran compiler. You should check the fortran command line entry has the /I entries 

Bryan3
Novice
2,109 Views

Thanks for the tip Andrew! That finally got rid of those errors that I was seeing. 

 

Now it's throwing out other errors that I also don't know what to do about...any ideas?

Severity Code Description Project File Line Suppression State
Error error LNK2019: unresolved external symbol gtk_window_set_title referenced in function activate gtkzero_gapp.obj
Error error LNK2019: unresolved external symbol gtk_application_window_new referenced in function activate gtkzero_gapp.obj
Error error LNK2019: unresolved external symbol gtk_window_set_default_size referenced in function activate gtkzero_gapp.obj
Error error LNK2019: unresolved external symbol GTK_mp_G_SIGNAL_CONNECT referenced in function MAIN__ gtkzero_gapp.obj
Error error LNK2019: unresolved external symbol g_application_run referenced in function MAIN__ gtkzero_gapp.obj
Error error LNK2019: unresolved external symbol gtk_widget_show referenced in function activate gtkzero_gapp.obj
Error error LNK2019: unresolved external symbol g_object_unref referenced in function MAIN__ gtkzero_gapp.obj
Error error LNK2019: unresolved external symbol gtk_application_new referenced in function MAIN__ gtkzero_gapp.obj
Error fatal error LNK1120: 8 unresolved externals x64\Release\Test3.exe

FortranFan
Honored Contributor II
2,104 Views

@Bryan3 ,

 

If you remain interested in Fortran generally and in GTK-Fortran specifically, please check out fortran-lang.org site and also the Discourse there where those working on Fortran bindings make regular posts and are more than willing to engage with users with Help as well as collaboration.  Here's a post that just popped up: https://fortran-lang.discourse.group/t/how-to-use-fpm-to-build-a-gtk-fortran-project/1424?u=fortranf...

Bryan3
Novice
2,097 Views

Hey there FortranFan, thanks for the suggestion. I actually came here to these forums after being over at the Discourse and talking to vmagnin to get the GTK-Fortran library compiled using the Intel Fortran Compiler. I just got to a point where it seemed like coming here would be better for my troubleshooting journey since the issues I am having are specific to the VS/ifort environment.

Bryan3
Novice
2,068 Views

@Steve_Lionel You said that you tried it and it worked fine, so you were able to build and run the example code , as is, without any errors? I am really struggling to figure out what is wrong with my configuration/setup that is causing these issues. Any help would be appreciated. 

Andrew's suggestion got rid of the 'error in opening the compiled module file' messages that I was seeing, but I am still getting these 'unresolved external symbol' errors listed above. Any ideas on what could be different between my setup and yours that is causing these errors?

Thanks,

Bryan

Steve_Lionel
Black Belt Retired Employee
2,065 Views

I said I could compile the one source you provided. I don't have the whole thing so can't link and run it.

The errors you show suggest a mismatch in naming conventions. I note that all of the symbols but one have lowercase names, which is not the default for Intel Fortran on Windows. Are you perhaps building with /names:lowercase or some other option that affects names? The error for GTK_mp_G_SIGNAL_CONNECT indicates that you are not including the object file for module GTK when linking.

I asked you earlier for the .vfproj file, but didn't see it. This would help me identify errors in your project configuration.

andrew_4619
Honored Contributor I
2,059 Views

I think all those routines are bind(c,name....) I looked at the files online but could not find routine gtk_window_set_title anywhere. It does not seem to be defined in the module it is used from which should be a compile error.... however the make files run all manner of scripts and build strings/names etc. I would speak to someone who knows the project.

Bryan3
Novice
2,053 Views

@Steve_Lionel If you compiled the source that I provided, then that is the extent of what I am trying to do at this time. I am just trying to get this most basic example to compile and run (should open a blank GUI window). This .f90 file, plus the compiled module and object files that were included in the 7-zip file in the original post of this thread is all that I am working from. So if you got that to work, then you are doing better than I am.

 

This is a library that was written by someone else that is primarily used, from what I can tell, on platforms other than Intel Fortran on Windows (gfortran compiler on linux). If the naming convention is off, then I can try to fix/update that and see what happens. Should all functions be uppercase? I am adding no additional input parameters (/names:lowercase) beyond what is the defaults and including the additional include directory (under Fortran, not Resources now). The GTK.mod and GTK.obj files are in the folder that is listed under additional input directories, so I don't know why it isn't finding it, unless it's also a capitalization issue. 

 

The .vfproj file was zipped up in the Test3.zip file earlier, but that was for the errors I was seeing previously. I have attached a new zip file that includes the latest .vfproj file for these new/different errors that I am seeing.

 

Thanks,
Bryan

Steve_Lionel
Black Belt Retired Employee
2,050 Views

First, your setting for Additional Include Directories is in the Release/X64 configuration only. If you try to build other configurations, the .mod files will not be found.

Second, Additional Include Directories is NOT used for linking in objects and libraries. For that you would have to either 1) Add the .obj or .lib to the project as if it were a source file, or 2) set the property Linker > Additional Dependencies to name the .obj or .lib files you want linked in and also set Linker > General > Additional Library Directories to point to the directory containing those objects or libraries. You did neither of these.

 

Generally, I recommend a third choice. Create a Fortran Static Library project for your library. Add that project to the VS Solution containing your executable project, then right click on the executable project, select Dependencies > Build Dependencies, and check the box for the library project. Intel Fortran will then automatically add the library project's output folder (containing .lib, .obj and .mod files) to the Include and link dependencies when building the project.

Bryan3
Novice
2,041 Views

@Steve_Lionel @andrew_4619 

Thanks, that is useful info on your second point. 

I tried your third choice recommendation, created a new project for Fortran Static Library, added all of the .f90 source files for the GTK-Fortran library to the project under Source Files folder, and surprisingly (to me) it compiled without errors. I then did as you explained and added that static library project to the solution for the Test3 project, and right clicked on Test3 project and set the dependency to require the static library project. I removed the other folder from additional include directories.  When I go to compile the Test3 project, I am still getting the following errors:

 

Severity Code Description Project File Line Suppression State
Error error LNK2019: unresolved external symbol g_signal_connect_data referenced in function GTK_mp_FUNCTION_G_SIGNAL_CONNECT GTK-Fortran-iFort.lib(gtk.obj)
Error error LNK2019: unresolved external symbol gtk_window_set_default_size referenced in function activate gtkzero_gapp.obj
Error error LNK2019: unresolved external symbol gtk_application_new referenced in function MAIN__ gtkzero_gapp.obj
Error error LNK2019: unresolved external symbol gtk_window_set_title referenced in function activate gtkzero_gapp.obj
Error error LNK2019: unresolved external symbol gtk_application_window_new referenced in function activate gtkzero_gapp.obj
Error error LNK2019: unresolved external symbol g_application_run referenced in function MAIN__ gtkzero_gapp.obj
Error error LNK2019: unresolved external symbol g_object_unref referenced in function MAIN__ gtkzero_gapp.obj
Error error LNK2019: unresolved external symbol gtk_widget_show referenced in function activate gtkzero_gapp.obj
Error fatal error LNK1120: 8 unresolved externals x64\Release\Test3.exe

 

Going off of Andrew's suggestion, I went and looked for all of these functions within the source code of the library:

'g_signal_connect_data' found in gtk-auto.f90 line 34768-9

'gtk_window_set_default_size ' found in gtk-auto.f90 line 3775

'gtk_window_set_title' found in gtk-auto.f90 line 3436-7

...

So, it seems like all of these functions that it is having issues finding are located in the gtk-auto.f90 file, which is included in the static library project that I created, but when I go look in the output/build folder at the *.obj and *.mod files, I don't see a 'gtk-auto.mod' or 'gtk-auto.obj'. Would it be getting put somewhere else? Any ideas?

 

I am happy to take any approach that will get the project to build/run without error.

I have attached a zip that includes the solution for Test3, a zip that includes the project for the static library, and a zip of the .f90 source files for the GTK-Fortran library.

Steve_Lionel
Black Belt Retired Employee
2,034 Views

It looks to me as if there is a separate GTK library you need. What you have is only the Fortran interface to it. None of the missing symbols are defined in the sources you have (other than as interfaces). When you find it, you can simply add the .lib as a source file in your executable project.

Bryan3
Novice
1,972 Views

Huge thanks to Steve_Lionel and andrew_4619 for their help on this. Below is my documented steps on how I finally managed to solve this problem. Posting this in hopes that on the off chance anyone else tries to do this without any prior knowledge of any of these things, this will be helpful to them.

 

Need to have Visual Studio 2019 installed and Intel Fortran Compiler added before doing any of these things, steps not noted here since this is done by our sys admin/IT staff.

 

Install GIT for Windows

Link: https://gitforwindows.org/

  • Install the executable
  • Recommend switching to Notepad++ as the default editor when prompted
  • Recommend switching to “Checkout as-is, commit as-is” on line ending conversions prompt
  • Otherwise, just stick with default options unless you know you need something else

Install MSYS2

Link: msys2.org

  • Install the executable following defaults (C:\msys64)
  • Run “MSYS2 MSYS” from start menu
  • Run “pacman –Syu”, at the end of this process, it will prompt you to close the program/prompt to finish installation, choose Yes
  • Run “MSYS2 MSYS” from start menu again
  • Run “pacman –Su”, wait for it to finish, will take a while
  • Run “pacman –S –needed base-devel mingw-w64-x86_64-toolchain”

Install Python 3.6.x

Link: https://www.python.org/ftp/python/3.6.2/python-3.6.2-amd64.exe

  • Download and run executable from above link
  • Choose Custom Installation
  • On “Optional Features” page, make sure everything is checked that can be
  • On “Advanced Options” page, make sure everything is checked that can be, change the “Customize install location” path to “C:\Python36”
  • Install
  • At the end, you will get a “Setup was successful” page, make sure to hit the button to “Disable path length limit”
  • Close installer

Building the GTK3 Libraries on Windows 10, Visual Studio 2019

Guide: https://github.com/wingtk/gvsbuild

  • Create the directories to a path “C:\gtk-build\github”
  • Open a command prompt window (Winkey+R, type “cmd”, hit enter; or start typing “command” at start menu)
  • Run “cd C:\gtk-build\github”
  • Run “git clone https://github.com/wingtk/gvsbuild”
  • Run “cd gvsbuild”
  • Run “python build.py build –p x64 --vs-ver 16 gtk3”
    • This will run a python script, specifying 64-bit build, and Visual Studio version 16 (2019), build the gtk3 library. This took ~15 minutes on a company laptop, so be patient.

Setting up a Static Library project for GTK-Fortran in Visual Studio

Link: https://github.com/vmagnin/gtk-fortran/tree/gtk3

  • First, get a copy of the GTK-Fortran library from the link above. This can be done from command prompt by making a directory somewhere, cd’ing to that directory, then typing “git clone https://github.com/vmagnin/gtk-fortran”, or by going to the website, clicking on the green Code button at the top right, and selecting “Download ZIP”.
  • Open Visual Studio 2019, select “Create New Project”, use the drop-downs to filter Languages to Fortran and Project Types to Library, then select “Static Library” and hit next. Name your project and put it in your desired directory, then hit Create. (Take note of where your project is being stored, you will need to add this project to your main solution later)
  • In a windows explorer window, navigate to the directory where you downloaded/unzipped the GTK-Fortran library. Look under the “src” folder, sort by file type, and select all of the *.f90 files in this directory. Drag all of these files into the Visual Studio window onto the “Source Files” folder. You should now be able to expand the “Source Files” folder in the Visual Studio Solution Explorer and see all of the *.f90 files.
  • Update the build settings from “Debug” and “x86” at the top of Visual Studio to “Release” and “x64”
  • Build the solution (Ctrl+Shift+B, Build->Build Solution, or Start button)

Setting up your working GUI project in Visual Studio

  • Open Visual Studio 2019, select “Create New Project”, use the drop-downs to filter Languages to Fortran, then select “Empty Project” and hit next. Name your project and put it in your desired directory, then hit Create. (Take note of where your project is being stored, you will need to move files there later)
  • In the Solution Explorer, right click on your Solution (should be top item), select Add->Existing Project… Navigate to the Static Library project file that you created above (*.vfproj) and hit okay
  • Your solution should now contain both the project you just created as well as the static library project in the Solution Explorer.
  • In the Solution Explorer, right click on your project (not the static library), select Build Dependencies->Project Dependencies… In the window that opens, under the list of “Depends On:”, check the checkbox next to the name of your static library project, then hit OK.
  • Add or create your source code file, adding it to the current project under Source Files.
  • Open a windows explorer window and navigate to “C:\gtk-build\gtk\x64\release\lib”, sort the folder by file type, select all of the *.lib files, drag them into your new project in Visual Studio under Source Files
  • Optional, but recommended, create a sub-folder under Source Files and put all of the *.lib files in that folder instead/first
  • Ensure that this project is also set to “Release” and “x64” settings at the top
  • Build your solution, should in theory get no errors if code is bug free, but still won’t open as executable at this point
  • Open a windows explorer window and navigate to the folder containing your solution, then dig down into “<Project Name>\<Project Name>\x64\Release” folder.
  • Open a separate windows explorer window and navigate to “C:\gtk-build\gtk\x64\release\bin”, sort folder by file type, and copy all of the *.dll files from this folder over into the Release folder of your project (one step up)
  • You should now be able to run your <Project Name>.exe program from the Release folder

 

It cannot be stressed enough:

  • Both the static library and the final project both have to be set to “Release” and “x64”
  • The version of GTK must match between the C based GTK libraries and the Fortran based GTK-Fortran libraries. At the time of writing, GTK4 is available, but the tools to build it are not updated yet, so this set of instructions is for building GTK3 ONLY.

 

 

Reply