@paule32:
There is no gentle way to say this (I have seen your repository).
- Please learn about the difference between static linking, dynamic linking and dynamic loading. You current implementation uses all 3 (and only 1 is valid at a time). Just pick one and stick to it (if only for the time being or as a new example project).
- start a new project (if only for testing) and use a single library header unit.
- get rid of the windows unit, there is no need for it.
for example you can read up on different linking vs loading
here and
here.
Have for example a look
here on the wiki and don't miss out on the link to the (externally linked) tutorial (it links to a Github repo that has a PDF with several examples/instructions).
I am aware that the above instructions mentioned still do not tell anything specific about dynamic loading with Pascal but for that have a look at the package directory of the FPC source-tree where you can find examples of well known (c-)libraries and their pascal bindings (that sometimes uses dynamic loading).
A small example of loading a library can be found in the documentation
here@aruna , the following is not meant to criticize your constructive answers but to illustrate to TS what is wrong.
Linker Warnings and Errors:[/b][/i]
/usr/bin/ld.bfd: warning: link.res contains output sections; did you forget -T?
/usr/bin/ld.bfd: cannot find -lfpc-qt.dll
/usr/bin/ld.bfd: cannot find -lfpc-qt
link.res contains output sections; did you forget -T?: This warning suggests that the linker found some sections in the link.res file that might need specific handling, potentially requiring the -T option for custom linker scripts.
You might not know this but it is compiler related. The FPC compiler used has this issue and the only 2 ways to get rid of it is a) to upgrade the compiler version or b) downgrade the (external) linker.
cannot find -lfpc-qt.dll:
The linker cannot find the library fpc-qt.dll. Note that .dll files are typically used on Windows, not Linux. This suggests that the project may be configured for Windows but is being compiled on Linux. (Which it is!)
cannot find -lfpc-qt: The linker also cannot find the fpc-qt library. This could be due to a missing library file or incorrect path settings.
Ensure that the fpc-qt library is available and correctly installed on your system. If it's a Windows-specific library, you may need to adjust your project settings for Linux or use the appropriate library for Linux.
Note that the presented code explicitly declares a library name with dll in it, as well as the loadlibrary routine that explicitly loads a dll (thereby mixing two different approaches).
Besides that, on linux machine when you link the library you either need to supply the correct compiler option(s) (or compiler directives) or set the ld_library path correctly (or install the library system wide).
@paule32: This reply is not meant to discourage you in any way but to show that you got a lot of things mixed up and that is catching up with you.