简体   繁体   中英

“Undefined reference to _ms_vsnprintf”

I figured out what I did. It was one of the libraries I was using. It had a reference to _ms__vsnprintf that wasn't defined in it. I removed the file and my program compiled. Thanks for your help. For future reference, the file was libglfw3.a .

How do I fix the error "Undefined Reference to _ms_vsnprintf"? I've only seen one other post about it, and that didn't fix my problem. I'm using Windows 8, Code::Blocks and MinGW. This is my code.

#define __LCC__
#define GLEW_STATIC
#define GLFWAPI __declspec(dllimport)
#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#define GLFW_INCLUDE_GLU
#include <GL/glfw3.h>
#include <glm/glm.hpp>
using namespace glm;
int main() {
if( !glfwInit() ) {
    fprintf( stderr, "Failed to initialize GLFW\n");
    return -1;
}
 glfwWindowHint(GLFW_SAMPLES, 4);
 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

GLFWwindow* window;
window = glfwCreateWindow( 600, 800, "OpenGL Window", NULL, NULL);

if(window == NULL) {
    fprintf(stderr, "OpenGL Couldn't open the window.\n");
    glfwTerminate();
    return -1;
}

glfwMakeContextCurrent(window);
glewExperimental=true;
if (glewInit() !=GLEW_OK) {
    fprintf(stderr, "Failed to start GLEW.\n");
    return -1;
}
 }

Here's the build log from Code::Blocks

-------------- Build: Debug in opengltest (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -lglfw3 -Wall -g -I..\..\MiniGW\lib\lib-mingw-w64 -c "D:\Programs\C PROGRAMS\opengltest\main.cpp" -o obj\Debug\main.o
mingw32-g++.exe -L..\..\MiniGW\lib\lib-mingw-w64 -L..\MiniGW\lib -o bin\Debug\opengltest.exe obj\Debug\main.o  -lglfw3 -lglfw3 -lopengl32 -lgdi32 -lglu32  ..\..\MiniGW\lib\Release\Win32\glew32s.lib ..\..\MiniGW\lib\lib-mingw-w64\glfw3dll.a ..\..\MiniGW\lib\lib-mingw-w64\libglfw3.a ..\..\MiniGW\lib\libglu32.a ..\..\MiniGW\lib\libopengl32.a
Warning: corrupt .drectve at end of def file
..\..\MiniGW\lib\lib-mingw-w64/libglfw3.a(init.c.obj):init.c:(.text+0x49): undefined reference to `__ms_vsnprintf'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 13 second(s))
1 error(s), 1 warning(s) (0 minute(s), 13 second(s))

I edited the question with my answer. Deleting libglfw3.a fixed it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM