Compile error when trying to use ofAppGLFWWindow getGLFWWindow()

Hi everybody,

I am implementing a first person camera, and trying to implement “infinite” mouse moving (to move the camera) with:

ofAppGLFWWindow *winptr = static_cast<ofAppGLFWWindow*>(ofGetWindowPtr());
GLFWwindow *win = winptr->getGLFWWindow();
glfwSetCursorPos(win, win_center_x, win_center_y);

It does not compile because “undefined reference to `ofAppGLFWWindow::getGLFWWindow()’”:
Complete compiler output

HOST_OS=Linux
HOST_ARCH=armv7l
checking pkg-config libraries:   cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libpulse-simple alsa gtk+-3.0 
Compiling OF library for Release
make[1]: Entering directory '/home/pi/of_v0.9.0_linuxarmv7l_release/libs/openFrameworksCompiled/project'
HOST_OS=Linux
HOST_ARCH=armv7l
checking pkg-config libraries:   cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libpulse-simple alsa gtk+-3.0 
HOST_OS=Linux
HOST_ARCH=armv7l
checking pkg-config libraries:   cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libpulse-simple alsa gtk+-3.0 
HOST_OS=Linux
HOST_ARCH=armv7l
checking pkg-config libraries:   cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libpulse-simple alsa gtk+-3.0 
Done!
make[1]: Leaving directory '/home/pi/of_v0.9.0_linuxarmv7l_release/libs/openFrameworksCompiled/project'


Compiling camaraTest for Release
make[1]: Entering directory '/home/pi/of_v0.9.0_linuxarmv7l_release/apps/monitor/camaraTest'
HOST_OS=Linux
HOST_ARCH=armv7l
checking pkg-config libraries:   cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libpulse-simple alsa gtk+-3.0 
Linking bin/camaraTest for linuxarmv7l
g++ -o bin/camaraTest  obj/linuxarmv7l/Release/src/ofApp3.o obj/linuxarmv7l/Release/src/main.o obj/linuxarmv7l/Release/src/ofApp4.o obj/linuxarmv7l/Release/src/firstPersonCamera.o obj/linuxarmv7l/Release/src/ofApp5.o obj/linuxarmv7l/Release/src/ofApp.o  /home/pi/of_v0.9.0_linuxarmv7l_release/libs/openFrameworksCompiled/lib/linuxarmv7l/libopenFrameworks.a   -Wl,-rpath=./libs:./bin/libs -Wl,--as-needed -Wl,--gc-sections -pthread -L/opt/vc/lib /home/pi/of_v0.9.0_linuxarmv7l_release/libs/glfw/lib/linuxarmv7l/libglfw3.a /home/pi/of_v0.9.0_linuxarmv7l_release/libs/kiss/lib/linuxarmv7l/libkiss.a /home/pi/of_v0.9.0_linuxarmv7l_release/libs/tess2/lib/linuxarmv7l/libtess2.a  /home/pi/of_v0.9.0_linuxarmv7l_release/libs/poco/lib/linuxarmv7l/libPocoNetSSL.a /home/pi/of_v0.9.0_linuxarmv7l_release/libs/poco/lib/linuxarmv7l/libPocoNet.a /home/pi/of_v0.9.0_linuxarmv7l_release/libs/poco/lib/linuxarmv7l/libPocoCrypto.a /home/pi/of_v0.9.0_linuxarmv7l_release/libs/poco/lib/linuxarmv7l/libPocoUtil.a /home/pi/of_v0.9.0_linuxarmv7l_release/libs/poco/lib/linuxarmv7l/libPocoJSON.a /home/pi/of_v0.9.0_linuxarmv7l_release/libs/poco/lib/linuxarmv7l/libPocoXML.a /home/pi/of_v0.9.0_linuxarmv7l_release/libs/poco/lib/linuxarmv7l/libPocoFoundation.a  -lz -lgstapp-1.0 -lgstvideo-1.0 -lgstbase-1.0 -lgstreamer-1.0 -ludev -lfreetype -lfontconfig -lsndfile -lopenal -lssl -lcrypto -lpulse-simple -lpulse -lasound -lgtk-3 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0   -lX11 -lXrandr -lXxf86vm -lXi -lXcursor -ldl -lpthread -lfreeimage -lrtaudio -lboost_filesystem -lboost_system -lGLESv2 -lGLESv1_CM -lEGL -lopenmaxil -lbcm_host -lvcos -lvchiq_arm -lpcre -lrt -lX11 -ldl
obj/linuxarmv7l/Release/src/ofApp5.o: In function `ofApp5::keyPressed(int)':
ofApp5.cpp:(.text+0x3c): undefined reference to `ofAppGLFWWindow::getGLFWWindow()'
collect2: error: ld returned 1 exit status
/home/pi/of_v0.9.0_linuxarmv7l_release/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:381: recipe for target 'bin/camaraTest' failed
make[1]: *** [bin/camaraTest] Error 1
make[1]: Leaving directory '/home/pi/of_v0.9.0_linuxarmv7l_release/apps/monitor/camaraTest'
/home/pi/of_v0.9.0_linuxarmv7l_release/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:126: recipe for target 'Release' failed
make: *** [Release] Error 2

This is strange, since i see on of_v0.9.0_linuxarmv7l_release/libs/openFrameworks/app, both files ofAppGLFWWindow.h and ofAppGLFWWindow.cpp, have the function “getGLFWWindow()” and there isn’t any preprocessor directive to avoid include this function.

I am using raspberry pi 2 whit OF version 0.9.0.

Any help would be welcome

the raspberry pi doesn’t use glfw so the library is not included. if you want to get the mouse position just use ofGetMouseX() and ofGetMouseY()

Hi Arturo, thank you for answering

What I am trying to do is to set mouse pointer on screen center, in every frame, so i can move mouse endless and camera would aim to any point in space. If i use ofGetMouseX() ofGetMouseY(), mouse position is limited to window size and camera would rotate with limits, let’s say between -180 and 180 degrees. I do not want this behaviour, I need that camera rotate in any direction any time, with no limitations.

Is there any alternative function to set mouse cursor position, or get endless mouse movement?

You can use the distance between the center of the screen and the mouse pointer for get a speed instead of a distance or angle.

Then at each update you add the speed to the actual position.

You should use a log instead of linear, so the user would have a more precise control over low speed.

Thank you cgiles for your advices, i will try to do it, math is not my strength