EXPORT Error?

Just starting out? Need help? Post your questions and find answers here.
j50501313
User
User
Posts: 20
Joined: Fri Oct 23, 2009 11:51 am

EXPORT Error?

Post 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:

Code: Select all

/EXPORT:_Add@8,NONAME
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.


Image
Last edited by j50501313 on Tue Feb 02, 2010 8:58 pm, edited 5 times in total.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Re: EXPORT Error?

Post 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
SPAMINATOR NR.1
j50501313
User
User
Posts: 20
Joined: Fri Oct 23, 2009 11:51 am

Re: EXPORT Error?

Post by j50501313 »

Hi: Rings

As you said, I changed, is still the same error.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: EXPORT Error?

Post by srod »

Should it not be :

Code: Select all

/EXPORT:Add, @1, NONAME
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.
I may look like a mule, but I'm not a complete ass.
j50501313
User
User
Posts: 20
Joined: Fri Oct 23, 2009 11:51 am

Re: EXPORT Error?

Post by j50501313 »

Hi srod:

I would like to create an EXE with the export functions.
j50501313
User
User
Posts: 20
Joined: Fri Oct 23, 2009 11:51 am

Re: EXPORT Error?

Post by j50501313 »

Hi srod

Can you tell me solution?
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: EXPORT Error?

Post by Fred »

If you use ProcedureCDLL, there is no @xxx added to the exported name.
j50501313
User
User
Posts: 20
Joined: Fri Oct 23, 2009 11:51 am

Re: EXPORT Error?

Post by j50501313 »

Hi Fred

Procedure, if I use it?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: EXPORT Error?

Post 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! :wink:
I may look like a mule, but I'm not a complete ass.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: EXPORT Error?

Post by Fred »

Man, i answered completely out of topic in the previous post :D. If you want to export a symbol from an exe, you will have to hack the asm, as srod said.
j50501313
User
User
Posts: 20
Joined: Fri Oct 23, 2009 11:51 am

Re: EXPORT Error?

Post 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:
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: EXPORT Error?

Post 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

Code: Select all

public _MyAddition
In the other listing, you add

Code: Select all

extrn _MyAddition@8
(because PS0=8)
j50501313
User
User
Posts: 20
Joined: Fri Oct 23, 2009 11:51 am

Re: EXPORT Error?

Post 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'.
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: EXPORT Error?

Post 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.
j50501313
User
User
Posts: 20
Joined: Fri Oct 23, 2009 11:51 am

Re: EXPORT Error?

Post by j50501313 »

can you give a complete code?


This EXE is a C + + was created. PB can tell the same?



Image
Post Reply