2017-05-16 2 views
1

Ich versuche, mit einem Buch über moderne OpenGL zu beginnen. In dem Buch muss ich mich mit einigen Bibliotheken verbinden (d. H. freeglutglew32vermilion32). Ich habe den Quellcode für glew heruntergeladen und die lib erzeugt. Es gibt kein Problem mit der Verknüpfung der Bibliotheken, die ich erstellt habe, aber es scheint, dass der Autor pragma comment verwendet und es einige Verknüpfungsfehler verursacht.kann Datei 'glew_static_vs2010.lib' und Pragma-Kommentar nicht öffnen

LINK : fatal error LNK1104: cannot open file 'glew_static_vs2010.lib' 
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.EXE"' : return code '0x2' 

In einem der Header-Dateien (das heißt vgl.h) im Code verwendet, gibt es diese Linien

#ifndef __VGL_H__ 
#define __VGL_H__ 

// #define USE_GL3W 

#ifdef USE_GL3W 

#include <GL3/gl3.h> 
#include <GL3/gl3w.h> 

#else 

#define GLEW_STATIC 

#include <GL/glew.h> 

#ifdef _MSC_VER 
# ifdef _DEBUG 
# if (_MSC_VER >= 1600) 
#  pragma comment (lib, "glew_static_vs2010_d.lib") 
# else 
#  pragma comment (lib, "glew_static_d.lib") 
# endif 
# else 
# if (_MSC_VER >= 1600) 
#  pragma comment (lib, "glew_static_vs2010.lib") 
# else 
#  pragma comment (lib, "glew_static.lib") 
# endif 
# endif 
#endif 

#endif 

#define FREEGLUT_STATIC 

#include <GL/freeglut.h> 

#ifdef _MSC_VER 
# ifdef _DEBUG 
# if (_MSC_VER >= 1600) 
#  pragma comment (lib, "freeglut_static_vs2010_d.lib") 
# else 
#  pragma comment (lib, "freeglut_static_d.lib") 
# endif 
# else 
# if (_MSC_VER >= 1600) 
#  pragma comment (lib, "freeglut_static_vs2010.lib") 
# else 
#  pragma comment (lib, "freeglut_static.lib") 
# endif 
# endif 
#endif 

#define BUFFER_OFFSET(x) ((const void*) (x)) 

#endif /* __VGL_H__ */ 

Ich weiß nicht, warum der Autor diesen Ansatz verfolgt. Wie kann ich dieses Problem überwinden? Das ist mein Makefile

CC = cl 
CFLAGS = /EHsc /c 
INCLUDES = \ 
    /I D:\CPP_Projects\CommandPrompt\ModernOpenGL\Books\Opengl_Programming_Guide_8th\oglpg_8th_edition\include 

LIBS = \ 
    /LIBPATH:D:\CPP_Projects\CommandPrompt\ModernOpenGL\Books\Opengl_Programming_Guide_8th\oglpg_8th_edition\lib \ 
    freeglut_staticd.lib glew32sd.lib vermilion32_d.lib 

all: project  

project: triangles.obj LoadShaders.obj 
    $(CC) /EHsc /Fetest.exe triangles.obj LoadShaders.obj \ 
      /link $(LIBS) 

triangles.obj: triangles.cpp 
    $(CC) $(CFLAGS) triangles.cpp $(INCLUDES) 

LoadShaders.obj: LoadShaders.cpp 
    $(CC) $(CFLAGS) LoadShaders.cpp $(INCLUDES) 

clean: 
    del *.exe *.obj 

Antwort

0

Microsoft Compiler #pragma comment (lib, "libraryname.lib") angeben Bibliotheken verwenden kann, die stattdessen durch Linker verwendet werden soll, die Weitergabe auf Befehlszeile Linker. Da Sie Ihre eigenen Bibliotheken bauen sollten Sie vielleicht diese ganzen Blöcke für die automatische Verknüpfung von vgl.h Kommentar (oder sogar löschen):

#ifndef __VGL_H__ 
#define __VGL_H__ 

    // #define USE_GL3W 

#ifdef USE_GL3W 

#include <GL3/gl3.h> 
#include <GL3/gl3w.h> 

#else 

#define GLEW_STATIC 

#include <GL/glew.h> 

// #ifdef _MSC_VER 
// # ifdef _DEBUG 
// # if (_MSC_VER >= 1600) 
// #  pragma comment (lib, "glew_static_vs2010_d.lib") 
// # else 
// #  pragma comment (lib, "glew_static_d.lib") 
// # endif 
// # else 
// # if (_MSC_VER >= 1600) 
// #  pragma comment (lib, "glew_static_vs2010.lib") 
// # else 
// #  pragma comment (lib, "glew_static.lib") 
// # endif 
// # endif 
// #endif 

#endif 

#define FREEGLUT_STATIC 

#include <GL/freeglut.h> 

// #ifdef _MSC_VER 
// # ifdef _DEBUG 
// # if (_MSC_VER >= 1600) 
// #  pragma comment (lib, "freeglut_static_vs2010_d.lib") 
// # else 
// #  pragma comment (lib, "freeglut_static_d.lib") 
// # endif 
// # else 
// # if (_MSC_VER >= 1600) 
// #  pragma comment (lib, "freeglut_static_vs2010.lib") 
// # else 
// #  pragma comment (lib, "freeglut_static.lib") 
// # endif 
// # endif 
// #endif 

#define BUFFER_OFFSET(x) ((const void*) (x)) 

#endif /* __VGL_H__ */ 
+0

Es wirft immer noch diesen Fehler 'LINK: fatal error LNK1104: Datei kann nicht geöffnet‚glew_static_vs2010 .lib'' – CroCo

Verwandte Themen