reference to `glfw...' undefined
Closed this issue · 9 comments
Hi, when I compile my project using the last version of mc_mujoco it doesn't find reference to several glfw files.
(mc_mujoco compile and install fine)
I will appreciate if you can give me some ideas.
Thanks
[ 0%] Built target run_function
[ 25%] Linking CXX executable test
/usr/bin/ld: /usr/local/lib/libmc_mujoco_lib.a(mj_sim.cpp.o): in the function `mc_mujoco::MjSimImpl::updateScene()':
/home/nk/mc_mujoco/src/mj_sim.cpp:837: reference to `glfwPollEvents' undefined
/usr/bin/ld: /usr/local/lib/libmc_mujoco_lib.a(mj_sim.cpp.o): in the function `mc_mujoco::MjSimImpl::render()':
/home/nk/mc_mujoco/src/mj_sim.cpp:948: reference to undefined `glfwSwapBuffers'
/usr/bin/ld: /home/nk/mc_mujoco/src/mj_sim.cpp:950: reference to `glfwWindowShouldClose' undefined
/usr/bin/ld: /usr/local/lib/libmc_mujoco_lib.a(mj_utils.cpp.o): in the function `mc_mujoco::mujoco_cleanup(mc_mujoco::MjSimImpl*)':
/home/nk/mc_mujoco/src/mj_utils.cpp:456: reference to `glfwDestroyWindow' undefined
/usr/bin/ld: /usr/local/lib/libmc_mujoco_lib.a(mj_utils.cpp.o): in the function `mc_mujoco::mujoco_create_window(mc_mujoco::MjSimImpl*)':
/home/nk/mc_mujoco/src/mj_utils.cpp:310: reference to `glfwInit' undefined
/usr/bin/ld: /home/nk/mc_mujoco/src/mj_utils.cpp:318: reference to `glfwCreateWindow' undefined
/usr/bin/ld: /home/nk/mc_mujoco/src/mj_utils.cpp:323: reference to `glfwMakeContextCurrent' undefined
/usr/bin/ld: /home/nk/mc_mujoco/src/mj_utils.cpp:324: reference to `glfwSwapInterval' undefined
/usr/bin/ld: /home/nk/mc_mujoco/src/mj_utils.cpp:325: reference to `glfwSetWindowUserPointer' undefined
/usr/bin/ld: /home/nk/mc_mujoco/src/mj_utils.cpp:399: reference to `glfwWindowHint' undefined
/usr/bin/ld: /home/nk/mc_mujoco/src/mj_utils.cpp:400: reference to `glfwWindowHint' undefined
/usr/bin/ld: /usr/local/lib/libmc_mujoco_lib.a(mj_utils.cpp.o): in the function `mc_mujoco::uiLayout(mjuiState_*)':
/home/nk/mc_mujoco/src/mj_utils.cpp:48: reference to `glfwGetFramebufferSize' undefined
/usr/bin/ld: /usr/local/lib/libmc_mujoco_lib.a(MujocoClient.cpp.o): in the function `mc_mujoco::MujocoClient::draw2D(GLFWwindow*)':
/home/nk/mc_mujoco/src/MujocoClient.cpp:78: reference to `glfwGetWindowSize' undefined
/usr/bin/ld: /usr/local/lib/libmc_mujoco_lib.a(glfw_dispatch.cc.o): in the function `mujoco::Glfw(void*)':
/home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:82: reference to `glfwCreateWindow' undefined
/usr/bin/ld: /usr/local/lib/libmc_mujoco_lib.a(glfw_dispatch.cc.o): in the `operator()' function:
/home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:83: reference to undefined `glfwDestroyWindow'
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:84: reference to `glfwGetCursorPos' undefined
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:85: reference to undefined `glfwGetFramebufferSize'
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:86: reference to `glfwGetKey' undefined
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:87: reference to undefined `glfwGetMonitorPhysicalSize'
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:88: reference to `glfwGetMouseButton' undefined
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:89: reference to undefined `glfwGetPrimaryMonitor'
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:90: reference to undefined `glfwGetTime'
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:91: reference to `glfwGetVideoMode' undefined
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:92: reference to undefined `glfwGetWindowMonitor'
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:93: reference to undefined `glfwGetWindowPos'
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:94: reference to undefined `glfwGetWindowSize'
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:95: reference to `glfwGetWindowUserPointer' undefined
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:96: reference to `glfwInit' undefined
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:97: reference to undefined `glfwMakeContextCurrent'
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:98: reference to undefined `glfwPollEvents'
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:99: reference to `glfwSetClipboardString' undefined
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:100: reference to undefined `glfwSetCursorPosCallback'
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:101: reference to undefined `glfwSetDropCallback'
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:102: reference to undefined `glfwSetKeyCallback'
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:103: reference to undefined `glfwSetMouseButtonCallback'
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:104: reference to undefined `glfwSetScrollCallback'
/usr/bin/ld: /home/nk/.mujoco/mujoco231/simulate/glfw_dispatch.cc:105: reference to undefined `glfwSetWindowMonitor'
.
.
.
/home/nk/mc_mujoco/ext/imgui/backends/imgui_impl_glfw.cpp:505: reference to `glfwDestroyCursor' undefined
/usr/bin/ld: /usr/local/lib/libmc_mujoco_lib.a(imgui_impl_glfw.cpp.o): in the function `ImGui_ImplGlfw_NewFrame()':
/home/nk/mc_mujoco/ext/imgui/backends/imgui_impl_glfw.cpp:623: reference to `glfwGetWindowSize' undefined
/usr/bin/ld: /home/nk/mc_mujoco/ext/imgui/backends/imgui_impl_glfw.cpp:624: reference to `glfwGetFramebufferSize' undefined
/usr/bin/ld: /home/nk/mc_mujoco/ext/imgui/backends/imgui_impl_glfw.cpp:630: reference to `glfwGetTime' undefined
/usr/bin/ld: /home/nk/mc_mujoco/ext/imgui/backends/imgui_impl_glfw.cpp:520: reference to undefined `glfwGetWindowAttrib'
/usr/bin/ld: /home/nk/mc_mujoco/ext/imgui/backends/imgui_impl_glfw.cpp:543: reference to `glfwGetInputMode' undefined
/usr/bin/ld: /usr/local/lib/libmc_mujoco_lib.a(imgui_impl_glfw.cpp.o): in function `ImGui_ImplGlfw_UpdateMouseCursor':
/home/nk/mc_mujoco/ext/imgui/backends/imgui_impl_glfw.cpp:556: reference to `glfwSetCursor' undefined
/usr/bin/ld: /home/nk/mc_mujoco/ext/imgui/backends/imgui_impl_glfw.cpp:557: reference to `glfwSetInputMode' undefined
/usr/bin/ld: /usr/local/lib/libmc_mujoco_lib.a(imgui_impl_glfw.cpp.o): in the function `ImGui_ImplGlfw_NewFrame()':
/home/nk/mc_mujoco/ext/imgui/backends/imgui_impl_glfw.cpp:572: reference to `glfwGetGamepadState' undefined
/usr/bin/ld: /usr/local/lib/libmc_mujoco_lib.a(imgui_impl_glfw.cpp.o): in function `ImGui_ImplGlfw_UpdateMouseData':
/home/nk/mc_mujoco/ext/imgui/backends/imgui_impl_glfw.cpp:526: reference to `glfwSetCursorPos' undefined
/usr/bin/ld: /usr/local/lib/libmc_mujoco_lib.a(imgui_impl_glfw.cpp.o): in function `ImGui_ImplGlfw_UpdateMouseCursor':
/home/nk/mc_mujoco/ext/imgui/backends/imgui_impl_glfw.cpp:550: reference to `glfwSetInputMode' undefined
/usr/bin/ld: /usr/local/lib/libmc_mujoco_lib.a(imgui_impl_glfw.cpp.o): in function `ImGui_ImplGlfw_UpdateMouseData':
/home/nk/mc_mujoco/ext/imgui/backends/imgui_impl_glfw.cpp:532: reference to `glfwGetCursorPos' undefined
/usr/bin/ld: /usr/local/lib/libmc_mujoco_lib.a(imgui_impl_glfw.cpp.o): in the function `ImGui_ImplGlfw_GetClipboardText(void*)':
/home/nk/mc_mujoco/ext/imgui/backends/imgui_impl_glfw.cpp:126: reference to `glfwGetClipboardString' undefined
/usr/bin/ld: /usr/local/lib/libmc_mujoco_lib.a(imgui_impl_glfw.cpp.o): in the function `ImGui_ImplGlfw_SetClipboardText(void*, char const*)':
/home/nk/mc_mujoco/ext/imgui/backends/imgui_impl_glfw.cpp:131: reference to `glfwSetClipboardString' undefined
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/test.dir/build.make:138: test] Error 1
make[1]: *** [CMakeFiles/Makefile2:113: CMakeFiles/test.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
Hi Nick,
Sorry I couldn't understand, what do you mean by:
(mc_mujoco compile and install fine)
Not give me error in the mc_mujoco/build folder when:
make && sudo make install
But in the build of my project I got the glfw undefine reference.
I don't know what your project is or how it is related to mc_mujoco
😄
My guess would be that your cmake project can't find the path to the libglfw
library.
@rohanpsingh my project use reinforcement learning so I use mc_mujoco for the training and testing phase.
My project not use glfw but how use mc_mujoco I guess when compile it mc_mujoco not find the references.
I have installed GLFW
sudo apt-get update
sudo apt-get install libglfw3
sudo apt-get install libglfw3-dev
I tried to add in the CMakeList.txt of my project the find_package
and target_link_libraries
of GLFW.
I tried too copy the GLFW folder of ext
in mc_mujoco to my project and I add add_subdirectory(ext/glfw)
in my CMakeList.txt
I tried too put BUILD_SHARED_LIBS ON
in mc_mujoco but in all cases I got the same error.
In my project I reference mc_mujoco as follows:
CMakeList.txt
find_package(mc_mujoco REQUIRED)
target_link_libraries(run_function PUBLIC mc_mujoco::mc_mujoco)
I will appreciate your comments, thanks in advance.
Are you able to build mc_mujoco
separately? Do a fresh clone of mc_mujoco
and please try to build it.
yes, I can build mc_mujoco
separately.
can you try to add any project in your CMakeList.txt
and compile it?:
find_package(mc_mujoco REQUIRED)
target_link_libraries(run_function PUBLIC mc_mujoco::mc_mujoco)
yes, I can build mc_mujoco separately.
This means the problem is most probably not related to mc_mujoco
. To be sure, I think you can checkout to an older version of mc_mujoco
where things were working for you.
find_package(mc_mujoco REQUIRED) target_link_libraries(run_function PUBLIC mc_mujoco::mc_mujoco)
These two lines are probably not the cause of problems in your case.
Ah... so it was indeed a issue in mc-mujoco. Sorry about that! 😄