- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have to access a C structure from Fortran using COMMON BLOCK. In my C program the structure's variable is shared for multiple process access using the #pragma directives. On the Fortran side I have defined a COMMON BLOCK to map on this C structure variable. I am trying to compile the code to build the DLL. The problem I face is the Linker gives me error as stating 'one or more multiply defined symbols found' for the structure variable declared. My code looks like this.
*********************** C code ************************* ###### globalParams.h ######## #pragma pack(2) typedef struct CPPDLL_MACRO _GlobalParam { int k[2]; float var; int l; char str[11]; } GlobalParam; #pragma pack() extern CPPDLL_MACRO GlobalParam globalParam; ###### globalParams.c ###### #pragma data_seg (".shared") GlobalParam globalParam = {0}; #pragma data_seg() #pragma comment(linker, "/section:.shared,RWS") ******************** Fortran code ************************* ###### Engine.FI ##### !DEC$ ATTRIBUTES ALIAS:'_globalParam' :: GLOBALPARAM COMMON /GLOBALPARAM/ K(2), VAR, L, STR INTEGER*4 K, L REAL*4 VAR CHARACTER*11 STR ###### INITIALIZEPARAMS.F ###### SUBROUTINE INITIALIZEPARAMS #include "Engine.FI" DATA K / 5, 8 / DATA VAR / 2.30000 / DATA L / 9 / DATA STR / "HELLO WORLD" / END SUBROUTINE ***********************************************************
I am trying to compile the above code to build a DLL but the linker gives me the following error.
Linking... INITIALIZEPARAMS.OBJ : error LNK2005: _globalParam already defined in globalParameters.obj INITIALIZEPARAMS.OBJ : warning LNK4006: _globalParam already defined in globalParameters.obj; second definition ignored Creating library Debug/CPPDLL.lib and object Debug/CPPDLL.exp ..inCPPDLL.dll : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe. CPPDLL.dll - 2 error(s), 1 warning(s)
Can any one help me resolve this problem? Why is the Fortran COMMON BLOCK 'GLOBALPARAM' not mapping to the memory location of 'globalParam' structure defined in the C code?
Any help will be obliged. I am using CVF 6.6 and VC++ 6.0.
Nitin
Message Edited by nitinshukla on 02-28-2005 02:05 AM
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
However, I am not sure this will work properly because Fortran will want to put the COMMON in the .data section. You may need to use a linker /section switch to specify RWS since Fortran does not have a directive to do this. In this case, remove GlobalParams.c entirely and use the linker switch.
Message Edited by sblionel on 03-01-2005 08:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Message Edited by nitinshukla on 03-01-2005 09:41 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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