Problem with UserLibrary
Problem with UserLibrary
Hi,
I created a Library and now tried to compile an example-source. I get the following messages:
******************************************
PureBasic Linux x86 v3.92
******************************************
Loading external modules...
Starting compilation...
108 lines processed.
Creating the executable.
DynArray.a: could not read symbols: Archive has no index; run ranlib to add one
collect2: ld returned 1 exit status
Error: Linker
What am I doing wrong?
I created a Library and now tried to compile an example-source. I get the following messages:
******************************************
PureBasic Linux x86 v3.92
******************************************
Loading external modules...
Starting compilation...
108 lines processed.
Creating the executable.
DynArray.a: could not read symbols: Archive has no index; run ranlib to add one
collect2: ld returned 1 exit status
Error: Linker
What am I doing wrong?
Undank ist der Welten Lohn
Hi!
@dmoc: I put the Library directly into the PureLibraries-Directory
@olejr: The Library was created with Assembler
I'm going to write a detailed overview of how I created the Library this evening and will post it here. Maybe I just made a little mistake during the creation of it.
@dmoc: I put the Library directly into the PureLibraries-Directory
@olejr: The Library was created with Assembler
I'm going to write a detailed overview of how I created the Library this evening and will post it here. Maybe I just made a little mistake during the creation of it.
Undank ist der Welten Lohn
-
olejr
- Enthusiast

- Posts: 152
- Joined: Sun Jul 11, 2004 7:48 pm
- Location: Lillehammer, No(r)way
- Contact:
Oh.. I didn't get asm to work either, so I did it in C..
I got some error about missing 'main' or something.. Don't remember....
It should also work in asm, but i'm no guru..
But heres a quick rundown on how it should be:
I got some error about missing 'main' or something.. Don't remember....
It should also work in asm, but i'm no guru..
But heres a quick rundown on how it should be:
Code: Select all
fasm source.asm source.o <- repeat for every sourcefile
ar rvs yourlib.a *.o
librarymaker yourlib.desc /TO $(PUREBASIC_HOME)/purelibraries/
Here are some information of how I made the Library:
I am using Suse 9.1, 2.6.4-52-default
1. Write SourceCode in PureBasic-Language (OS-Independent)
2. Use TailBite to create the .asm-Files (Under Windows)
3. Compiled the .asm Files to .o-Files with FAsm (under Linux)
4. Created an Archive containing the .o-Files with ar (ar rs DynArray.a *.o)
5. Corrected the .Desc-File (Content below)
6. Used PBLibraryMaker to create the Library and put it into PureLibraries-Directory
7. Tried to compile an ExampleSource using the Library -> LinkerError
My .asm-Files look like this (this is only one of them):
My .Desc-File looks like this:
These are the Messages I get when I compile an ExampleSource that uses the Library:
When I use the original SourceCode of the Library (IncludeFile) to compile the ExampleSource, everything works fine... :monday:
I am using Suse 9.1, 2.6.4-52-default
1. Write SourceCode in PureBasic-Language (OS-Independent)
2. Use TailBite to create the .asm-Files (Under Windows)
3. Compiled the .asm Files to .o-Files with FAsm (under Linux)
4. Created an Archive containing the .o-Files with ar (ar rs DynArray.a *.o)
5. Corrected the .Desc-File (Content below)
6. Used PBLibraryMaker to create the Library and put it into PureLibraries-Directory
7. Tried to compile an ExampleSource using the Library -> LinkerError
My .asm-Files look like this (this is only one of them):
Code: Select all
format MS COFF
Public PB_DynArray_Erase
Extrn PB_PeekL
Extrn _PB_FreeMemory@4
Extrn PB_PokeL
section '.text' code readable executable
PB_DynArray_Erase:
_DynArray_Erase:
PUSH ebx
PUSH ecx
PUSH ebp
PUSH esi
PUSH edi
MOV esi,esp
SUB esp,8
MOV eax,esp
MOV edx,eax
ADD edx,8
_ClearLoop16:
MOV dword [eax],0
ADD eax,4
CMP eax,edx
JNE _ClearLoop16
MOV eax, dword [esi+24]
MOV dword [esp+0],eax
;
; DynID=PeekL(*DynArrayID)
MOV eax,dword [esp]
CALL PB_PeekL
MOV dword [esp+4],eax
;
; If DynID<>0
MOV ebx,dword [esp+4]
CMP ebx,0
JE _EndIf56
; FreeMemory(DynID-4)
MOV ebx,dword [esp+4]
ADD ebx,-4
PUSH ebx
CALL _PB_FreeMemory@4
; PokeL(*DynArrayID,0)
PUSH dword 0
MOV eax,dword [esp+4]
CALL PB_PokeL
; EndIf
_EndIf56:
;
; EndProcedure
XOR eax,eax
_EndProcedure17:
ADD esp,8
POP edi
POP esi
POP ebp
POP ecx
POP ebx
RET 4
_EndProcedure16:Code: Select all
ASM
;
0
;
LIB
;
4
String
StringExtension
MemoryExtension
Memory
;
DynArray.chm
;
DynArray_ReDim, Long, Long (*DynArrayID, ElementCount) - Creates or redimensionates a DynArray
Byte | StdCall
;
DynArray_Set, Long, Long, Long (*DynArrayID, ElementNumber, Value) - Sets a Value to an Element in the DynArray
Byte | StdCall
;
DynArray_Get, Long, Long (*DynArrayID, ElementNumber) - Gets a Value from an Element in the DynArray
Long | StdCall
;
DynArray_Clone, Long, Long (*DynArrayIDSrc, *DynArrayIDDest) - Clones a DynArray
Byte | StdCall
;
DynArray_Count, Long (*DynArrayID) - Returns the Count of Elements
Long | StdCall
;
DynArray_Clear, Long (*DynArrayID) - Sets all Values to 0
None | StdCall
;
DynArray_FillByPBArray, Long, Long, Long, Long (*DynArrayID, aPBarray, StartDest, ElementCount) - Fills a DynArray by a PureBasic-Array
None | StdCall
;
DynArray_GetMemoryPosition, Long (*DynArrayID) - Returns the MemoryAddress of the LongArray
Long | StdCall
;
DynArray_Erase, Long (*DynArrayID) - Destroys a DynArray
None | StdCall
;
DynArray_RemoveElement, Long, Long (*DynArrayID, ElementNumber) - Removes an Element
None | StdCall
;
DynArray_InsertElement, Long, Long, Long (*DynArrayID, ElementNumber, Value) - Insert an Element and set the Value
Byte | StdCall
;
DynArray_SetString, Long, String, Long (*DynArrayID, aString.s, StartDest) - Set a Part of the DynArray to the Bytes of a String
Byte | StdCall
;
DynArray_GetString, Long, Long, Long (*DynArrayID, StartElement, MaxLength) - Get a Part of the DynArray as a String
String | StdCall
;
Code: Select all
******************************************
PureBasic Linux x86 v3.92
******************************************
Loading external modules...
Starting compilation...
108 lines processed.
Creating the executable.
DynArray.a: could not read symbols: Archive has no index; run ranlib to add one
collect2: ld returned 1 exit status
Error: Linker
Undank ist der Welten Lohn
-
olejr
- Enthusiast

