Wiki source for KeyPgLib
{{fbdoc item="title" value="LIB"}}----
Specifies the library where a sub or function can be found as part of a declaration
{{fbdoc item="syntax"}}##
[[KeyPgDeclare|declare]] { [[KeyPgSub|sub]] | [[KeyPgFunction|function]] } //proc_name// **lib** "//libname//" [ [[KeyPgAlias|alias]] "//symbol_name//" ] ( //arguments list// ) [[KeyPgAs|as]] //return_type//
[[KeyPgExternBlock|extern]] "//mangling//" lib "//libname//"
//declarative statements//
end [[KeyPgExternBlock|extern]]
[[KeyPgType|type]] //T//
[[KeyPgAs|as]] [[KeyPgInteger|integer]] dummy
[[KeyPgDeclare|declare]] [[KeyPgConstructor|constructor]] **lib** "//libname//" [ [[KeyPgAlias|alias]] "//symbol_name//" ] ( //arguments list// )
end [[KeyPgType|type]]
##
{{fbdoc item="desc"}}
In ##[[KeyPgSub|Sub]]## or ##[[KeyPgFunction|Function]]## declarations, and also in class method declarations (including constructors and destructors), ##**lib**## indicates the library containing the function. Libraries specified in this way are linked in as if ##[[KeyPgInclib|#inclib "libname"]]## or ##[[CompilerOptl|-l libname]]## had been used.
##**lib**## can also be used with [[KeyPgExternBlock|Extern ... End Extern blocks]] to specifiy a ##**lib**## for all declarations inside.
{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/procs/mydll.bas"}}%%(freebasic)
'' mydll.bas
'' compile with:
'' fbc -dll mydll.bas
Public Function GetValue() As Integer Export
Function = &h1234
End Function
%%
{{fbdoc item="filename" value="examples/manual/procs/lib.bas"}}%%(freebasic)
Declare Function GetValue Lib "mydll" () As Integer
Print "GetValue = &h"; Hex(GetValue())
' Expected Output :
' GetValue = &h1234
%%
{{fbdoc item="diff"}}
- New to ""FreeBASIC""
{{fbdoc item="see"}}
- ##[[KeyPgDeclare|Declare]]##
- ##[[KeyPgInclib|#inclib]]##
{{fbdoc item="back" value="CatPgProcedures|Procedures"}}
Specifies the library where a sub or function can be found as part of a declaration
{{fbdoc item="syntax"}}##
[[KeyPgDeclare|declare]] { [[KeyPgSub|sub]] | [[KeyPgFunction|function]] } //proc_name// **lib** "//libname//" [ [[KeyPgAlias|alias]] "//symbol_name//" ] ( //arguments list// ) [[KeyPgAs|as]] //return_type//
[[KeyPgExternBlock|extern]] "//mangling//" lib "//libname//"
//declarative statements//
end [[KeyPgExternBlock|extern]]
[[KeyPgType|type]] //T//
[[KeyPgAs|as]] [[KeyPgInteger|integer]] dummy
[[KeyPgDeclare|declare]] [[KeyPgConstructor|constructor]] **lib** "//libname//" [ [[KeyPgAlias|alias]] "//symbol_name//" ] ( //arguments list// )
end [[KeyPgType|type]]
##
{{fbdoc item="desc"}}
In ##[[KeyPgSub|Sub]]## or ##[[KeyPgFunction|Function]]## declarations, and also in class method declarations (including constructors and destructors), ##**lib**## indicates the library containing the function. Libraries specified in this way are linked in as if ##[[KeyPgInclib|#inclib "libname"]]## or ##[[CompilerOptl|-l libname]]## had been used.
##**lib**## can also be used with [[KeyPgExternBlock|Extern ... End Extern blocks]] to specifiy a ##**lib**## for all declarations inside.
{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/procs/mydll.bas"}}%%(freebasic)
'' mydll.bas
'' compile with:
'' fbc -dll mydll.bas
Public Function GetValue() As Integer Export
Function = &h1234
End Function
%%
{{fbdoc item="filename" value="examples/manual/procs/lib.bas"}}%%(freebasic)
Declare Function GetValue Lib "mydll" () As Integer
Print "GetValue = &h"; Hex(GetValue())
' Expected Output :
' GetValue = &h1234
%%
{{fbdoc item="diff"}}
- New to ""FreeBASIC""
{{fbdoc item="see"}}
- ##[[KeyPgDeclare|Declare]]##
- ##[[KeyPgInclib|#inclib]]##
{{fbdoc item="back" value="CatPgProcedures|Procedures"}}