473,473 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

extern access to variable

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
1 2009
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: mark | last post by:
compiler g++ on linux file.h has the following, int x=5; and inside the main program file I can access "x" without declaring it "extern x". Program compiles and runs fine.... also program...
3
by: Rolf S. Arvidson | last post by:
Be kind, a newb question here. I don't understand why I get a compile-time error from the following: I define a variable in main.cpp as such double x = 1.; int _tmain(int argc, _TCHAR* argv){...
2
by: Sona | last post by:
Hi, I read some place that if you have two or more modules or files in C, you can share variables between the these modules or files using the 'extern' keyword. I'm not really sure how to do...
18
by: tweak | last post by:
What's the best way to use extern when using multiplefiles that is easiest to maintain? Is it best to declare: extern int a; in a header file and include the header file in all files except...
19
by: ccwork | last post by:
Hi all, I am reading "C: A Reference Manual" 4th ed and I get lost for the "extern". It says that global object without specifying the storage-class specifier will have "extern" as the default...
5
by: siliconwafer | last post by:
Hi all, I wanted to know that is use of extern keyword mandatory in case of global variables and functions used in other source files? i.e consider a following piece of code from MSDN explaining...
17
by: Tapeesh | last post by:
I would like to know what is the expected behaviour of C compilers when an extern decleration is intialized. When the following code is compiled using gcc //File extern.c int arr ; int a ;
5
by: Christian Christmann | last post by:
Hi, I've tree questions on the storage class specifier "extern": 1) Code example: int main( void ) { int b = -2; // my line 3 if ( a ) {
5
by: Noel Mosa | last post by:
Hi, i am using a library compiled in C(FFMPEG) and need to access a number of variables that are defined within a C module. The include file for the library declares it as a extern pointer. I can...
7
by: blangela | last post by:
I am currently taking a course and one of the example programs showed a function prototype something like: extern void func(); I asked why the "extern" was necessary. Someone in the class...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.