Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8385125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:35:24+00:00 2026-06-09T17:35:24+00:00

I am trying to compile SASL under MinGW and in a source file seterror.c

  • 0

I am trying to compile SASL under MinGW and in a source file seterror.c there are two functions declared as follows:


#include <config.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#ifdef HAVE_SYSLOG
#include <syslog.h>
#endif
#include <stdarg.h>
#include <ctype.h>

#include <sasl.h>
#include <saslutil.h>
#include <saslplug.h>
#include "saslint.h"

#ifdef WIN32
/* need to handle the fact that errno has been defined as a function
   in a dll, not an extern int */
# ifdef errno
#  undef errno
# endif /* errno */
#endif /* WIN32 */
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

static int _sasl_seterror_usererr(int saslerr)
{
    /* Hide the difference in a username failure and a password failure */
    if (saslerr == SASL_NOUSER)
    return SASL_BADAUTH;

    /* otherwise return the error given; no transform necessary */
    return saslerr;
}

void sasl_seterror(sasl_conn_t *conn,
           unsigned flags,
           const char *fmt, ...)
{
  size_t outlen=0; /* current length of output buffer */
  size_t pos = 0; /* current position in format string */
  size_t formatlen;
  int result;
  sasl_log_t *log_cb = NULL;
  void *log_ctx;
  int ival;
  char *cval;
  va_list ap; /* varargs thing */
  char **error_buf;
  size_t *error_buf_len;

  if(!conn) {
#ifndef SASL_OSX_CFMGLUE
      if(!(flags & SASL_NOLOG)) {
      /* See if we have a logging callback... */
      result = _sasl_getcallback(NULL, SASL_CB_LOG, (sasl_callback_ft *)&log_cb, &log_ctx);
      if (result == SASL_OK && ! log_cb)
          result = SASL_FAIL;
      if (result != SASL_OK)
          return;

      log_cb(log_ctx, SASL_LOG_FAIL,
         "No sasl_conn_t passed to sasl_seterror");
      }  
#endif /* SASL_OSX_CFMGLUE */
      return;
  } else if(!fmt) return;    

/* we need to use a back end function to get the buffer because the
   cfm glue can't be rooting around in the internal structs */
  _sasl_get_errorbuf(conn, &error_buf, &error_buf_len);

  formatlen = strlen(fmt);

  va_start(ap, fmt); /* start varargs */

  while(pos<formatlen)
  {
    if (fmt[pos]!='%') /* regular character */
    {
      result = _buf_alloc(error_buf, error_buf_len, outlen+1);
      if (result != SASL_OK)
    return;
      (*error_buf)[outlen]=fmt[pos];
      outlen++;
      pos++;
    } else { /* formating thing */
      int done=0;
      char frmt[10];
      int frmtpos=1;
      char tempbuf[21];
      frmt[0]='%';
      pos++;

      while (done==0)
      {
    switch(fmt[pos])
      {
      case 's': /* need to handle this */
        cval = va_arg(ap, char *); /* get the next arg */
        result = _sasl_add_string(error_buf, error_buf_len,
                      &outlen, cval);

        if (result != SASL_OK) /* add the string */
          return;

        done=1;
        break;

      case '%': /* double % output the '%' character */
        result = _buf_alloc(error_buf, error_buf_len, outlen+1);
        if (result != SASL_OK)
          return;
        (*error_buf)[outlen]='%';
        outlen++;
        done=1;
        break;

      case 'm': /* insert the errno string */
        result = _sasl_add_string(error_buf, error_buf_len,
                      &outlen,
                      strerror(va_arg(ap, int)));
        if (result != SASL_OK)
          return;
        done=1;
        break;

      case 'z': /* insert the sasl error string */
        result = _sasl_add_string(error_buf, error_buf_len, &outlen,
             (char *)sasl_errstring(_sasl_seterror_usererr(
                            va_arg(ap, int)),NULL,NULL));
        if (result != SASL_OK)
          return;
        done=1;
        break;

      case 'c':
        frmt[frmtpos++]=fmt[pos];
        frmt[frmtpos]=0;
        tempbuf[0] = (char) va_arg(ap, int); /* get the next arg */
        tempbuf[1]='\0';

        /* now add the character */
        result = _sasl_add_string(error_buf, error_buf_len,
                      &outlen, tempbuf);
        if (result != SASL_OK)
          return;
        done=1;
        break;

      case 'd':
      case 'i':
        frmt[frmtpos++]=fmt[pos];
        frmt[frmtpos]=0;
        ival = va_arg(ap, int); /* get the next arg */

        snprintf(tempbuf,20,frmt,ival); /* have snprintf do the work */
        /* now add the string */
        result = _sasl_add_string(error_buf, error_buf_len,
                      &outlen, tempbuf);
        if (result != SASL_OK)
          return;
        done=1;

        break;
      default: 
        frmt[frmtpos++]=fmt[pos]; /* add to the formating */
        frmt[frmtpos]=0;        
        if (frmtpos>9) 
          done=1;
      }
    pos++;
    if (pos>formatlen)
      done=1;
      }

    }
  }

  (*error_buf)[outlen]='\0'; /* put 0 at end */

  va_end(ap);  

#ifndef SASL_OSX_CFMGLUE
  if(!(flags & SASL_NOLOG)) {
      /* See if we have a logging callback... */
      result = _sasl_getcallback(conn, SASL_CB_LOG, (sasl_callback_ft *)&log_cb, &log_ctx);
      if (result == SASL_OK && ! log_cb)
      result = SASL_FAIL;
      if (result != SASL_OK)
      return;

      result = log_cb(log_ctx, SASL_LOG_FAIL, conn->error_buf);
  }
#endif /* SASL_OSX_CFMGLUE */
}

There are no #defines around them at all. When I compile with: gcc -DHAVE_CONFIG_H -I. -I.. -I../include -I../lib -I../sasldb -I../include -Wall -W -g -O2 -c seterror.c nm produces:

$ nm seterror.o
00000000 b .bss
00000000 d .data
00000000 N .debug_abbrev
00000000 N .debug_aranges
00000000 N .debug_info
00000000 N .debug_line
00000000 N .debug_loc
00000000 N .debug_ranges
00000000 N .debug_str
00000000 r .eh_frame
00000000 r .rdata
00000000 t .text
         U __buf_alloc
         U __imp__sasl_errstring
         U __sasl_add_string
         U __sasl_get_errorbuf
         U __sasl_getcallback
00000000 T _sasl_seterror
         U _snprintf
         U _strerror

Why are there no addresses? If I run nm on the library I get:

$ nm .libs/libsasl2.a | grep sasl_seterror
         U __imp__sasl_seterror
         U __imp__sasl_seterror
         U __imp__sasl_seterror
         U __imp__sasl_seterror
         U __imp__sasl_seterror
         U __imp__sasl_seterror
         U __imp__sasl_seterror
00000000 T _sasl_seterror

Still no address, why? Lastly, when i try to link against the library I get errors saying undefined reference to '__imp__sasl_seterror'.

Can anyone help explain what is going on here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:35:26+00:00Added an answer on June 9, 2026 at 5:35 pm

    There was a header line linked as follows:

    LIBSASL_API void sasl_seterror(sasl_conn_t *conn, unsigned flags,
                       const char *fmt, ...);
    

    and LIBSASL_API was defined as:

    
    #ifdef WIN32
    #  ifdef LIBSASL_EXPORTS
    #   define LIBSASL_API  __declspec(dllexport)
    #  else /* LIBSASL_EXPORTS */
    #   define LIBSASL_API  __declspec(dllimport)
    #  endif /* LIBSASL_EXPORTS */
    #else /* WIN32 */
    # define LIBSASL_API extern
    #endif /* WIN32 */
    

    Therefore, the function was being compiled as though it was going to be dynamically linked.

    However, nm is still producing 00000000 T for sasl_seterror, but the linker isnt complaining about that function any more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to compile two folders in eclipse from a large open source project
When trying to compile a file that include winnt.h via windows.h, I get the
When trying to compile this code: #include <iostream> #include <vector> using namespace std; class
While trying to compile my project, that uses some third party headers, with mingw
Iam trying to compile a file of the following format by making a parser
Im trying to compile a simple class library project,its from Source Safe. However,when i
i am trying to compile a pom file for a project (say com.mycompany.package2 ).
When trying to compile the following: #include <string> #include <iterator> #include <iostream> using namespace
I am trying to compile my source code into a library but i get
I am trying to compile a very simple C program. Installed MinGW using auto

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.