From 65f97de2ac9bf8cddd9afc987c1faff593b985ea Mon Sep 17 00:00:00 2001 From: lets_all_be_stupid_forever Date: Mon, 16 Sep 2024 10:26:49 +0200 Subject: [PATCH] Add linux compilation Can now compile in linux. Still need to put a symbolic link to luajit libs and a LD_LIBRARY_PATH to the current executable directory so it can find libraylib.so (as in `LD_LIBRARY_PATH=$PWD ./ca`). --- CMakeLists.txt | 12 +++++++++++- README.md | 8 ++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c51ad8f..547f837 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,12 @@ IF (WIN32) third_party/clip/clip_win_wic.cpp third_party/clip/clip_win_bmp.cpp ) +ELSEIF (UNIX) + ADD_COMPILE_DEFINITIONS(-DHAVE_XCB_XLIB_H=1) + SET(clip_libs xcb pthread) + SET(ca_src ${ca_src} + third_party/clip/clip_x11.cpp + ) ELSEIF (APPLE) SET(ca_src ${ca_src} third_party/clip/clip_osx.mm @@ -103,6 +109,10 @@ ELSEIF (APPLE) ENDIF() add_executable(ca ${ca_src}) +IF (UNIX) + # Need this command so luajit can access the C API from ffi + SET_PROPERTY(TARGET ca PROPERTY ENABLE_EXPORTS ON) +ENDIF() target_include_directories(ca PRIVATE src @@ -123,4 +133,4 @@ ENDIF() IF (OPENMP) SET(openmp_lib OpenMP::OpenMP_C) ENDIF () -target_link_libraries(ca raylib ${shlwapi_lib} nfd ${openmp_lib} ${luajit_lib}) +target_link_libraries(ca raylib ${shlwapi_lib} nfd ${openmp_lib} ${luajit_lib} ${clip_libs}) diff --git a/README.md b/README.md index 834886d..b94ac28 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,14 @@ Made with [raylib](https://www.raylib.com/). ## Building -Compiles in Windows. +Compiles in Windows, Linux and Mac. - Need to build within the `build/` directory (or something within the root directory so it can access `luasrc/` and `asset/` folder) -- Need to download and build [luajit](https://luajit.org/download.html) locally in the folder `LuaJIT`, so that `LuaJIT/src/`, `LuaJIT/src/lua51.dll` and `LuaJIT/src/luajit.lib` are there. +- You need to compile `LuaJIT/`. You can see the instructions [here](https://luajit.org/install.html). The binaries will go to the `LuaJIT/src` folder. In MAC it seems you need to install it too. In linux I've managed to make it work with a symbolic link from `build/`. In Windows it worked directly with the cmake directives ( if it doesnt for you mind that it might be something related to link path). +- In linux it might complain that it can't find `libraylib.so`, that's because linux won't look for libraries in the directory it is in, you can fix with it `LD_LIBRARY_PATH=$PWD ./ca` until we find a cleaner solution. +- By default OPENMP is off, you might want to activate in the `OPENMP` cmake option. + +The Linux and MAC versions are not stable yet: they compile but have some divergences from windows version. ## License