- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi! I just installed Microsoft Visual Studio Community 2022 (64 bit) - version 17.6.2 and the oneAPI HPC Toolkit on a Windows 10 machine.
I created a new Fortran Empty Project test_fortran.vfproj, which also created the solution test_fortran.sln
I then added as a source file the file main.f90, which reads:
program main
print *, 'Hello, World!'
end program main
I tried to compile the solution, but I get the following error:
File MSVCRTD.lib(exe_winmain.obj): error LNK2019: reference to the external symbol WinMain not resolved in the function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
File test_fortran.exe: fatal error LNK1120: 1 external not resolved
What should I do to solve this? Thanks a lot in advance,
Laura
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Intel Fortran (both ifx and ifort) require Microsoft Visual Studio C/C++ tools to be installed.
I do note the linker was found, so you likely have installed C/C++
WinMain is an entrypoint used by Windows application.
The program you posted is a console program. Select console application from the MS VS template for specifying program type.
Jim Dempsey
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Intel Fortran (both ifx and ifort) require Microsoft Visual Studio C/C++ tools to be installed.
I do note the linker was found, so you likely have installed C/C++
WinMain is an entrypoint used by Windows application.
The program you posted is a console program. Select console application from the MS VS template for specifying program type.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using VS 2022 17.4.4 and 2023.1 ifort/ifx compilers and got no errors. I selected "Fortran empy project" and added Source1.f90 and it compiled on both ifort and ifx compilers. Do you have "Desktop development with c++" installed?
I now see @jimdempseyatthecove previously mentioned the desktop feature.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The error mentioned by @lauras8306 is, as Jim suggested, triggered by selecting an inappropriate project type when creating the project. This can be a confusing thing. As Jim said, selecting a project type with the Console tag (there are several) is key when you have a traditional Fortran program. What happened instead is that a "Desktop" project was selected, which wants a WinMain entry point and code that uses the Windows API to create windows. (The exception to this is QuickWin, which would also work here but is probably not what was wanted.)
There are two Empty Project templates, one for Console and one for Desktop. Be sure to select the correct one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
using Console solved the issue. Thanks a lot!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page