簡體   English   中英

glfw和MSVS 2012的鏈接器錯誤

[英]Linker Errors with glfw and MSVS 2012

我正在嘗試使用MSVS 2012設置glfw。

我從http://www.glfw.org/download.html(32位)下載了最新版本的glfw。 在下一步中,我創建了一個具有以下內容的新屬性表:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets" />
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup />
  <ItemDefinitionGroup>
    <ClCompile>
      <AdditionalIncludeDirectories>$(glfw_DIR)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    </ClCompile>
    <Link>
      <AdditionalLibraryDirectories>$(glfw_DIR)\lib-msvc120;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
      <AdditionalDependencies>glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemGroup />
</Project>

然后,我嘗試運行以下代碼:

#include <GLFW/glfw3.h>
#include <thread>

int main()
{
    glfwInit();
    std::this_thread::sleep_for(std::chrono::seconds(1));
    glfwTerminate();
}

並收到以下輸出:

1>------ Erstellen gestartet: Projekt: openGL_Basic_flow, Konfiguration: Debug Win32 ------
1>LINK : warning LNK4098: Standardbibliothek "MSVCRT" steht in Konflikt mit anderen Bibliotheken; /NODEFAULTLIB:Bibliothek verwenden.
1>glfw3.lib(window.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__glClear@4" in Funktion "_glfwCreateWindow".
1>glfw3.lib(context.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__glGetIntegerv@8" in Funktion "__glfwRefreshContextAttribs".
1>glfw3.lib(context.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__glGetString@4" in Funktion "_glfwExtensionSupported".
1>glfw3.lib(wgl_context.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__wglCreateContext@4" in Funktion "__glfwCreateContext".
1>glfw3.lib(wgl_context.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__wglDeleteContext@4" in Funktion "__glfwDestroyContext".
1>glfw3.lib(wgl_context.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__wglGetProcAddress@4" in Funktion "__glfwPlatformGetProcAddress".
1>glfw3.lib(wgl_context.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__wglMakeCurrent@8" in Funktion "__glfwPlatformMakeContextCurrent".
1>glfw3.lib(wgl_context.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__wglShareLists@8" in Funktion "__glfwCreateContext".
1>glfw3.lib(win32_time.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__dtoul3" in Funktion "__glfwPlatformSetTime".
1>glfw3.lib(win32_time.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__ultod3" in Funktion "__glfwInitTimer".
1>C:\Projektmappe\Debug\openGL_Basic_flow.exe : fatal error LNK1120: 10 nicht aufgelöste Externe
========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ==========

我還嘗試使用此處提到的解決方法來修復它: 使用Visual Studio 2012編譯GLFW,但這沒有幫助。 輸出更改為以下內容:

1>------ Erstellen gestartet: Projekt: openGL_Basic_flow, Konfiguration: Debug Win32 ------
1>  main.cpp
1>LINK : warning LNK4098: Standardbibliothek "MSVCRT" steht in Konflikt mit anderen Bibliotheken; /NODEFAULTLIB:Bibliothek verwenden.
1>glfw3.lib(win32_time.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__dtoul3" in Funktion "__glfwPlatformSetTime".
1>glfw3.lib(win32_time.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__ultod3" in Funktion "__glfwInitTimer".
1>C:\Projektmappe\Debug\openGL_Basic_flow.exe : fatal error LNK1120: 2 nicht aufgelöste Externe
========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ==========

還有其他想法嗎?

您為Visual Studio 2012使用了錯誤的二進制文件。正確的二進制文件在lib-msvc110文件夾中。 當您使用2位或3位數字的版本時,您需要始終保持謹慎,因為它們與年份不匹配(僅適用於2010年)。

  • VC90 = Visual Studio 2008年
  • VC100 = Visual Studio 2010
  • VC110 = Visual Studio 2012。
  • VC120 = Visual Studio 2013。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM