- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
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
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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):
>winapp3.obj : error LNK2028: unresolved token (0A000007) "extern "C" void __cdecl Dll1(void)" (?Dll1@@$$J0YAXXZ) referenced in function "int __clrcall main(cli::array
>winapp3.obj : error LNK2019: unresolved external symbol "extern "C" void __cdecl Dll1(void)" (?Dll1@@$$J0YAXXZ) referenced in function "int __clrcall main(cli::array
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"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The default naming conventionof WindowsFortran is all uppercase so the subroutine needs to be declared in C code as:
extern "C" void DLL1();
extern "C" void DLL1();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It works :) finally. Thanks a lot Xiaoping Duan for your tips.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page