- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I have a problem linking to a .lib file withthe linker complaining about an unresolved symbol (LNK2019 error). This is, I believe, because the ifort compiler converts all symbols to uppercase, whereas the .lib file contains lowercase symbols. Is there anyway to change this behavior?
1 Lösung
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
There are multiple ways to do this. What I would recommend is to declare an interface for the routines you're calling and add "BIND(C)" after the argument list. For example:
interface
subroutine sub1 (arg) bind(C)
integer arg
end subroutine
subroutine sub2 (arg) bind(C)
integer arg
end subroutine
...
end interface
The bind(C) will cause the names to be downcased.
An alternative is to use:
!DEC$ ATTRIBUTES ALIAS:"lowercasename" :: routinename
where you'll be calling the routine.
You do not want to force ALL external names to be lowercase - this can lead to other problems.
interface
subroutine sub1 (arg) bind(C)
integer arg
end subroutine
subroutine sub2 (arg) bind(C)
integer arg
end subroutine
...
end interface
The bind(C) will cause the names to be downcased.
An alternative is to use:
!DEC$ ATTRIBUTES ALIAS:"lowercasename" :: routinename
where you'll be calling the routine.
You do not want to force ALL external names to be lowercase - this can lead to other problems.
Link kopiert
7 Antworten
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
There are multiple ways to do this. What I would recommend is to declare an interface for the routines you're calling and add "BIND(C)" after the argument list. For example:
interface
subroutine sub1 (arg) bind(C)
integer arg
end subroutine
subroutine sub2 (arg) bind(C)
integer arg
end subroutine
...
end interface
The bind(C) will cause the names to be downcased.
An alternative is to use:
!DEC$ ATTRIBUTES ALIAS:"lowercasename" :: routinename
where you'll be calling the routine.
You do not want to force ALL external names to be lowercase - this can lead to other problems.
interface
subroutine sub1 (arg) bind(C)
integer arg
end subroutine
subroutine sub2 (arg) bind(C)
integer arg
end subroutine
...
end interface
The bind(C) will cause the names to be downcased.
An alternative is to use:
!DEC$ ATTRIBUTES ALIAS:"lowercasename" :: routinename
where you'll be calling the routine.
You do not want to force ALL external names to be lowercase - this can lead to other problems.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Thanks a lot, that solved the problem. When using the alternative solution, I had to insert an extra underscore:
!DEC$ ATTRIBUTES ALIAS:"_lowercasename" :: routinename
!DEC$ ATTRIBUTES ALIAS:"_lowercasename" :: routinename
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
probably better to do
!DEC$ ATTRIBUTES, DECORATE, ALIAS:"lowercasename" :: routinename
without the underscore
Les
!DEC$ ATTRIBUTES, DECORATE, ALIAS:"lowercasename" :: routinename
without the underscore
Les
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I agree with Les and should have suggested that instead.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
That seemingly only works when I supply an interface. Minimal example:
test.f90(6) : Error: Only a function or subroutine subprogram may have the !DEC$
ATTRIBUTES directive DECORATE specifier. [SUBRT]
!DEC$ ATTRIBUTES DECORATE, ALIAS:"subrt" :: SUBRT
----------------------------------------------^
[fortran]program test implicit none external SUBRT !DEC$ ATTRIBUTES DECORATE, ALIAS:"subrt" :: SUBRT call SUBRT() end program test [/fortran]
test.f90(6) : Error: Only a function or subroutine subprogram may have the !DEC$
ATTRIBUTES directive DECORATE specifier. [SUBRT]
!DEC$ ATTRIBUTES DECORATE, ALIAS:"subrt" :: SUBRT
----------------------------------------------^
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
With just the declaration "external SUBRT"the compiler can not see what kind of external
you have. If you have an explicit interface it can. (Not sure if an ordinary variable can be
declared "external", but I guess COMMON blocks are another example).
Normally, you put these attributes at the definition of the subroutine or function.
Regards,
Arjen
you have. If you have an explicit interface it can. (Not sure if an ordinary variable can be
declared "external", but I guess COMMON blocks are another example).
Normally, you put these attributes at the definition of the subroutine or function.
Regards,
Arjen
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I think the compiler should allow that - I'll ask.

Antworten
Themen-Optionen
- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite