aardappel / lobster

The Lobster Programming Language

Home Page:http://strlen.com/lobster

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Help with compiling to binaries

eboatwright opened this issue · comments

So, I'm trying to compile some of the example projects to Linux and Windows (WebAssembly would be nice too, but I'm starting simple(-ish)). So, I look around the website and find the compiling page. I try the --pak, and it makes this lpak file. What is that? So, then I tried the --cpp option, and it makes the cpp file. But, I try to compile it (with gcc compiled_lobster.cpp) and I get this error:

src/compiled_lobster.cpp:1:10: fatal error: lobster/stdafx.h: No such file or directory
    1 | #include "lobster/stdafx.h"
      |          ^~~~~~~~~~~~~~~~~~

So, I copy the file into that folder, and I get another error asking for another file, and another, and another, and after a while it starts asking for files that don't even exist, for files inside folders, that also need that same file in an infinite recursion directory spiral into the infinity of nothingness. Sorry, I got on a little tangent, but you get the point

Also, I'm on Pop! OS 21.04 an Ubuntu based distro.

P.S. I know I'm probably using the wrong C++ compiler or something, but I don't know much about C++ so :/

If you just want to run stuff, you shouldn't need either option, since Lobster contains a JIT, just run programs like on https://aardappel.github.io/lobster/getting_started.html: bin/lobster samples/pythtree.lobster.

--cpp is for making a binary with the c++ you should only need if you're shipping to customers. The error you're getting is because you can't compile that file by itself, it needs all of the rest of Lobster compiled into it, so you need to build it thru CMake, see instuctions on https://aardappel.github.io/lobster/implementation.html, in particular under Compiling Lobster code to C++.

Yeah, I tried to read those docs, but for some reason my brain skipped over the part where it said to be in the dev directory :( sorry, So I got compiling to Linux working, how would I go about cross compiling to Windows?

I've never cross-compiled to Windows, so I have no idea. I use an actual Windows to build (with Visual Studio).

Lobster build depends on graphics/sound/opengl and what not, so would need Windows system headers etc, so I bet a cross-compile is not that easy.

oh, ok. Thank you for your time, and help :)

Maybe using the Zig toolchain could help out? I've heard multiple people say that they don't even write in Zig itself but still use it to cross-compile stuff because it simplifies a lot of the headaches involved:

https://zig.news/kristoff/cross-compile-a-c-c-project-with-zig-3599

Hm, I'll look into that! I don't really like the Zig programming language, but I might be able to write a few build scripts with it :) Thanks!

@JobLeonard yeah the zig toolchain is really cool.. had thoughts at some point to include it in Lobster such that the Lobster compiler can uniformly build on all platforms in --cpp mode.