Thread: undefined reference to `_imp__Options|

  1. #1
    Registered User
    Join Date
    Nov 2015
    Posts
    112

    undefined reference to `_imp__Options|

    I do not understand, I do not know, because there is a description of this function is included .. Help!


    \Zvjyazuvannya.cpp|13|undefined reference to `_imp__Options|

    Code:
    /* Глава 5. Версия atou, использующая явное связывание. */
    #include "EvryThng.h"
    #include "OPTIONS.C"
    #include "REPRTERR.C"
    int _tmain (int argc, LPTSTR argv [])
    {
       /* Объявить переменную Asc2Un как функцию. */
       BOOL (*Asc2Un)(LPCTSTR, LPCTSTR, BOOL);
       DWORD LocFileIn, LocFileOut, LocDLL, DashI;
       HINSTANCE hDLL;
       FARPROC pA2U;
    
       LocFileIn = Options (argc, argv, _T ("i"), &DashI, NULL);
       LocFileOut = LocFileIn + 1;
       LocDLL = LocFileOut + 1;
       /* Проверить существование файла, а также опущен ли параметр DashI. */
       /* Загрузить функцию преобразования из ASCII в Unicode. */
       hDLL = LoadLibrary (argv [LocDLL]);
       if (hDLL == NULL)
          ReportError (_T ("Не удается загрузить DLL."), 1, TRUE);
       /* Получить адрес точки входа. */
       pA2U = GetProcAddress (hDLL, "Asc2Un");
       if (pA2U == NULL)
          ReportError (_T ("Не найдена точка входа."), 2, TRUE);
       /* Привести тип указателя. Здесь можно использовать typedef. */
       Asc2Un = (BOOL (*)(LPCTSTR, LPCTSTR, BOOL)) pA2U;
    
       /* Вызвать функцию. */
       Asc2Un (argv [LocFileIn], argv [LocFileOut], FALSE);
       FreeLibrary (hDLL);
       return 0;
    }
    Code:
    /* Utility function to extract option flags from the command line.  */
    
    #include "Everything.h"
    #include <stdarg.h>
    
    DWORD Options (int argc, LPCTSTR argv [], LPCTSTR OptStr, ...)
    
    /* argv is the command line.
        The options, if any, start with a '-' in argv[1], argv[2], ...
        OptStr is a text string containing all possible options,
        in one-to-one correspondence with the addresses of Boolean variables
        in the variable argument list (...).
        These flags are set if and only if the corresponding option
        character occurs in argv [1], argv [2], ...
        The return value is the argv index of the first argument beyond the options. */
    
    {
        va_list pFlagList;
        LPBOOL pFlag;
        int iFlag = 0, iArg;
    
        va_start (pFlagList, OptStr);
    
        while ((pFlag = va_arg (pFlagList, LPBOOL)) != NULL
                    && iFlag < (int)_tcslen (OptStr)) {
            *pFlag = FALSE;
            for (iArg = 1; !(*pFlag) && iArg < argc && argv [iArg] [0] == _T('-'); iArg++)
                *pFlag = _memtchr (argv [iArg], OptStr [iFlag],
                        _tcslen (argv [iArg])) != NULL;
            iFlag++;
        }
    
        va_end (pFlagList);
    
        for (iArg = 1; iArg < argc && argv [iArg] [0] == _T('-'); iArg++);
    
        return iArg;
    }

  2. #2
    Registered User
    Join Date
    Jun 2015
    Posts
    1,643
    Do you really have a header called "EvryThng.h" and another called "Everything.h"? What do they contain?

  3. #3
    Registered User
    Join Date
    Nov 2015
    Posts
    112
    Yes. This confusion has arisen from the fact that I use the book in Russian. And use together a book in English. Book in Russian contains different and garbled code. Both codes go awry. I am copying code from one book, then another, depending on which book you read. So different code tangling.

    Zvjyazuvannya1.zip
    Last edited by Dmy; 05-01-2017 at 04:26 AM.

  4. #4
    Registered User
    Join Date
    Jun 2015
    Posts
    1,643
    That's a confusing mess of code.

    Did the original authors actually directly include C code like that?

    As an experiment, try commenting out the #include "support.h" line from both Environment.h and Envirmnt.h.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,738
    It looks like you're compiling C++.

    > int _tmain (int argc, LPTSTR argv [])
    > LocFileIn = Options (argc, argv, _T ("i"), &DashI, NULL);
    vs
    > DWORD Options (int argc, LPCTSTR argv [], LPCTSTR OptStr, ...)
    vs
    > support.h:LIBSPEC DWORD Options (int, LPCTSTR *, LPCTSTR, ...);

    Perhaps if you made the whole thing const-correct and declaration-correct (what is LIBSPEC?), it would help.

    Through function overloading, it seems like the one you declare isn't the one you're trying to call.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    Nov 2015
    Posts
    112
    Thank you very much for your help!
    I am very grateful to you.
    I ask you to forgive me for my inattention and incompetence. I myself would not understand for a very long time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference
    By Dudealadude in forum C Programming
    Replies: 1
    Last Post: 11-29-2011, 02:43 PM
  2. undefined reference to
    By diego in forum C++ Programming
    Replies: 4
    Last Post: 05-18-2010, 03:06 PM
  3. undefined reference....
    By najwani in forum C Programming
    Replies: 0
    Last Post: 04-06-2009, 10:05 PM
  4. undefined reference to
    By shaun84 in forum C Programming
    Replies: 12
    Last Post: 10-15-2006, 02:32 AM
  5. Undefined reference
    By Buckshot in forum C++ Programming
    Replies: 5
    Last Post: 08-16-2005, 03:28 PM

Tags for this Thread