Fix cocos2d-x 3.0 linux build script

when you compile a project created by project-creator under linux, you will get this error
lib/libcocos2d.a(CCEGLView.cpp.o): In function `cocos2d::EGLView::EGLView()': /home/jarod/workspace/game/vchat/cocos2d/cocos/2d/platform/linux/CCEGLView.cpp:315: undefined reference to `glfwSetErrorCallback' lib/libcocos2d.a(CCEGLView.cpp.o): In function `cocos2d::EGLView::init(char const*, float, float, float)': /home/jarod/workspace/game/vchat/cocos2d/cocos/2d/platform/linux/CCEGLView.cpp:333: undefined reference to `glfwWindowHint' /home/jarod/workspace/game/vchat/cocos2d/cocos/2d/platform/linux/CCEGLView.cpp:334: undefined reference to `glfwCreateWindow' /home/jarod/workspace/game/vchat/cocos2d/cocos/2d/platform/linux/CCEGLView.cpp:335: undefined reference to `glfwMakeContextCurrent' /home/jarod/workspace/game/vchat/cocos2d/cocos/2d/platform/linux/CCEGLView.cpp:337: undefined reference to `glfwGetFramebufferSize' /home/jarod/workspace/game/vchat/cocos2d/cocos/2d/platform/linux/CCEGLView.cpp:340: undefined reference to `glfwSetCursorPosCallback' /home/jarod/workspace/game/vchat/cocos2d/cocos/2d/platform/linux/CCEGLView.cpp:341: undefined reference to `glfwSetScrollCallback' /home/jarod/workspace/game/vchat/cocos2d/cocos/2d/platform/linux/CCEGLView.cpp:344: undefined reference to `glfwSetWindowPosCallback' lib/libcocos2d.a(CCEGLView.cpp.o): In function `cocos2d::EGLView::end()': /home/jarod/workspace/game/vchat/cocos2d/cocos/2d/platform/linux/CCEGLView.cpp:405: undefined reference to `glfwSetWindowShouldClose' lib/libcocos2d.a(CCEGLView.cpp.o): In function `cocos2d::EGLView::windowShouldClose()': /home/jarod/workspace/game/vchat/cocos2d/cocos/2d/platform/linux/CCEGLView.cpp:417: undefined reference to `glfwWindowShouldClose' collect2: error: ld returned 1 exit status make[2]: *** [bin/vchat] Error 1 make[1]: *** [CMakeFiles/vchat.dir/all] Error 2 make: *** [all] Error 2

work around:

--- a/cocos/2d/CMakeLists.txt
+++ b/cocos/2d/CMakeLists.txt
@@ -196,6 +196,8 @@ endif()
 elseif(APPLE)

 else()
+find_package(PkgConfig REQUIRED)
+pkg_search_module(GLFW REQUIRED glfw3)
 set(COCOS_LINK
   jpeg
   webp
@@ -204,7 +206,7 @@ set(COCOS_LINK
   fontconfig
   png
   pthread
-  glfw
+  ${GLFW_STATIC_LIBRARIES}
   GLEW
   GL
   X11

platform:
ubuntu 14.04 and gflw3 build from source

Have you submitted a pull request or issue? I’m having the same issues on Linux Mint 16, gcc 4.8.1. Even after running the Linux dependency installation script.

Edit: Submitted an issue with a link to this thread. :slight_smile:

Hello guys,
I think I’ve found the same problem, but I solved it in the end.
I’m using Ubuntu 14.04, which libglfw2 was installed automatically.
So I uninstall it first, just typing “sudo apt-get purge libglfw2”
and then execute the script “cocos2d-x-3.3/tools/travis-scripts/install_glfw.sh” and after that, I can build my “hello project” properly.
Hope this idea can help you.
Love Linux, Love cocos

@ffpwserver Thanks! It is due to the original libglfw.