Page 1 of 2
EXPORT Error?
Posted: Tue Feb 02, 2010 1:45 pm
by j50501313
Int.pb:
Code: Select all
Procedure.l Add(a.l,b.l)
ProcedureReturn a + b
EndProcedure
; IDE Options = PureBasic 4.40 (Windows - x86)
; CursorPosition = 146
; FirstLine = 120
; Folding = -
; EnableThread
; EnableAdmin
; LinkerOptions = Int.txt
Int.txt:
polink.exe :
/EXPORT:symbol[=[module.]symbol][,@ordinal[,NONAME]][,DATA]
/EXPORT:linker,_Add@8,NONAME
Why the error?
C++ to
#pragma comment(linker, "/EXPORT:_Add,@1,NONAME")
--------------------------------
I would like to create an EXE with the export functions.
C++ Has been achieved, I would like to use PB to achieve.

Re: EXPORT Error?
Posted: Tue Feb 02, 2010 1:51 pm
by Rings
cany you be more specific ?
anyway:
Add@1
seems wrong, as you define 2 Longs (2 x 4 byte) as Paramter,
so it should be :
Add@8
Re: EXPORT Error?
Posted: Tue Feb 02, 2010 2:08 pm
by j50501313
Hi: Rings
As you said, I changed, is still the same error.
Re: EXPORT Error?
Posted: Tue Feb 02, 2010 2:15 pm
by srod
Should it not be :
Anyhow, I don't know whether PB will place the 'Add' symbol within the object file's symbol table prior to linking unless you are creating a dll? For an exe, I don't know? Without this you will not be able to export the symbol.
Re: EXPORT Error?
Posted: Tue Feb 02, 2010 2:22 pm
by j50501313
Hi srod:
I would like to create an EXE with the export functions.
Re: EXPORT Error?
Posted: Tue Feb 02, 2010 2:25 pm
by j50501313
Hi srod
Can you tell me solution?
Re: EXPORT Error?
Posted: Tue Feb 02, 2010 2:26 pm
by Fred
If you use ProcedureCDLL, there is no @xxx added to the exported name.
Re: EXPORT Error?
Posted: Tue Feb 02, 2010 2:29 pm
by j50501313
Hi Fred
Procedure, if I use it?
Re: EXPORT Error?
Posted: Tue Feb 02, 2010 2:32 pm
by srod
You'll have to ask Fred if the 'Add' symbol is made public in these cases?
If not.... edit the ASM file generated by the compiler to make the relevant procedure label public (it will be something like _Procedure0) and then reassemble by using the PB compiler from the command line with the /REASM switch (not forgetting to specify your linker file etc.)
I see no reason why this should not work... but then I haven't tried it!

Re: EXPORT Error?
Posted: Tue Feb 02, 2010 2:40 pm
by Fred
Man, i answered completely out of topic in the previous post

