compiled program cannot find freeglut.dll

后端 未结 2 588
南笙
南笙 2021-02-09 07:37

I\'m new to this site, and relatively new to programming. I\'ve been doing some C++ programming for a while using Visual Studio 2010, and I wanted to get into OpenGL, so I bough

相关标签:
2条回答
  • 2021-02-09 07:54

    @ScottMcP-MVP 's answer solved my problem, but I thought I'd add some detail that doesn't really fit in the comment.

    My solution:

    1. Add the following subdirectory structure to your solution folder:

    enter image description here

    In x86, put the 32-bit versions of GLut, GLew and anything else you need.

    In x64, put the 64-bit versions of same.

    I went ahead and put all .dll, .lib, and .h in the corresponding folders here rather than placing them in the Windows SDK (Or, in Win7+, the "Windows Kits" folder) to ensure that my projects in SVN had the correct version, and checking out on another machine would retrieve all dependencies. This required adding the include and target-specific lib folders to the project properties:

    enter image description here

    Set your Include Directories field to

    $(SolutionDir)ThirdParty\Include\;$(IncludePath)

    And your Library Directories field to

    $(SolutionDir)\ThirdParty\$(PlatformTarget)\lib\;$(LibraryPath)

    Note that all of these should be applied to the "All Platforms" build configuration. The $(PlatformTarget) macro will make sure that the correct lib's and dll's are used. The include folder is target-agnostic, so I've placed it in the root of my ThirdParty folder.

    To get the required files into your output folder, add the following post-build event to your project configuration (under "All platforms"):

    xcopy $(SolutionDir)ThirdParty\$(PlatformTarget)\*.dll $(OutputPath) /Y

    enter image description here

    That will copy the correct version of the DLLs to your output folder on build. This keeps you from having to manually put the DLLs in our output folder, and is more compatible with source control where you typically don't want to include your output, bin or debug folders.

    Once I had all of this configured, I created a VC OpenGL project template since getting everything configured took 30 minutes of my life I'd rather have back.

    0 讨论(0)
  • 2021-02-09 08:03

    Try putting the DLL in the same folder as your exe file. The advice to put it in Windows\System32 predates a lot of newer Windows security restrictions.

    0 讨论(0)
提交回复
热议问题