June 15, 2024, 10:46:09 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Static lib error

Started by King64, February 01, 2010, 06:36:58 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

King64

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) ??  ???

LarryMc

try this and see if it works:

export sum

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


Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

sapero

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.

King64

Thanks Sapero, your explanations are excellent as usual  :)

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library