Skip to content

Commit

Permalink
Add linux compilation
Browse files Browse the repository at this point in the history
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`).
  • Loading branch information
lets-all-be-stupid-forever committed Sep 16, 2024
1 parent a26ee56 commit 65f97de
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,23 @@ 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
)
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
Expand All @@ -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})
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 65f97de

Please sign in to comment.