premake-core icon indicating copy to clipboard operation
premake-core copied to clipboard

Linking ".a" archive file is unsupported.

Open tmathews opened this issue 1 year ago • 2 comments

What seems to be the problem? Using the links method to include an .a archive file incorrectly supplements the library with a flag instead of just providing the library path. The archive file will be prefixed with -l and the relative path to the file is omitted. e.g. -llibrary.a instead of my/custom/library.a.

What did you expect to happen? I expect the LIBS make variable to be supplemented with the archive file path. e.g. LIBS=... my/custom/library.a.

What have you tried so far? Researching docs for alternative methods. None tried provided the required outcome. Manually adding the archive path to the LIBS variable in the make file successfully statically links.

How can we reproduce this? Use the link method like so:

links({"./my/custom/library.a"})
  • [x] GNU Makefile 2 (gmake2)

What version of Premake are you using? 5.0.0-beta2

tmathews avatar Jun 20 '24 17:06 tmathews

BTW, why using links { "my/custom/library.a" } instead of

links { "rary" } -- without 'lib' prefix ;-)
libdirs { "my/custom" }

?

Jarod42 avatar Jun 21 '24 15:06 Jarod42

Because this will produce the incorrect Make file configuration. As stated, it will produce -lrary flags instead of directly linking the archive file.

Additionally putting the .a file in the files list gets ignored too.

tmathews avatar Jun 21 '24 16:06 tmathews

If you run into this kind of issue you can override the generator to resolve it. Ideally Premake should not be performing any kind of magic, but that's my opinion. Ran into the same issue with VS generator and using ".a" files where ".lib" is appended.

Closing this as it is easy to override. Read the documentation for further details.

tmathews avatar Feb 04 '25 22:02 tmathews