0
votes

I'm new to cocos2d-x platform and tried to run the tests on Linux(Ubuntu 13.04) environment. I have followed the steps from git-cocos2d-x and got the following error while executing cocos run -p linux command.

/usr/bin/ld: cannot find -lglfw collect2: error: ld returned 1 exit status

Can anybody tell me how to fix this error ?

Any help would be appreciable.

After installation I got the following errors

lib/libcocos2d.a(CCGLView.cpp.o): In function cocos2d::GLView::GLView()': cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:275: undefined reference toglfwSetErrorCallback' lib/libcocos2d.a(CCGLView.cpp.o): In function cocos2d::GLView::initWithRect(std::string const&, cocos2d::Rect, float)': cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:337: undefined reference toglfwWindowHint' cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:343: undefined reference to glfwCreateWindow' cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:344: undefined reference toglfwMakeContextCurrent' cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:347: undefined reference to glfwSetCursorPosCallback' cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:348: undefined reference toglfwSetScrollCallback' cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:351: undefined reference to glfwSetWindowPosCallback' cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:352: undefined reference toglfwSetFramebufferSizeCallback' lib/libcocos2d.a(CCGLView.cpp.o): In function cocos2d::GLView::initWithFullScreen(std::string const&)': cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:381: undefined reference toglfwGetPrimaryMonitor' cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:385: undefined reference to glfwGetVideoMode' lib/libcocos2d.a(CCGLView.cpp.o): In functioncocos2d::GLView::initWithFullscreen(std::string const&, GLFWvidmode const&, GLFWmonitor*)': cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:397: undefined reference to glfwWindowHint' cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:398: undefined reference toglfwWindowHint' cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:399: undefined reference to glfwWindowHint' cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:400: undefined reference toglfwWindowHint' lib/libcocos2d.a(CCGLView.cpp.o): In function cocos2d::GLView::end()': cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:414: undefined reference toglfwSetWindowShouldClose' lib/libcocos2d.a(CCGLView.cpp.o): In function cocos2d::GLView::windowShouldClose()': cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:430: undefined reference toglfwWindowShouldClose' lib/libcocos2d.a(CCGLView.cpp.o): In function cocos2d::GLView::updateFrameSize()': cocos2d-x/NTT-Game/MyGame/cocos2d/cocos/platform/desktop/CCGLView.cpp:489: undefined reference toglfwGetFramebufferSize'

2

2 Answers

2
votes

Do you have libglfw installed on system? Since version 3 of that library the link flag is -lglfw3

0
votes

I had a similar issue when I tried to build a Cocos2d-x project on OpenSuSE. Go to the root directory of your Cocos2d-x project and from there change to the 'cocos2d/cocos' directory. Open up the CMakeLists.txt file and look for the list of PLATFORM_SPECIFIC_LIBS for Linux. You should see a section that looks similar to this:

if(LINUX)
set(PLATFORM_SPECIFIC_LIBS
    pthread
    fontconfig
    GLEW
    X11
    rt
    glfw3
    Xi
    Xrandr
    Xxf86vm
    GL
    ${FMOD_LIB}
    )

In my file I had to change 'glfw' to 'glfw3' and add dependencies on Xi, Xrandr, and Xxf86vm to get the program to build.