extern keyword and dlls

Václav Haisman v.haisman@sh.cvut.cz
Mon Feb 11 10:39:00 GMT 2008


masta uy wrote, On 11.2.2008 0:40:
> Hello,
> 
> I am in working on porting some code to cygwin but I am stuck. I need it to be compiled as a dll but gcc gives me a linking error.
> 
> This code triggers the error:
> 
> extern int num;
> 
> int foo() {
>   extern int num;
>   num = 5;
> }
You are missing a definition of num. All you have now is just a declaration.

> 
> 
> the error is:
> 
> hello.c:(.text+0x5): undefined reference to `_num'
> 
> And this is how I call gcc: "gcc -shared hello.c" 
> 
> Interestingly, the code above does work on my ubuntu installation (ubuntu 7.10 gcc 4.1.3)
> 
> Any help is appreciated
> 
> Regards
> Fernando

--
VH

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20080211/697069cb/attachment.sig>


More information about the Cygwin mailing list