. If you want to export a symbol from an exe, you will have to hack the asm, as srod said.
Re: EXPORT Error?
Posted: Tue Feb 02, 2010 2:43 pm
by j50501313
Hi Fred:
Modify what position?
Code: Select all
;
; PureBasic 4.40 (Windows - x86) generated code
;
; (c) 2009 Fantaisie Software
;
; The header must remain intact for Re-Assembly
;
; :System
; KERNEL32
; :Import
;
format MS COFF
;
extrn _ExitProcess@4
extrn _GetModuleHandleA@4
extrn _HeapCreate@12
extrn _HeapDestroy@4
;
extrn _memset
public _PB_Instance
public _PB_ExecutableType
public _PB_MemoryBase
public PB_Instance
public PB_MemoryBase
public _PB_EndFunctions
macro pb_public symbol
{
public _#symbol
public symbol
_#symbol:
symbol:
}
macro pb_align value { rb (value-1) - ($-_PB_DataSection + value-1) mod value }
macro pb_bssalign value { rb (value-1) - ($-_PB_BSSSection + value-1) mod value }
public PureBasicStart
;
section '.code' code readable executable align 8
;
;
PureBasicStart:
;
PUSH dword I_BSSEnd-I_BSSStart
PUSH dword 0
PUSH dword I_BSSStart
CALL _memset
ADD esp,12
PUSH dword 0
CALL _GetModuleHandleA@4
MOV [_PB_Instance],eax
PUSH dword 0
PUSH dword 4096
PUSH dword 0
CALL _HeapCreate@12
MOV [PB_MemoryBase],eax
;
; Procedure.l Add(a.l,b.l)
macro MP0{
_Procedure0:
PUSH ebx
PS0=8
; ProcedureReturn a + b
MOV ebx,dword [esp+PS0+0]
ADD ebx,dword [esp+PS0+4]
MOV eax,ebx
JMP _EndProcedure1
; EndProcedure
XOR eax,eax
_EndProcedure1:
POP ebx
RET 8
}
_PB_EOP_NoValue:
PUSH dword 0
_PB_EOP:
CALL _PB_EndFunctions
PUSH dword [PB_MemoryBase]
CALL _HeapDestroy@4
CALL _ExitProcess@4
_PB_EndFunctions:
RET
;
;
section '.data' data readable writeable
;
_PB_DataSection:
pb_public PB_DEBUGGER_LineNumber
dd -1
pb_public PB_DEBUGGER_IncludedFiles
dd 0
pb_public PB_DEBUGGER_FileName
db 0
_PB_ExecutableType: dd 0
align 4
align 4
s_s:
dd 0
dd -1
align 4
;
section '.bss' readable writeable
_PB_BSSSection:
align 4
;
I_BSSStart:
_PB_MemoryBase:
PB_MemoryBase: rd 1
_PB_Instance:
PB_Instance: rd 1
;
align 4
PB_DataPointer rd 1
align 4
align 4
align 4
align 4
I_BSSEnd:
section '.data' data readable writeable
SYS_EndDataSection:
Re: EXPORT Error?
Posted: Tue Feb 02, 2010 6:39 pm
by Olliv
Hi J50501313
(Post edited after a first code without success)
Normally you can see it:
Code: Select all
; Procedure.I AddIntPlusInt(A.I, B.I)
Macro MP0{
_Procedure0:
PUSH ebx
PS0=8 Etc...
...
Like sRod said, rename _Procedure0 to a public name you prefer, for example _MyAddition.
And Add the line before
In the other listing, you add
(because PS0=8)
Re: EXPORT Error?
Posted: Tue Feb 02, 2010 8:42 pm
by j50501313
Hi Olliv:
I follow your changes, errors.
Code: Select all
;
; PureBasic 4.40 (Windows - x86) generated code
;
; (c) 2009 Fantaisie Software
;
; The header must remain intact for Re-Assembly
;
; :System
; KERNEL32
; :Import
;
format MS COFF
;
extrn _ExitProcess@4
extrn _GetModuleHandleA@4
extrn _HeapCreate@12
extrn _HeapDestroy@4
;
extrn _memset
extrn _SYS_InitString@0
;
extrn _SYS_GetStringBase@0
extrn _SYS_GetStringBasePointer@0
extrn _SYS_GetStringBaseNoResult@0
extrn _SYS_GetStringBasePosition@0
extrn _SYS_SetStringBasePosition@4
extrn _SYS_RestoreStringBasePosition@4
extrn _SYS_IncrementStringBasePosition@0
extrn _Procedure0@8
;
public _PB_Instance
public _PB_ExecutableType
public _PB_MemoryBase
public PB_Instance
public PB_MemoryBase
public _PB_EndFunctions
public _Procedure0
macro pb_public symbol
{
public _#symbol
public symbol
_#symbol:
symbol:
}
macro pb_align value { rb (value-1) - ($-_PB_DataSection + value-1) mod value }
macro pb_bssalign value { rb (value-1) - ($-_PB_BSSSection + value-1) mod value }
extrn SYS_CpuID
public PureBasicStart
;
section '.code' code readable executable align 8
;
;
PureBasicStart:
;
PUSH dword I_BSSEnd-I_BSSStart
PUSH dword 0
PUSH dword I_BSSStart
CALL _memset
ADD esp,12
PUSH dword 0
CALL _GetModuleHandleA@4
MOV [_PB_Instance],eax
PUSH dword 0
PUSH dword 4096
PUSH dword 0
CALL _HeapCreate@12
MOV [PB_MemoryBase],eax
CALL SYS_CpuID
;
CALL _SYS_InitString@0
;
; Procedure.l A(a.l,b.l)
macro MP0{
_Procedure0:
PUSH ebx
PS0=8
; ProcedureReturn a + b
MOV ebx,dword [esp+PS0+0]
ADD ebx,dword [esp+PS0+4]
MOV eax,ebx
JMP _EndProcedure1
; EndProcedure
XOR eax,eax
_EndProcedure1:
POP ebx
RET 8
}
_PB_EOP_NoValue:
PUSH dword 0
_PB_EOP:
CALL _PB_EndFunctions
PUSH dword [PB_MemoryBase]
CALL _HeapDestroy@4
CALL _ExitProcess@4
_PB_EndFunctions:
RET
;
;
section '.data' data readable writeable
;
_PB_DataSection:
pb_public PB_DEBUGGER_LineNumber
dd -1
pb_public PB_DEBUGGER_IncludedFiles
dd 0
pb_public PB_DEBUGGER_FileName
db 0
_PB_ExecutableType: dd 0
;
; Dynamic functions jump table
;
public _SYS_StaticStringStart
_SYS_StaticStringStart:
pb_public PB_NullString
db 0
public _SYS_StaticStringEnd
_SYS_StaticStringEnd:
align 4
align 4
s_s:
dd 0
dd -1
align 4
;
section '.bss' readable writeable
_PB_BSSSection:
align 4
;
I_BSSStart:
_PB_MemoryBase:
PB_MemoryBase: rd 1
_PB_Instance:
PB_Instance: rd 1
;
align 4
PB_DataPointer rd 1
align 4
align 4
align 4
align 4
I_BSSEnd:
section '.data' data readable writeable
SYS_EndDataSection:
Code: Select all
Error: Assembler
C:\PureBasic.asm [37]:
public _Procedure0
error: undefined symbol '_Procedure0'.
Re: EXPORT Error?
Posted: Tue Feb 02, 2010 8:46 pm
by Olliv
Wopopop! Don't forget it before:
I wrote:Like sRod said, rename _Procedure0 to a public name you prefer, for example _MyAddition.
And if sRod says it, Chuck Norris can't do it better.
Re: EXPORT Error?
Posted: Tue Feb 02, 2010 9:01 pm
by j50501313
can you give a complete code?
This EXE is a C + + was created. PB can tell the same?
