lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Compilation fails on Fedora 36

Open dov opened this issue 3 years ago • 8 comments

Trying to compile the lua-language-server plugin on Linux fails with the error:

/usr/bin/ld: cannot find -lstdc++

The cause seems to be the assumption that you can link with gcc and add -lstdc++ for C++ support. This is not the recommended way to link a g++ program. The recommended way is to use g++ as an executable for the linking.

I don't know anything about the luamake program so I don't know if this is a bug in lua-language-server or in one of its dependencies in the build tool chain.

dov avatar Aug 21 '22 11:08 dov

duplicate #642

actboy168 avatar Aug 22 '22 01:08 actboy168

@actboy168 Thanks. But even though #642 provides a workaround, I still think it is valid to fix the underlying bug that the lua language server is using gcc for linking instead of g++.

dov avatar Aug 22 '22 14:08 dov

I do not think so. But you can use whatever solution you think is correct, as long as it solves your problem. Any pull requests are also welcome.

actboy168 avatar Aug 23 '22 01:08 actboy168

@actboy168 Unfortunately, my current solution is not working very well, and I tried to understand what to change in luamake to make it use g++ instead of gcc for linking, but unfortunately I got lost. How can I define what c-compiler I want to use for compilation and linking? What if I want to use clang++? Would that require creating a scripts/compiler/clang.lua file? And afterwards, how do I choose what "compiler" to use when running "luamake"?

Thanks!

dov avatar Aug 23 '22 08:08 dov

luamake --cc g++ luamake --cc clang luamake --cc clang++

actboy168 avatar Aug 23 '22 08:08 actboy168

Thanks! That should solve it. Just for completeness, is there a way of changing the linker command as well? E.g. in the case you have a mixed C and C++ project and you want to compile the C-files with gcc and the C++ files with g++ and link with g++?

dov avatar Aug 24 '22 06:08 dov

No, I don't think it makes sense. You should first understand the difference between g++ and gcc..

actboy168 avatar Aug 24 '22 06:08 actboy168

Ok. I guess you are right. I just realized that g++ is using a c-compiler for files with the .c extension.

dov avatar Aug 24 '22 06:08 dov