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

CLR Windows Forms Application & Fortran DLL Library

ddexterr
Beginner
1,732 Views
Hi,

I use MS Visual C++ 2008 (professional edition). Is it possible to create solution with 2 projects: CLR Windows Forms Application and Fortran library (DLL). I tried do it but I'm still getting linker errors. For example:

unresolved external symbol "extern "C" void __clrcall FSUB(int *,char *,char *,unsigned int,unsigned int)"

or

fatal error LNK1313: pure module detected; cannot link with ijw/native modules

0 Kudos
4 Replies
Xiaoping_D_Intel
Employee
1,732 Views
Check if the application project properties setting/ General / Common Language Runtime Support is "/clr:pure". If yes it will not allow native code in the binary. Please change it to "/clr" and link the application.
0 Kudos
ddexterr
Beginner
1,732 Views
I change it to "/clr" but I get:

>winapp3.obj : error LNK2028: unresolved token (0A000007) "extern "C" void __cdecl Dll1(void)" (?Dll1@@$$J0YAXXZ) referenced in function "int __clrcall main(cli::array^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
>winapp3.obj : error LNK2019: unresolved external symbol "extern "C" void __cdecl Dll1(void)" (?Dll1@@$$J0YAXXZ) referenced in function "int __clrcall main(cli::array^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)


My example files:

-------------------------------------------

// winapp3.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"

extern "C" __declspec(dllimport) void Dll1 ();

using namespace winapp3;

[STAThreadAttribute]
int main(array<:STRING> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);

// Create the main window and run it
Application::Run(gcnew Form1());

Dll1();

return 0;
}

-------------------------------------------

! Dll1.f90
!
! FUNCTIONS/SUBROUTINES exported from Dll1.dll:
! Dll1 - subroutine
!
subroutine Dll1

! Expose subroutine Dll1 to users of this DLL
!
!DEC$ ATTRIBUTES DLLEXPORT::Dll1

! Variables

! Body of Dll1

end subroutine Dll1

-------------------------------------------

For project Windows Forms Application (winapp3):

  • Linker/Input = Dll1.lib
  • General/Additional library directories = "C:\\Documents and Settings\\ddexterr\\Moje dokumenty\\Visual Studio 2008\\Projects\\winapp3\\Dll1\\Debug";"D:\\Program Files\\Intel\\Compiler\\11.1\\065\\lib\\ia32"
Maybe Dll1.lib is still invisible for linker?

0 Kudos
Xiaoping_D_Intel
Employee
1,732 Views
The default naming conventionof WindowsFortran is all uppercase so the subroutine needs to be declared in C code as:

extern "C" void DLL1();
0 Kudos
ddexterr
Beginner
1,732 Views
It works :) finally. Thanks a lot Xiaoping Duan for your tips.
0 Kudos
Reply