By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,238 Members | 1,771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,238 IT Pros & Developers. It's quick & easy.

extern access to variable

P: n/a
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!!!



Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Sun, 7 Dec 2003 18:07:51 -0800, "smackdab" <sm*******@hotmail.com>
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
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.