[英]OpenGL GLFW build errors OR linking errors
有人可以幫助我讓GLFW在Visual Studio 2012中工作嗎? 我無法通過最初的編譯。 對於GLFW功能,我一直都無法解決外部問題。 問題是,我不知道我在做什么錯。 我可以是:
我不確定是哪個,所以我只列出我做了什么:
1. Downloaded glfw-3.1.1 from glfw.org.
2. Used CMake GUI to make the source files.
a. Set source code to C:/GLFW/glfw-3.1.1
b. Set "Where to build the binaries" to C:/GLFW/glfw-3.1.1/GLFW_Built (I created that directory)
c. Clicked "Configure"
d. Selected "Visual Studio 11 2012" as the generator (I also tried "Visual Studio 11 2012 Win64," but it gave me the same results. The ARM one wouldn't build at all)
e. Left "Use default native compilers" selected.
f. Clicked "Finish."
g. Set "BUILD_SHARED_LIBS" to true (checked).
h. Clicked "Generate."
3. Built the library.
a. Went to C:\GLFW\glfw-3.1.1\GLFW_Built and opened GLFW.sln in Visual Studio 2012.
b. Clicked BUILD->Build ALL_BUILD (worked fine, no errors)
4. Created a new blank project in Visual Studio 2012.
5. Went into the properties pages and set:
a. Configuration Properties/VC++ Directories/Include Directories: added "C:\GLFW\glfw-3.1.1\include"
b. Configuration Properties/VC++ Directories/Library Directories: added "C:\GLFW\glfw-3.1.1\GLFW_Built\CMakeFiles\Export\lib" (it was the only lib folder I saw) and "C:\GLFW\glfw-3.1.1\GLFW_Built\src\Debug" (contains glfw3.dll and glfw3dll.lib)
c. Configuration Properties/C/C++/Additional Include Directories: added "C:\GLFW\glfw-3.1.1\include"
d. Configuration Properties/Linker/General: added "C:\GLFW\glfw-3.1.1\GLFW_Built\src\Debug
e. Configuration Properties/Linker/Input: added "glfw3dll.lib" and "opengl32.lib"
對於我的代碼,main.cpp中只有一個非常簡單的測試程序:
#include <GLFW/glfw3.h>
#include <thread>
int main()
{
glfwInit();
std::this_thread::sleep_for(std::chrono::seconds(1));
glfwTerminate();
}
但是我總是在輸出中得到這個:
1>main.obj : error LNK2019: unresolved external symbol _glfwInit referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _glfwTerminate referenced in function _main
1>C:\Users\Adam\Desktop\Revenant\Revenant\Debug\Revenant.exe : fatal error LNK1120: 2 unresolved externals
將GLFW提取到C:\\glfw-src
(以使存檔中的CMakeLists.txt
位於C:\\glfw-src\\CMakeLists.txt
)
cd C:\\glfw-src
mkdir build
cd build
cmake-gui ../
CMAKE_INSTALL_PREFIX
設置為C:/glfw
c:\\glfw
目錄 build\\GLFW.sln
C:\\glfw
現在應該包含include
和lib
目錄。
假設采用全新的“空項目”解決方案:
c:\\glfw\\include
添加到/I
(配置屬性-> C / C ++->常規->其他包含目錄) c:\\glfw\\lib
添加到/LIBPATH
(配置屬性->鏈接器->常規->其他庫目錄),並將glfw3.lib
和opengl32.lib
添加到/DYNAMICBASE
(配置屬性->鏈接器->輸入->其他依賴項)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.