jkuhlmann / gainput

Cross-platform C++ input library supporting gamepads, keyboard, mouse, touch
http://gainput.johanneskuhlmann.de/
MIT License
858 stars 103 forks source link

Link time error while using as a library on windows #68

Closed twaritwaikar closed 4 years ago

twaritwaikar commented 4 years ago

I have made my own CMake to compile this project as a library. However some symbols are not being compiled.

My CMakeLists (alongside include/ and source/):

file(GLOB_RECURSE Gainput ./**.cpp)
file(GLOB_RECURSE GainputH ./**.h)

set(ROOTEX_INCLUDES
    ${ROOTEX_INCLUDES}
    ${CMAKE_CURRENT_LIST_DIR}/include/
CACHE INTERNAL "")

add_definitions(-DGAINPUT_BUILD_SHARED=OFF)
add_definitions(-DGAINPUT_BUILD_STATIC=ON)
add_definitions(-DGAINPUT_LIB_BUILD)
add_definitions(-DGAINPUT_PLATFORM_WIN)

add_library(Gainput STATIC ${Gainput} ${GainputH})
set_target_properties(Gainput PROPERTIES LINKER_LANGUAGE CXX)

target_include_directories(Gainput PUBLIC
    ./include/
)

The link errors:

Error   LNK2019 unresolved external symbol XInputGetState referenced in function "public: virtual void __cdecl gainput::InputDevicePadImplWin::Update(class gainput::InputDeltaState *)" (?Update@InputDevicePadImplWin@gainput@@UEAAXPEAVInputDeltaState@2@@Z) Game    D:\CPP Projects\Rootex\build\game\Gainput.lib(GainputInputDevicePad.obj)    1   

Error   LNK2019 unresolved external symbol XInputSetState referenced in function "public: virtual bool __cdecl gainput::InputDevicePadImplWin::Vibrate(float,float)" (?Vibrate@InputDevicePadImplWin@gainput@@UEAA_NMM@Z)   Game    D:\CPP Projects\Rootex\build\game\Gainput.lib(GainputInputDevicePad.obj)    1   
twaritwaikar commented 4 years ago

This is just me not linking Xinput to my project. Closing this issue now...