$LIBRARY directive

Purpose: The library named as a parameter in a $LIBRARY statement will be linked to the program without the need, at link time, to specify explicitly, on the command line or in a makefile, the library.

$LIBRARY is an alias to the C compiler "#pragma lib" feature. $LIBRARY operates on the same level as #INCLUDE and will emit the appropriate library statements within the header section of the emitted C source code.


 Syntax 1:

 $LIBRARY "c:\bcx\lib\mylib.lib" 

 Parameters:

  • "c:\bcx\lib\mylib.lib" will search in the folder specified for the library.

 Syntax 2:

 $LIBRARY "mylib.lib" 

 Parameters:

  • "mylib.lib" will search in the current working folder for the library.

 Syntax 3:

 $LIBRARY <mylib.lib> 

 Parameters:

  • <mylib.lib> will search in the C compiler's default LIB folder for the library.

Example:


 $LIBRARY <shell32.lib>
 '-------------------------------------------------
 '   BrowseFolder
 '   Original by Jacob Navia
 '   Converted to BCX version by Kevin Diggins
 '-------------------------------------------------
 DIM Folder$
 
 IF BrowseDir("Choose a folder", Folder$) THEN
   PRINT "Chosen Folder: ", Folder$
 ELSE
   PRINT "Action Cancelled"
 END IF
 
 FUNCTION BrowseDir(Title$, Result$)
   '---------------------------------------
   LOCAL pMalloc      AS LPMALLOC
   LOCAL browseInfo   AS BROWSEINFO
   LOCAL lpItemIDList AS LPITEMIDLIST
   LOCAL Rc
   '---------------------------------------
   CONST BIF_NEWDIALOGSTYLE = 64
   '---------------------------------------
   IF S_OK <> SHGetMalloc(&pMalloc) THEN EXIT FUNCTION
   memset(&browseInfo, 0, SIZEOF(BROWSEINFO))
   browseInfo.hwndOwner      = GetActiveWindow()
   browseInfo.pszDisplayName = Result$
   browseInfo.lpszTitle      = Title$
   browseInfo.ulFlags = BIF_NEWDIALOGSTYLE
 
   lpItemIDList = SHBrowseForFolder(&browseInfo)
   IF lpItemIDList <> NULL THEN
     Result$ = ""
     IF SHGetPathFromIDList(lpItemIDList,Result$) THEN
       IF LEN(Result$) > 0 THEN Rc = 1
     END IF
     pMalloc->lpVtbl->FREE(pMalloc,lpItemIDList)
   END IF
   pMalloc->lpVtbl->Release(pMalloc)     ' BCX is amazing !
   FUNCTION = Rc
 END FUNCTION

BCX Console Sample Programs using $LIBRARY directive.

S66.bas S73.bas S92.bas S126.bas S128.bas

$NOLIBRARY directive

Purpose: The library named as a parameter with a $NOLIBRARY directive will not be linked to the program. This directive is used with the libraries that BCX loads by default when the $CPP directive or the bc.exe -c command line flag is used.


 Syntax:

 $NOLIBRARY "LibraryName.lib" 

 Parameters:

  • "LibraryName.lib" is the name of library not to load.