DucktapeEngine / Ducktape

Ducktape - An open source 3d C++ game engine.
MIT License
127 stars 25 forks source link

Improvements to building on Linux #132

Closed cappe987 closed 2 years ago

cappe987 commented 2 years ago

I wanted to build this on Linux, but there were many problems with linking. I fixed some but not all. In the end I get stuck with a compiler error. But it's still some steps forward to before. Please try this on Windows as well to make sure I have not broken anything.

I also had to build and install assimp and glfw on my system because I couldn't get them to link.

Here's the error I get stuck on. I don't know C++ so I have no idea how to solve it.

Ducktape/Resources/Scripts/PlayerController.cpp:76:22: error: expected constructor, destructor, or type conversion before ‘(’ token
   76 | extern "C" __declspec(dllexport) Component *AssignPlayerController(Entity entity)
aryanbaburajan commented 2 years ago

@cappe987 Awesome! A few things: 1) Linking on Linux indeed sounds like a pain (thus I switched to Windows 😅). Ducktape could force the users to install the libraries themselves through apt or any similar package manager (like you did), avoiding most linker issues. So could you edit the CMake file (the one at the root of the entire repo) to skip add_subdirectory() compilation on Linux?

2) And as for the compiler error you encountered, I figured it had something to do with __declspec(dllexport) not working on Linux. Which seems to be correct, as per this stackoverflow answer. So could you try using the Linux alternative instead? Also it'd be great if you could replace that part of the code with a macro which would be something like:

#ifdef _WIN32
#define DT_EXPORT extern "C" __declspec(dllexport)
#endif
#ifdef __linux__
#define DT_EXPORT extern "C" __attribute__((visibility("default")))
#endif

(Note that the above code is untested.)

aryanbaburajan commented 2 years ago

Follow up: And if possible, please do also add the appropriate apt install commands for each library in the linux build script.