- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I am trying to build a Fortran static library of AMD64 to be called by a C++ project. I use the following command line:
ifort *.f /libs /link /machine:amd64 /subsystem:windows /out:test.lib
However, it displayed that no '_MAIN_' entry exist? How can I generate a static library like this?
Another way is the following two command lines:
ifort *.f /compile_only
lib *.obj /machine:amd64 /subsystem:windows /out:test.lib
Then it generated the static library I wanted. However, when I linked it into the C++ project by a .mak file which has the following linker setting (only listedpart of its settings):
LINK32=test.lib bufferoverflowu.lib ifconsol.lib libifcore.lib libifport.lib libirc.lib libm.lib /machine:amd64 /subsystem:windows
The following error information displayed:
libifcore.lib(for_init.obj) : error LNK2019: unresolved external symbol __argc referenced in function for_rtl_init_
libifcore.lib(for_init.obj) : error LNK2019: unresolved external symbol __argv referenced in function for_rtl_init_
libifcore.lib(for_init.obj) : error LNK2019: unresolved external symbol _pxcptinfoptrs referenced in function GETEXCEPTIONPTRSQQ
libifcore.lib(for_init.obj) : error LNK2019: unresolved external symbol __argv referenced in function for_rtl_init_
libifcore.lib(for_init.obj) : error LNK2019: unresolved external symbol _pxcptinfoptrs referenced in function GETEXCEPTIONPTRSQQ
Can anyone tell me how to solve my problem?
Thanks,
Zhanghong Tang
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can't create a .lib directly from the ifort command. You have to first create .obj files (use /c when compiling to prevent linking) and then use the lib command to create the library. See the User's Guide on the details of using "lib".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you tell me why my second method is wrong?
Thanks,
Zhanghong Tang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Without seeing all the options, including how the C++ code was compiled, I can't say for sure. Compiled that way, the Fortran code is expecting the static, single-threaded C libraries (libc). You should not have to specify the Fortran libraries, as there are linker directives inserted to pull those in. Make sure you compile the Fortran code with the same run-time library option as the C++ code (/MD, /MT, whatever) and don't list the Fortran libraries on the link line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve,
Thank you very much for your kindly reply.
Now I have listed the compile and link option in my C++ project.
F90=df.exe
CPP=cl.exe
CPP_PROJ=/nologo /MD /W3 /GX /O2 /Op /GR /D "NDEBUG" /D "WIN64" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR) emp AMD64.pch" /Yu"stdafx.h" /Fo"$(INTDIR)" /Fd"$(INTDIR)" /FD /c
CPP=cl.exe
CPP_PROJ=/nologo /MD /W3 /GX /O2 /Op /GR /D "NDEBUG" /D "WIN64" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR) emp AMD64.pch" /Yu"stdafx.h" /Fo"$(INTDIR)" /Fd"$(INTDIR)" /FD /c
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
...
$(CPP) @<<
$(CPP_PROJ) $<
<<
...
MTL=midl.exe
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /WIN64
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR) emp.res" /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR) emp AMD64.bsc"
BSC32_SBRS=
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /WIN64
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR) emp.res" /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR) emp AMD64.bsc"
BSC32_SBRS=
LINK32=link.exe
LINK32_FLAGS=rpcrt4.lib version.lib FortranLib*.lib netapi32.lib OPENGL32.LIB GLU32.LIB GLAUX.LIB /nologo /FORCE:MULTIPLE /subsystem:windows /STACK:0x5f5e100,0x5f5e100 /incremental:no /pdb:"$(OUTDIR) emp.pdb" /nodefaultlib:"libc.lib" /out:"$(OUTDIR) emp.exe" /machine:AMD64
The Fortran static library is placed in the directory of fortranlib, in the C++ project, no fortran code exists and there is no Fortarn compiler in the AMD64 machine which compile the C++ project.
The C++ compiler I used for AMD64 is shown in the picture attached.
Can you help me to modify the options of IFORT and LIB to generate a Fortran Static Library to be called by the C++ project?
Thanks,
Zhanghong Tang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
re

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