IonicWind Software

IWBasic => General Questions => Topic started by: King64 on February 01, 2010, 06:36:58 AM

Title: Static lib error
Post by: King64 on February 01, 2010, 06:36:58 AM
Trying to make a static lib i got the following error:

Compiling...
example.eba
No Errors

Linking...
Emergence Linker v1.12 Copyright ÂÃ,© 2009 Ionic Wind Software
Unresolved external __imp_sum
Error: Unresolved extern __imp_sum
Error(s) in linking C:\Documents and Settings\.........example.exe


That's the simply code for my static lib:

GLOBAL sum

SUB sum(a:int,b:int),INT
RETURN a+b
ENDSUB


here is the code where i use it

$USE "sum.lib"

DECLARE IMPORT, sum(a:INT,b:INT),INT

PRINT Sum(12,42)
DO:UNTIL INKEY$<>""
end


Where is the mistake(s) ??  ???
Title: Re: Static lib error
Post by: LarryMc on February 01, 2010, 06:57:34 AM
try this and see if it works:

export sum

global SUB sum(a:int,b:int),INT
RETURN a+b
ENDSUB


Larry
Title: Re: Static lib error
Post by: sapero on February 01, 2010, 07:09:31 AM
King64, use EXTERN instead IMPORT, the import keyword is used only with import libraries, or in special cases as a dynamic function pointer.DECLARE EXTERN, sum(a:INT,b:INT),INT
If you really want to use the import keyword, change your code to
GLOBAL sum
GLOBAL __imp_sum

SUB sum(a:int,b:int),INT
RETURN a+b
ENDSUB

_asm
align 4
__imp_sum: dd sum
_endasm




Larry, "export" is used only when generating an exe or dll. It does nothing when the target is a static lbrary.
Title: Re: Static lib error
Post by: King64 on February 01, 2010, 07:24:43 AM
Thanks Sapero, your explanations are excellent as usual  :)
Title: Re: Static lib error
Post by: LarryMc on February 01, 2010, 10:13:24 AM
you're right as always Sapero.
I had glanced at what I thought was one of my static libs but after going back I see it was for a dll.

Larry