Using C library : option -cxxlib

Using C library : option -cxxlib

Hi,

With Linux OS we could use the linker option -cxxlib in order to link C libraries. I am trying to migrate my fortran project from Linux to Windows, and I cannot find an equivalent option. Is there an other solution?

Regards,

Emilie Hardy.

8 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

This was useful on Linux because if you used "ifort" to link, it only specifies the Fortran libraries.

If you have C++ object files too, that required the C++ runtime libraries, then using -cxxlib was a handy way to get those linked in.

On Windows the library file references are {generally} embedded in the object file by the compiler, and the linker reads those references and finds the libraries.

Are you actually having a problem, or looking at translating your makefile? 

            --Lorri

           

cxxlib was an old linux option from the time when icpc offered a choice between libstdc++ and Dinkumware STL.  There never was such an option on Windows.  You could have found that out by firing up your web search engine "cxxlib site:software.intel.com"

On linux, if you use Fortran to link a build which uses libstdc++, you need -lstdc++ in your command line.  In a Fortran build with Visual Studio, the STL libraries are included by link anyway.  I assume, if you have C++ functions, you must be using a Visual Studio with C++ rather than VS Shell.

Hi Lorri,

Thank you very much for your answer.

I am indeed having a problem. When I compile I get the folowing unresolved external symbol error:

ifort -implicitnone -free -warn:declarations -warn:uncalled -warn:unused -warn:u
sage -module:../../../MOD  -c  -o ../../../OBJ/actens.o actens.f90
Intel(R) Visual Fortran Compiler XE for applications running on IA-32, Version 1
4.0.3.202 Build 20140422
Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.
ifort: command line warning #10006: ignoring unknown option '/implicitnone'

ifort -o ../../../EXEC/APPLI/ACTENS/actens -L../../../LIB   ../../../OBJ/actens.
o -lderpot -lorbital -lnumeric -lrotations -lio -ltransdate -lsofa -cxxlib -lioc

Intel(R) Visual Fortran Compiler XE for applications running on IA-32, Version 1
4.0.3.202 Build 20140422
Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.
ifort: command line warning #10006: ignoring unknown option '/L../../../LIB'
ifort: command line warning #10161: unrecognized source type '../../../OBJ/acten
s.o'; object file assumed
ifort: command line warning #10006: ignoring unknown option '/lderpot'
ifort: command line warning #10006: ignoring unknown option '/lorbital'
ifort: command line warning #10006: ignoring unknown option '/lnumeric'
ifort: command line warning #10006: ignoring unknown option '/lrotations'
ifort: command line warning #10006: ignoring unknown option '/lio'
ifort: command line warning #10006: ignoring unknown option '/ltransdate'
ifort: command line warning #10006: ignoring unknown option '/lsofa'
ifort: command line warning #10006: ignoring unknown option '/cxxlib'
ifort: command line warning #10006: ignoring unknown option '/lioc'

Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:..\..\..\EXEC\APPLI\ACTENS\actens.exe
-subsystem:console
../../../OBJ/actens.o
libio.a(IOFMicroscope.o) : error LNK2019: unresolved external symbol _toReadMicr
oscopeVector referenced in function _INTERFACEMICROSCOPE_mp_READMICROSCOPEVECTOR

libio.a(IOFMicroscope.o) : error LNK2019: unresolved external symbol _toWriteMic
roscopeVector referenced in function _INTERFACEMICROSCOPE_mp_WRITEMICROSCOPEVECT
OR
libio.a(IOFMicroscope.o) : error LNK2019: unresolved external symbol _toWriteTes
t referenced in function _INTERFACEMICROSCOPE_mp_WRITEMICROSCOPEVECTOR
libio.a(IOFMicroscope.o) : error LNK2019: unresolved external symbol _toDeAlloca
teMicroscope referenced in function _INTERFACEMICROSCOPE_mp_DEALLOCATEMICROSCOPE

..\..\..\EXEC\APPLI\ACTENS\actens.exe : fatal error LNK1120: 4 unresolved extern
als
mingw32-make: *** [actens] Error 1120

For the problem with the unknown option -L I added the path to the libraries in the %LIB% environment variable. For all the -l unknown option I added !DEC$ OBJCOMMENT lib:'libio.a', etc, in my source file. That seems to work with an other program that didn't need the -cxxlib option.

However I am now wondering if this is really the origin of the problem. All of the unresolved external symbols are functions defined in INTERFACE (see attached file). Should I do something special in order to link these interfaces ?

 

Attachments: 

AttachmentSize
Download IOFMicroscope.f906.58 KB

Quote:

Tim Prince wrote:

cxxlib was an old linux option from the time when icpc offered a choice between libstdc++ and Dinkumware STL.  There never was such an option on Windows.  You could have found that out by firing up your web search engine "cxxlib site:software.intel.com"

On linux, if you use Fortran to link a build which uses libstdc++, you need -lstdc++ in your command line.  In a Fortran build with Visual Studio, the STL libraries are included by link anyway.  I assume, if you have C++ functions, you must be using a Visual Studio with C++ rather than VS Shell.

Thank you for your explanations Tim. I do not use Visual Studio but the command prompt.

Quote:

Emilie H. wrote:

Quote:

Tim Prince wrote:

cxxlib was an old linux option from the time when icpc offered a choice between libstdc++ and Dinkumware STL.  There never was such an option on Windows.  You could have found that out by firing up your web search engine "cxxlib site:software.intel.com"

On linux, if you use Fortran to link a build which uses libstdc++, you need -lstdc++ in your command line.  In a Fortran build with Visual Studio, the STL libraries are included by link anyway.  I assume, if you have C++ functions, you must be using a Visual Studio with C++ rather than VS Shell.

 

Thank you for your explanations Tim. I do not use Visual Studio but the command prompt.

I meant that you have Visual Studio installed so that link.exe is searching MSVC++ libraries, regardless of whether you use GUI or command prompt.

If the missing references match the names provided in InterfaceMicroscope, it means that compilation unit has taken effect as expected, but your C and C++ llibraries aren't working.  The fact that the Microsoft linker doesn't recognize the linux/Unix style -l and (in the form you presented it) -L options should tell you that as well.  You would need to include the names of the .lib files (or, if you're lucky, .a files may work in their place).

Microsoft intentionally avoids the kind of linux compatibility you would see in cygwin; neither Microsoft nor Intel accept the licensing models implied by such compatibility.

You cannot use a Linux command line on Windows. All of those -l switches, and -o should be removed. -o can be replaced with /EXE. -L is ok (should be .L). The -l options would be replaced by just naming the .lib files on the link line.

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today