【问题标题】:GLUT - Undefined reference to pressedButton(int, int) [duplicate]GLUT - 对pressedButton(int,int)的未定义引用[重复]
【发布时间】:2022-01-12 03:17:27
【问题描述】:

我有一个main 方法,其中包含glutMotionFunc,它接收签名为void movimentoMouseBotaoApertado(int, int) 的函数movimentoMouseBotaoApertado。我有一个.h.cpp 文件,但是当我在主文件中导入.h 并尝试执行代码时,出现错误undefined reference to movimentoMouseBotaoApertado(int, int)

main.cpp

...
#include "mouse/mouse.h"
#include "desenha/desenha.h"
...
int main(int argc, char *argv[])
{
    glutInit(&argc, argv); // Always needs glutInit
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);

    inicializa();
    nomeDoPrograma();

    glutDisplayFunc(desenha);
    glutKeyboardFunc(teclado);
    glutSpecialFunc(teclasEspeciais);
    criarMenu();
    glutMouseFunc(gerenciaMouse);
    glutMotionFunc(movimentoMouseBotaoApertado);
    glutPassiveMotionFunc(movimentoMouse);
    glutReshapeFunc(alterarTamanhoJanela);
    glutMainLoop(); // Redesenhando
}

movimentoMouseBotaoApertado.h

#ifndef MOVIMENTOMOUSEBOTAOAPERTADO_H_INCLUDED
#define MOVIMENTOMOUSEBOTAOAPERTADO_H_INCLUDED

void movimentoMouseBotaoApertado(int, int);

#endif // MOVIMENTOMOUSEBOTAOAPERTADO_H_INCLUDED

movimentoMouseBotaoApertado.cpp

#include <stdio.h>

void movimentoMouseBotaoApertado(int x, int y) {
    printf("Botão apertado [%d,%d]", x, y);
}

【问题讨论】:

    标签: c++ glut freeglut


    【解决方案1】:

    我单击右键并选择递归添加文件...然后我选择了文件夹/文件并使用它。

    【讨论】:

      猜你喜欢
      • 2012-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多