27 October 2021, 00:01 | #1 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
How can I use third party libraries in my project?
I am trying to use a regex library in my project. I found this regex library from aminet but cannot understand how to include this in my project.
I compile my executable using a make file. I have placed regex.library in my project directory. I then edited my makefile with the -L. and -l flags as follows; Code:
LIBS = -lamiga -lauto -L. -lregex I have tried -lregex.library or moving the regex.libraty to the System:Libs but to no avail. Anyone knows how I can include a third party library to my project? |
27 October 2021, 05:41 | #2 |
Registered User
Join Date: May 2021
Location: Melbourne, Australia
Posts: 40
|
What the compiler library is looking for is a linker library, which is different from an Amiga library, which this is.
To access that library, ensure that all that library's header and proto files are accessible, include them in your source code and then use OpenLibrary() from AmigaOS to open that library and start accessing. Don't forget to CloseLibrary() after you are finished. -lauto won't automatically open that library for you because it doesn't know that 3rd party library. |
27 October 2021, 08:06 | #3 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
So I have now also placed regex.lib in my source directory. This means that in my source directory I now have regex.library, regex.lib and regex.h. I use the flags -L. and -lregex. The error message has now changed to "Fatal error 11. regex.lib: File format not recognized". Do I need to recompile the library using my compiler for it to work?
Last edited by Sim085; 27 October 2021 at 10:27. |
27 October 2021, 10:28 | #4 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Looks like this is a linker library in Aztec-C "lb" format. Only the Aztec linker might be able to use it.
(Is there a description of that format somewhere?) Quote:
Unfortunately the author didn't provide an FD file for his shared library. Otherwise the normal procedure to use third party libraries would be to simply regenerate the linker library, proto- and inline headers for it with fd2pragma. You could also try to create an FD file yourself from the information provided in interface.asm. |
|
27 October 2021, 11:45 | #5 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
I can see some other distributions of regex on aminet that do have an fd file.
Are there any guides how I can regenerate the linker library from this? |
27 October 2021, 12:26 | #6 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Linker library with stub functions:
Code:
fd2pragma special 12 to vlibos3: hunkname CODE regex.fd Code:
fd2pragma special 38 to vincludeos3:proto regex.fd Code:
fd2pragma special 70 voidbase to vincludeos3:inline regex.fd clib path_to/clib/regex_protos.h |
28 October 2021, 11:48 | #7 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
I am having problems with the last step.
I have modified as follows; Code:
fd2pragma special 70 voidbase to vincludeos3:inline regexp.fd clib vincludeos3:proto/RegExp.h However I get the following output: Code:
SourceFile: regexp.fd ResultFile: vincludeos3:inline/RegExp_protos.h Error 27 : No prototupes file (CLIB parameter) was specified. Last edited by Sim085; 29 October 2021 at 11:40. |
29 October 2021, 11:02 | #8 | |
Zone Friend
Join Date: May 2006
Location: France
Posts: 1,801
|
Quote:
|
|
29 October 2021, 12:09 | #9 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
Just to clarify that I have moved to this distribution which comes with a .fd file.
https://aminet.net/package/util/libs/RegExpLib From what I understand the first command creates the linker library from the fd file. The second command is creating the header file (under the proto directory of vbcc), this is what I would include in my source files. However I do not understand what the third command is doing. When I open the header file generated I can see there is the following entry but I cannot identify any clib directory under my vbcc installation. Code:
#if !defined(CLIB_REGEXP_PROTOS_H) && !defined(__GNUC__) #include <clib/RegExp_protos.h> #endif Code:
#elif defined(__VBCC__) #include <inline/RegExp_protos.h> |
29 October 2021, 18:50 | #10 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
|
|
29 October 2021, 19:09 | #11 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Quote:
inlinedirectory with the name libname_protos.h. It is automatically included and used as soon as you include <proto/libname.h>. If you want to use the stubs, you would include <clib/libname_protos.h>instead. Quote:
clib/libname_protos.h. This doesn't seem to be the case with the RegExp library you found - which is also somewhat old... Looking into the RegExpLib archive I guess that regexp.his meant as proto/clib header file - it even includes pragmas for SAS/C inline calls. You can try copying it into your clib directory and rename it to RegExp_protos.h. Then use it with the clib option from the "special 70" fd2pragma call. fd2pragma needs these proto types to generate valid inline functions with matching types. EDIT: If you don't care about optimized library calls, just delete the #include <inline/RegExp_protos.h>from your proto-header and you're done. Last edited by phx; 29 October 2021 at 19:15. |
|||
08 November 2021, 18:25 | #12 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
Hi phx, I did manage to get it to work by moving the header to the clib directory and then continued the steps from there.
Wanted to thank you for all your help. |
08 November 2021, 22:20 | #13 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
M68K and libraries | rcman | Coders. Asm / Hardware | 3 | 05 February 2020 21:03 |
New / updated XPK libraries | andy2004 | support.Apps | 0 | 16 September 2019 16:55 |
Libraries | Syntrax | support.Other | 6 | 31 March 2019 15:59 |
Missing Libraries | manicx | support.Apps | 3 | 04 June 2003 09:02 |
|
|