Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCC cannot find lua headers on Ubuntu #5179

Open
rws-git opened this issue Jun 2, 2024 · 2 comments
Open

GCC cannot find lua headers on Ubuntu #5179

rws-git opened this issue Jun 2, 2024 · 2 comments
Labels

Comments

@rws-git
Copy link

rws-git commented Jun 2, 2024

Xmake Version

v2.8.7+20240401

Operating System Version and Architecture

Ubuntu 24.04 LTS x86_64

Describe Bug

I am trying to compile a simple program inside an Ubuntu Docker container, but the compiler cannot locate Lua header files.
All necessary packages for building are installed inside the container, including lua5.1 and liblua5.1-dev. xmake is installed as instructed on the website. Here is the .Dockerfile contents. If you're not familiar with Docker, it's basically taking latest headless Ubuntu distribution as a base system and runs the commands between ALL_RUN ... ALL_RUN.

# syntax=docker/dockerfile

FROM ubuntu:latest

RUN <<ALL_RUN
add-apt-repository ppa:xmake-io/xmake
apt-get -y --no-install-recommends --no-upgrade update
apt-get -y --no-install-recommends install git ca-certificates build-essential unzip xmake
apt-get -y --no-install-recommends install lua5.1 liblua5.1-dev
apt-get -y clean
groupadd -r developer && useradd -m -g developer developer
ALL_RUN

USER developer

WORKDIR /home/developer

What I end up is a command line version of Ubuntu with xmake, gcc and lua5.1 installed.
Then I try to build this simple program:

#include <lua.hpp>
#include <iostream>

int main(int argc, char* argv[]) {
	std::cout << "Hello world" << std::endl;
	return 0;
}

I've attached the error message as a screenshot. Searching for lua.hpp gives one result in /usr/include/lua5.1/lua.hpp.
So I suspect this has something to do with the header being inside a version folder and that folder is not passed to the compiler as include directory.
Is it an xmake bug where it fails to provide proper include directories? Or is it a known Ubuntu+Lua feature, that requires special treatment? Btw, same thing happens on Debian. Am I doing something wrong here?
I'd appreciate any help.

Expected Behavior

The program is built correctly with xmake -v luatest

Project Configuration

set_xmakever("2.8.6")

add_requires("lua")

target("luatest")
    set_kind("binary")

    add_files("main.cpp")

    add_packages("lua")

Additional Information and Error Logs

Screenshot from 2024-06-02 14-42-56

@rws-git rws-git added the bug label Jun 2, 2024
@waruqi
Copy link
Member

waruqi commented Jun 3, 2024

you can disable system package. add_requires("lua", {system = false})

or open a pr to improve to find lua from system in xmake-repo.

add on_fetch or add_extsources to improve it.

https://github.com/xmake-io/xmake-repo/blob/dev/packages/l/lua/xmake.lua

@rws-git
Copy link
Author

rws-git commented Jun 3, 2024

Hi @waruqi . Thank you for your suggestions.
Disabling system package is not desirable in my case as my goal is to test code compilation using system Lua distributions.

I'd be glad to help improve xmake-repo, but I'd need some time to dive into the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants