extern access to variable

Discussion in 'C Programming' started by smackdab, Dec 8, 2003.

  1. smackdab

    smackdab Guest

    Hi, I am using MSVC to compile GD and I think I am down to my last problem
    (we'll see ;-)

    I can compile libgd.dll and libgd.lib ok but a gdtest.exe program that
    refers to extern font variables
    are not defined and I have no idea how this should work...sorry for the
    confusing email, the
    more I write, the worse it becomes ;-)

    SHORT VERSION>
    My gdtest.exe program's .map file does not list gdFontGiant and seems to
    only list functions
    that are visabally called in the source. There is a "enable function level
    linking" setting, but it
    is NOT on...How does a .exe refer to a char [] created in a .dll? (does it
    come from the .lib?)
    Does the .lib hold data variables?
    If I don't link in the libgd.lib, I get unresolved externals except for the
    variables, this call does
    nothing: extern gdFontPtr gdFontGiant;
    gdFontPtr is defined as a * to a struct, but gdFontGiant is a char[] defined
    in libgd.c(libgd.lib).
    ----------------------

    LONG VERSION> Here are the details:

    Here is a sample from the .dll source that creates a font character (stuff
    deleted)
    "gdFontGiant" is what I want to access from gdtest.exe...

    #include "gdfontg.h"
    char gdFontGiantData[] = {
    /* Char 0 */
    0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0,
    };
    gdFont gdFontGiantRep = {
    256,
    0,
    9,
    15,
    gdFontGiantData
    };

    gdFontPtr gdFontGiant = &gdFontGiantRep;

    ------------------------------------------------------
    Here is the gdfontg.h referenced above:

    #ifndef _GDFONTG_H_
    #define _GDFONTG_H_ 1
    #ifdef __cplusplus
    extern "C"
    {
    #endif
    #include "gd.h"
    extern gdFontPtr gdFontGiant;
    #ifdef __cplusplus
    }
    #endif
    #endif

    ------------------------------------------------------
    And the .def file that exports gdFontGiant

    ; LIBGD.DEF - module definition file

    LIBRARY LIBGD
    DESCRIPTION 'LIBGD.DLL'
    EXPORTS
    gdAlphaBlend
    gdDPExtractData
    gdFontGiant

    ------------------------------------------------------

    gdFontGiant *seems* to be in the .map .lib and .dll files if I bring
    up a text editor and search for the gdFontGiant string...

    ------------------------------------------------------

    The gdtest.exe program, just has
    #include "gdfontg.h"
    To include the extern part
    extern gdFontPtr gdFontGiant;

    But, when I am in the debugger gdFontGiant isn't defined
    I have added libgd.lib in the link options, and no compiler errors

    Is gdFontGiant statically compiled into gdtest.exe ?
    Or does it come from the DLL? (doesn't seem likely as
    it isn't a function...)

    Anything is helpful!!!
     
    smackdab, Dec 8, 2003
    #1
    1. Advertising

  2. smackdab

    Jack Klein Guest

    On Sun, 7 Dec 2003 18:07:51 -0800, "smackdab" <>
    wrote in comp.lang.c:

    > Hi, I am using MSVC to compile GD and I think I am down to my last problem
    > (we'll see ;-)
    >
    > I can compile libgd.dll and libgd.lib ok but a gdtest.exe program that
    > refers to extern font variables
    > are not defined and I have no idea how this should work...sorry for the
    > confusing email, the
    > more I write, the worse it becomes ;-)


    [snip]

    You need to take this to a Windows programming group like
    news:comp.os.ms-windows.programmer.win32, or one of Microsoft's
    support groups in the news:microsoft.public.vc.* family. This is a
    compiler and Windows issue, not a language one.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c /faq
     
    Jack Klein, Dec 8, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas Matthews
    Replies:
    5
    Views:
    2,486
    tom_usenet
    Aug 2, 2004
  2. Dan Elliott
    Replies:
    4
    Views:
    13,277
    Tom Widmer
    Dec 8, 2004
  3. Bangalore

    extern struct variable

    Bangalore, Aug 2, 2005, in forum: C++
    Replies:
    5
    Views:
    453
    Srini
    Sep 6, 2005
  4. extern variable

    , Dec 24, 2006, in forum: C++
    Replies:
    4
    Views:
    575
  5. Andre
    Replies:
    5
    Views:
    550
    Keith Thompson
    Jul 17, 2012
Loading...

Share This Page