math/grace port: "" not found ?? [SOLVED]

Igor Robul igorr at
Thu Oct 27 01:20:05 PDT 2005

Rob wrote:

>   XtAppContext app_con;
>   Display *disp = NULL;
>   char *display_name = NULL;
>   XtSetLanguageProc(NULL, NULL, NULL); 
>   XtToolkitInitialize();
>   app_con = XtCreateApplicationContext();
>   disp = XOpenDisplay(display_name);
>(I have simplified this code snippet a bit, for
>this example; also, grace uses Motif for its GUI).
>Before the XOpenDisplay() call, dlerror() does
>not have the error-indicator set, but after
>that call, it has.
>Is this where Linux and FreeBSD are out-of-sync?
>Or does Grace something wrong here, or is this
>a problem cause by FreeBSD or Xorg?
I think, that when XOpenDisplay called, tries load some libraries 
from preconfigured paths, and
last unsuccessful attempt is recorded for dlerror().

dlopen() _does not_ reset dlerror() state on sucess, it just returns non 
NULL. So you must not check dlerror() for error condition, you need 
check return result of dlopen(), and if it is NULL, then you need use 

So, code in grace:

   dlopen("library name", MODE);
   if (dlerror() != NULL) {


need to be:

handle = dlopen("library name", MODE);
if (handle == NULL) {  



just because dlerror() != NULL is not indicator of error.

More information about the freebsd-questions mailing list