代码::阻止对"*"的未定义引用 [英] Code::Blocks undefined reference to "*"

查看:108
本文介绍了代码::阻止对"*"的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像标题中所说的那样,我在使用C :: B时遇到多个构建错误,所有人都在说undefined reference to '*'.我正在尝试使用OpenGL,GLFW和GLEW构建程序.每次找不到的前三件事是_imp__CreateDCW@16_imp__GetDeviceCaps@8_imp__DeleteDC@4.在Internet上浏览时,我看到所有这些方法都在gdi32库中,并确保将其添加到链接器中.一旦尝试使用GLFW3中的方法,该错误似乎就发生了.我尝试使用MinGW使用不同版本的GLFW,这就是我在Code :: Blocks中使用的版本,但是我无法摆脱错误.

Like the title says, I'm getting multiple build errors using C::B, all are saying undefined reference to '*'. I'm trying to build a program using OpenGL, GLFW, and GLEW. The top three things that it cant find every time are _imp__CreateDCW@16, _imp__GetDeviceCaps@8, _imp__DeleteDC@4. When looking on the internet, I saw that all of those methods were in the gdi32 library, which I made sure to add to the linker. The error appears to be happening as soon as I try to use methods from GLFW3. I've tried using different builds of GLFW using MinGW, which is what I'm using with Code::Blocks, but I cannot get the error to go away.

我正在使用Code :: Blocks 13.12在Windows 8.1上进行开发.

I am developing on Windows 8.1, using Code::Blocks 13.12.

以下是我链接的所有内容的列表,并且顺序相同:

Here is a list of everything I am linking and in the same order:

  • gdi32
  • 内核32
  • user32
  • opengl32
  • glu32
  • glfw3

代码::: Blocks看起来有点麻烦,但我真的很想开始习惯它.感谢任何可以提供帮助的人.

Code::Blocks is turning out to be a bit of a hassle, but I really want to start to get used to it. Thanks to anyone who can help.

推荐答案

您必须通过-lgdi32以便链接程序知道您正在使用GDI函数.顺序也很重要.在带有MinGW 4.8.1工具链的Windows 8上,我给出了这个信息:

You've to pass -lgdi32 for the linker to know that you're using GDI functions. Also the order matters. On Windows 8 with MinGW 4.8.1 tool chain I give this:

  • gle
  • glfw3
  • opengl32
  • gdi32

它对我有用;我不包括其他win32库.如果您使用的是GLEW的静态库,请确保在CB中定义GLEW_STATIC或直接将其定义为-DGLEW_STATIC.

And it works for me; I don't include the other win32 libraries. If you're using GLEW's static library make sure you define GLEW_STATIC either in CB or directly as -DGLEW_STATIC.

对于IDE,我选择了带有CMake且没有Qt SDK的QtCreator.

As for the IDE, I chose QtCreator with CMake and with no Qt SDK.

这篇关于代码::阻止对"*"的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