473,785 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ 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.l ib).
----------------------

LONG VERSION> Here are the details:

Here is a sample from the .dll source that creates a font character (stuff
deleted)
"gdFontGian t" 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 2029
On Sun, 7 Dec 2003 18:07:51 -0800, "smackdab" <sm*******@hotm ail.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.program mer.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.l earn.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
1921
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 compiles and runs fine with x declared as extern. So is it necessary to declare x as extern if one get away without declaring it extern ? What is the standard and good practice ?
3
10657
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
23000
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 this and when to do this. For example, if main.c has: double some_val; // global and first.c wants to use the variable and the value that was assigned to
18
4290
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 where it's defined.
19
3860
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 storage-class specifier. My (little) C experience tells me that an object with "extern" is to let the linker knows that the object is referencing the object defined in somewhere, and this "somewhere" object does not have the storage-class specifier...
5
16607
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 extern storage class: /****************************************************************** SOURCE FILE ONE *******************************************************************/ extern int i; /* Reference to i, defined below */
17
4934
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
2859
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
2518
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 compile without problems but when linking the linker cant find it and aborts. lets say a variable is called "dummy" then the linker gives an error that it cant find "_dummy". The variable extern declaration is already within "extern "C ""
7
3536
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 (not the instructor) explained that if the same function prototype is used in more than one source file in a project, that the linker will complain.
0
9485
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10161
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10098
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8986
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7506
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4058
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 we have to send another system
3
2890
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.