1

UPDATE I've found the answer and posted it in the comments. I'm pretty annoyed this was closed as a duplicate though. What I was asking isn't the same as the duplicate it was marked as.
________________________________________

So I'm trying to build some OpenGL examples from the command line in windows.

I am able to do this in Visual Studio. I want to do it from the command line.

I've been following the tutorial here on learnopengl.com. I've installed cmake, and built 32-bit libs of GLFW and GLEW.

When I open the Developer Command Prompt for VS2015 I enter the following to compile my program.

cl /EHsc /IC:\Users\Kojo\dev\cpp-include hello_window.cpp /link User32.lib OpenGL32.lib C:\Users\Kojo\dev\cpp-libs\glew32s.lib C:\Users\Kojo\dev\cpp-libs\glfw3-32.lib Gdi32.lib Shell32.lib

This is the program

I get the following output

C:\Users\Kojo\dev\LearnOpenGL>cl /EHsc /IC:\Users\Kojo\dev\cpp-include hello_window.cpp /link User32.lib OpenGL32.lib C:\Users\Kojo\dev\cpp-libs\glew32s.lib C:\Users\Kojo\dev\cpp-libs\glfw3.lib Gdi32.lib Shell32.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

hello_window.cpp
Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:hello_window.exe
User32.lib
OpenGL32.lib
C:\Users\Kojo\dev\cpp-libs\glew32s.lib
C:\Users\Kojo\dev\cpp-libs\glfw3.lib
Gdi32.lib
Shell32.lib
hello_window.obj
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
glfw3.lib(init.obj) : warning LNK4217: locally defined symbol ___stdio_common_vsprintf imported in function _vsnprintf
glfw3.lib(wgl_context.obj) : warning LNK4049: locally defined symbol _calloc imported
glfw3.lib(egl_context.obj) : warning LNK4049: locally defined symbol _calloc imported
glfw3.lib(monitor.obj) : warning LNK4049: locally defined symbol _calloc imported
glfw3.lib(vulkan.obj) : warning LNK4049: locally defined symbol _calloc imported
glfw3.lib(win32_window.obj) : warning LNK4217: locally defined symbol _calloc imported in function __glfwPlatformGetClipboardString
glfw3.lib(win32_joystick.obj) : warning LNK4049: locally defined symbol _calloc imported
glfw3.lib(window.obj) : warning LNK4217: locally defined symbol _calloc imported in function _glfwCreateWindow
glfw3.lib(input.obj) : warning LNK4217: locally defined symbol _calloc imported in function _glfwSetTime
glfw3.lib(win32_init.obj) : warning LNK4049: locally defined symbol _calloc imported
glfw3.lib(win32_monitor.obj) : warning LNK4049: locally defined symbol _calloc imported
glfw3.lib(wgl_context.obj) : warning LNK4049: locally defined symbol _free imported
glfw3.lib(egl_context.obj) : warning LNK4049: locally defined symbol _free imported
glfw3.lib(monitor.obj) : warning LNK4049: locally defined symbol _free imported
glfw3.lib(vulkan.obj) : warning LNK4049: locally defined symbol _free imported
glfw3.lib(win32_window.obj) : warning LNK4217: locally defined symbol _free imported in function _acquireMonitor
glfw3.lib(win32_joystick.obj) : warning LNK4049: locally defined symbol _free imported
glfw3.lib(window.obj) : warning LNK4217: locally defined symbol _free imported in function _glfwDestroyWindow
glfw3.lib(input.obj) : warning LNK4217: locally defined symbol _free imported in function _glfwGetTime
glfw3.lib(win32_init.obj) : warning LNK4049: locally defined symbol _free imported
glfw3.lib(win32_monitor.obj) : warning LNK4049: locally defined symbol _free imported
glfw3.lib(monitor.obj) : warning LNK4217: locally defined symbol _qsort imported in function _refreshVideoModes
glfw3.lib(win32_joystick.obj) : warning LNK4049: locally defined symbol _qsort imported
glfw3.lib(vulkan.obj) : error LNK2001: unresolved external symbol __imp___wassert
glfw3.lib(wgl_context.obj) : error LNK2001: unresolved external symbol __imp___wassert
glfw3.lib(egl_context.obj) : error LNK2001: unresolved external symbol __imp___wassert
glfw3.lib(window.obj) : error LNK2001: unresolved external symbol __imp___wassert
glfw3.lib(input.obj) : error LNK2001: unresolved external symbol __imp___wassert
glfw3.lib(context.obj) : error LNK2001: unresolved external symbol __imp___wassert
glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol __imp___wassert
glfw3.lib(context.obj) : error LNK2019: unresolved external symbol __imp__strstr referenced in function __glfwStringInExtensionString
glfw3.lib(win32_joystick.obj) : error LNK2001: unresolved external symbol __imp__strstr
glfw3.lib(context.obj) : error LNK2019: unresolved external symbol __imp__strncmp referenced in function __glfwRefreshContextAttribs
glfw3.lib(egl_context.obj) : error LNK2001: unresolved external symbol __imp__strncmp
glfw3.lib(context.obj) : error LNK2019: unresolved external symbol __imp____stdio_common_vsscanf referenced in function __vsscanf_l
glfw3.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp__wcscmp referenced in function __glfwPlatformIsSameMonitor
glfw3.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp__wcscpy referenced in function _createMonitor
glfw3.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp__wcslen referenced in function __glfwPlatformIsSameMonitor
glfw3.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp__realloc referenced in function __glfwPlatformGetMonitors
glfw3.lib(monitor.obj) : error LNK2019: unresolved external symbol __imp___strdup referenced in function __glfwAllocMonitor
glfw3.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp___strdup
glfw3.lib(win32_joystick.obj) : error LNK2001: unresolved external symbol __imp___strdup
MSVCRTD.lib(_chandler4gs_.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4
hello_window.exe : fatal error LNK1120: 10 unresolved externals

I believe the symbols it's complaining about are C symbols rather than C++ ones making me think that maybe I'm not linking some common C library. I've tried adding libcmt.lib to the library list but I get the same error.

Has anyone run into something like this with CL before?

K0j0
  • 99
  • 1
  • 7
  • 1
    @genpfault So I don't think this is a straight duplicate of [this](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) because I understand what the issue is. I'm asking if anyone has experience linking with CL specifically not "what does this error mean?" – K0j0 Mar 02 '17 at 19:44
  • 3
    So I've figured this out. It doesn't seem like I can add an answer since @genpfault closed it as a duplicate. [This](http://stackoverflow.com/a/335478/710249) guided me. The __imp prefix on the library means that it's expecting those libraries to be dynamically linked. I rebuilt GLFW without the option USE_MSVC_RUNTIME_LIBRARY_DLL and all is well. Hope that's helpful to someone. – K0j0 Mar 02 '17 at 20:49
  • thanks, this fixed my problem with GLFW as well. Super helpful. Appreciate the comment. – Dan Bechard Feb 08 '20 at 17:10

0 Answers0