- Posts: 152
- Joined: Sun Jul 11, 2004 7:48 pm
- Location: Lillehammer, No(r)way
- Contact:
Well here's the offending parts:
Ie Windows only stuff...
Not sure if it work if you change this bits either..
Code: Select all
format MS COFF ;<- MS as in MicroSoft
;Should be
format ELF ;<- Not sure about this.. Maybe just COFF (pb output is ELF)
section '.text' code readable executable
;Should be
section '.text' executableNot sure if it work if you change this bits either..
I tried both, COFF and ELF, but nothing worked. Using COFF results in the same Messages as above. When I use ELF I get the following:
With ELF I removed all flags except "exectuable" and "writeable", with COFF "code" and "data"...
hmmmm
Code: Select all
******************************************
PureBasic Linux x86 v3.92
******************************************
Loading external modules...
Starting compilation...
108 lines processed.
Creating the executable.
DynArray.a(DynArray_Clone.o)(.text+0x69): In function `PB_DynArray_Clone':
: undefined reference to `_PB_ReAllocateMemory@8'
DynArray.a(DynArray_Clone.o)(.text+0xa6): In function `PB_DynArray_Clone':
: undefined reference to `_PB_AllocateMemory@4'
DynArray.a(DynArray_Clone.o)(.text+0xe4): In function `PB_DynArray_Clone':
: undefined reference to `_PB_CopyMemory@12'
DynArray.a(DynArray_Erase.o)(.text+0x42): In function `PB_DynArray_Erase':
: undefined reference to `_PB_FreeMemory@4'
DynArray.a(DynArray_FillByPBArray.o)(.text+0xba): In function `PB_DynArray_FillByPBArray':
: undefined reference to `_PB_CopyMemory@12'
DynArray.a(DynArray_InsertElement.o)(.text+0x8c): In function `PB_DynArray_InsertElement':
: undefined reference to `_PB_ReAllocateMemory@8'
DynArray.a(DynArray_InsertElement.o)(.text+0xf5): In function `PB_DynArray_InsertElement':
: undefined reference to `_PB_CopyMemory@12'
DynArray.a(DynArray_ReDim.o)(.text+0x6d): In function `PB_DynArray_ReDim':
: undefined reference to `_PB_FreeMemory@4'
DynArray.a(DynArray_ReDim.o)(.text+0xab): In function `PB_DynArray_ReDim':
: undefined reference to `_PB_ReAllocateMemory@8'
DynArray.a(DynArray_ReDim.o)(.text+0xf8): In function `PB_DynArray_ReDim':
: undefined reference to `_PB_AllocateMemory@4'
DynArray.a(DynArray_RemoveElement.o)(.text+0xa6): In function `PB_DynArray_RemoveElement':
: undefined reference to `_PB_CopyMemory@12'
DynArray.a(DynArray_RemoveElement.o)(.text+0xd1): In function `PB_DynArray_RemoveElement':
: undefined reference to `_PB_ReAllocateMemory@8'
collect2: ld returned 1 exit status
Error: Linkerhmmmm
Undank ist der Welten Lohn
Compiling on Windows for Linux won't work, as internals fonctions names aren't the same, as reported by the linker. You will have to compile it on Linux as olejr told, and tweak the code (may be TailBite could be easily adapted, the output code is very similar - olejr give it a try IIRC).
Fred - AlphaSND

