I try to make a DLL with the pgfortran compiler. I first did the example in the manual (page 123), which worked with version 18.4 (I reported the bug in version 18.10 in January, and went back to version 18.4).
Now I want to do my own subroutine. Actually, i have several subroutines, but I want to export only three of them. I.e., a user should be able to call these three subroutines, but the other subroutines (which are only used internally) should be hidden from him. Hence I wrote three sources files like
!DEC$ ATTRIBUTES DLLEXPORT :: sub1
end subroutine sub1
The project also uses libblas.lib and liblapack.lib. I am using Code::Blocks as an IDE.
When I build this project, I get the above error message. However, in no place in my source do I define a function “DllMain”. And this error does not occur with the example in the manual (which contains only a single subroutine and a common block that are exported).
Is this problem related to the fact that the DLL contains several exported subroutines? Or is the problem with the use of the lapack and blas libraries? I include the complete build-lob below.
-------------- Build: Debug in MevelerDLL (compiler: PGI Fortran Compiler)---------------
pgfortran.exe -Mmakedll obj\Debug\src\AbelGuess.o obj\Debug\src\CopyVector.o obj\Debug\src\Entropy4Meveler.o obj\Debug\src\HistoricMEM2.o obj\Debug\src\Legend.o obj\Debug\src\LegendreProject3.o obj\Debug\src\MevelerTools.o obj\Debug\src\Modul_MevelerOptions.o obj\Debug\src\SimLeg.o obj\Debug\src\SimSC2.o obj\Debug\src\FetchOption.o obj\Debug\src\MevelerDLL3.o obj\Debug\src\SetOptions.o -o bin\Debug\MevelerDLL.dll -Mmakedll “…\Program Files\PGICE\win64\18.4\lib\libblas.lib” “…\Program Files\PGICE\win64\18.4\lib\liblapack.lib”
libblas.lib(memory.obj) : error LNK2005: DllMain already defined in msvcrt.lib(dll_dllmain_stub.obj)
Creating library bin\Debug\MevelerDLL.lib and object bin\Debug\MevelerDLL.exp
bin\Debug\MevelerDLL.dll : fatal error LNK1169: one or more multiply defined symbols found
Process terminated with status 2 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))