I’m trying to set up my project so all of my game code gets compiled into a shared library lightship
, and then two executables (server and client) link it, so server and client specific code is separated.
Here’s how I set up the game library:
include (UrhoCommon)
set (TARGET_NAME lightship)
define_source_files (RECURSE)
setup_library (SHARED)
include_directories ("include")
And here’s how I set up the server executable:
include (UrhoCommon)
set (TARGET_NAME lightship-server)
define_source_files (RECURSE)
setup_main_executable (LIBS lightship)
include_directories ("${CMAKE_SOURCE_DIR}/lightship/include")
The error I’m getting is:
CMakeFiles/lightship-server.dir/src/main.cpp.o: In function `main':
/home/thecomet/documents/programming/cpp/lightship-cpp/server/src/main.cpp:25: undefined reference to `Lightship::Lightship(Urho3D::Context*)'
Here’s my main():
int main(int argc, char** argv)
{
SharedPtr<Context> context(new Context);
SharedPtr<Application> app(new Lightship(context));
return app->Run();
}
And here’s my Lightship class:
class Lightship : public Urho3D::Application
{
public:
enum DebugDrawMode
{
DRAW_NONE = 0,
DRAW_PHYSICS
};
Lightship(Urho3D::Context* context);
virtual void Setup() override;
virtual void Start() override;
virtual void Stop() override;
private:
void RegisterSubsystems();
void RegisterComponents();
void LoadScene();
void CreateCamera();
void CreatePlayer();
void CreateDebugHud();
void HandleKeyDown(Urho3D::StringHash eventType, Urho3D::VariantMap& eventData);
void HandlePostRenderUpdate(Urho3D::StringHash eventType, Urho3D::VariantMap& eventData);
void HandleFileChanged(Urho3D::StringHash eventType, Urho3D::VariantMap& eventData);
DebugDrawMode debugDrawMode_;
Urho3D::SharedPtr<TrackingCamera> trackingCamera_;
Urho3D::SharedPtr<MapState> map_;
Urho3D::SharedPtr<Urho3D::Scene> scene_;
Urho3D::SharedPtr<Urho3D::XMLFile> xmlScene_;
Urho3D::SharedPtr<Urho3D::DebugHud> debugHud_;
};