hi everyone, im trying to add new stuff to game but struggling with some topics:
added these to end of the makefile
CXX ?= g++
TARGETS := $(B)/haptics/libhaptics.a $(TARGETS)
CLIENT_LIBS := $(CLIENT_LIBS) -L$(MOUNT_DIR)/haptics/dhd/lib -L$(B)/haptics \
-ldhd -lpthread -lusb-1.0 -lrt \
-lGL -lGLU -lglut \
-lm -lstdc++ -lhaptics
$(B)/haptics/%.o: $(MOUNT_DIR)/haptics/%.cpp
-mkdir -p $(B)/haptics
$(CXX) -g -fPIC -DLINUX -I$(MOUNT_DIR)/haptics/dhd/include -I$(MOUNT_DIR)/haptics -o $@ -c $<
$(B)/haptics/%.a: $(B)/haptics/haptics.o
ar rcs $@ $<
i created folder inside code named âhapticsâ and i put 2 files 1 directory there:
- haptics.cpp
- haptics.h
- dhd/
- include/
- dhdc.h
- lib/
- libdhd.a
- include/
the dhd folder is the linux x64 library i got from forcedimension website
( http://www.forcedimension.com/download/sdk )
under âOther Releasesâ Haptics SDK, dhd-3.2.2, i renamed out folder as dhd and put it in code/haptics/
when i compile i see build/release-linux-x86_64/haptics/libhaptics.a there and when i run âar tâ on archive i see haptics.o inside
*I CAN SUCCESSFULLY COMPILE BUT FAIL WHEN LINKING CLIENTBIN AKA IOQUAKE3.$(ARCH)
btw i have these codes:
haptics.h:
#ifndef _HAPTICS_H_
#define _HAPTICS_H_
void haptics_init(void);
#endif
haptics.cpp:
#include <dhdc.h>
#include "haptics.h"
void haptics_init() {
if(dhdOpen() < 0)
return;
dhdWaitForReset(); // blocking function
return;
}
and in code/sdl/sdl_input.c
i added â#include ââŚ/haptics/haptics.hââ after normal inclusions (line 35)
and added haptics_init(); to end of the IN_Init() function (line ~970) after dash print
i cannot pass linking stage due to error:
build/release-linux-x86_64/client/sdl_input.o: In function `IN_Init':
code/sdl/sdl_input.c:(.text+0xfbb): undefined reference to `haptics_init'
what should i do to pass linking stage?