question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Undefined symbols for architecture x86_64

See original GitHub issue

For the following code:

#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <stdio.h>

int main() {
    // start GL context and O/S window using the GLFW helper library
    if (!glfwInit()) {
        fprintf(stderr, "ERROR: could not start GLFW3\n");
        return 1;
    }
    // uncomment these lines if on Apple OS X
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    GLFWwindow *window = glfwCreateWindow(640, 480, "Hello Triangle", NULL, NULL);
    if (!window) {
        fprintf(stderr, "ERROR: could not open window with GLFW3\n");
        glfwTerminate();
        return 1;
    }
    glfwMakeContextCurrent(window);
    // start GLEW extension handler
    glewExperimental = GL_TRUE;
    glewInit();
    // get version info
    const GLubyte *renderer = glGetString(GL_RENDERER);
    const GLubyte *version = glGetString(GL_VERSION);
    printf("Renderer: %s\n", renderer);
    printf("OpenGL version supported %s\n", version);
    // tell GL to only draw onto a pixel if the shape is closer to the viewer
    glEnable(GL_DEPTH_TEST); // enable depth-testing
    glDepthFunc(GL_LESS); // depth-testing interprets a smaller value as "closer"
    /* OTHER STUFF GOES HERE NEXT */
    // close GL context and any other GLFW resources
    glfwTerminate();
    return 0;
}

And the following conanfile:

[requires]
glew/2.1.0@bincrafters/stable
glfw/3.3@bincrafters/stable

[generators]
cmake

And following the tutorial for running conan on CLion, when I debug it executes the following command:

"/Users/brianyeh/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/192.7142.39/CLion.app/Contents/bin/cmake/mac/bin/cmake" --build /Users/brianyeh/CLionProjects/glfw_template/cmake-build-debug --target glfw_template -- -j 4

which generates the following error:

Scanning dependencies of target glfw_template
[ 50%] Building CXX object CMakeFiles/glfw_template.dir/main.cpp.o
[100%] Linking CXX executable bin/glfw_template
Undefined symbols for architecture x86_64:
  "_glewExperimental", referenced from:
      _main in main.cpp.o
  "_glewInit", referenced from:
      _main in main.cpp.o
  "_glfwCreateWindow", referenced from:
      _main in main.cpp.o
  "_glfwInit", referenced from:
      _main in main.cpp.o
  "_glfwMakeContextCurrent", referenced from:
      _main in main.cpp.o
  "_glfwTerminate", referenced from:
      _main in main.cpp.o
  "_glfwWindowHint", referenced from:
      _main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [bin/glfw_template] Error 1
make[2]: *** [CMakeFiles/glfw_template.dir/all] Error 2
make[1]: *** [CMakeFiles/glfw_template.dir/rule] Error 2
make: *** [glfw_template] Error 2

Am I doing something wrong or is this an issue with conan or the libraries? Also I’m running this on OSX.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Minimoniumcommented, Mar 8, 2020

It’s a linking issue, profile seems alright. Have you tried the https://github.com/lasote/clion-conan-consumer? I also noticed that the tutorial doesn’t mention this line: https://github.com/lasote/clion-conan-consumer/blob/master/CMakeLists.txt#L13 Please make sure you have it in your CMakeLists.

0reactions
jgsogocommented, Mar 9, 2020

Thanks a lot, @Minimonium, for attending this issue ❤️

I think it’s been resolved, but feel free to open it again if needed.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

c++ - Undefined Symbols for architecture x86_64: Compiling ...
There's no mystery here, the linker is telling you that you haven't defined the missing symbols, and you haven't.
Read more >
Undefined symbols for architecture x86_64 - Apple Developer
I'm trying to create an application that sends keystrokes to another process and I keep getting this error: Undefined symbols for architecture x86_64:....
Read more >
[C++] Undefined symbols for architecture x86_64 - Reddit
The error "undefined reference to symbol" means that you declared something but didn't define it. For example, you provided a function prototype ...
Read more >
How To Fix It: Undefined Symbols for Architecture X86_64:
The undefined symbols for architecture x86_64: can be easily fixed by defining a value inside the missing declared statements. This is a common...
Read more >
Undefined symbols for architecture x86_64: #4238 - GitHub
Bug report Summary After installation when I run the iOS project from xcode, it gives following error Undefined symbols for architecture ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found