我已經得到這些LNK2019s一段時間了,似乎無法找到擺脫它們的方法。我知道這些錯誤已經有很多線索了,但我還沒有找到任何對我有幫助的東西,所以希望有人可能錯過我可能錯過的明顯的東西。LNK2019&LNK1120未解決的外部問題可能是一個簡單的解決方法,但我有真正的麻煩
我從來沒有學過很傳統,所以很抱歉如果我的代碼有點混亂。
主:
#include "eventLoop.h"
#include <time.h>
#include <iostream>
using namespace std;
bool buttonA, buttonB, buttonC, buttonD, buttonE, buttonF, buttonG = false;
bool KeepProgramOpen = true;
time_t timer;
time_t oldtime;
time_t dtime;
time_t looptime;
int rate;
char Note;
bool FirstLoop = true;
eventLoop MainEventLoop;
int main()
{
rate = 60;
looptime = 1000/rate;
while(KeepProgramOpen==true)
{
time(&timer);
dtime = timer-oldtime;
if(dtime<looptime)
{
continue;
}
oldtime = timer;
MainEventLoop.FindFinalNote(buttonA, buttonB, buttonC, buttonD, buttonE, buttonF, buttonG, FirstLoop);
FirstLoop = false;
//Closing stuff goes here
}
}
eventLoop.h:
#pragma once
class eventLoop {
public:
void FindFinalNote(bool, bool, bool, bool, bool, bool, bool, bool);
protected:
};
eventLoop.cpp:
#include "eventLoop.h"
#include "MidiOutput.h"
#include "FileIO.h"
MidiOutput MidiOutputX;
FileIO fileioX;
void eventLoop::FindFinalNote(bool A, bool B, bool C, bool D, bool E, bool F, bool G, bool firstloop)
{
if(firstloop == true)
{
for (int loopindex=0; loopindex<10; loopindex++)
{
// Note[loopindex] = Filecheck for notes
}
MidiOutputX.FindDevice(
1, /*int argc number of ports*/
60, /*char argv argument vector - strings pointed to, i don't really get it*/
);
}
char Note[10];
int KeyIndex = 0;
FileIO::key CurrentKey;
CurrentKey = fileioX.RetrieveKey(KeyIndex);
for (int x = 0; x < 10; x++)
{
Note[x] = CurrentKey.Note[x];
}
// There's a bunch of simple if statements here, nothing I need to bore you with
}
MidiOutput.h:
#pragma once
class MidiOutput {
public:
void FindDevice(int, char);
void PlayNote(unsigned char);
void EndNote();
void CloseDevice();
protected:
};
MidiOutput.cpp:
#include "MidiOutput.h"
#include <Windows.h>
#include <mmsystem.h>
#include <stdio.h>
union { unsigned long word; unsigned char data[4]; } message;
int midiport;
HMIDIOUT device;
void FindDevice(int argc, char** argv)
{
if (argc < 2) {
midiport = 0;
} else {
midiport = atoi(argv[1]);
}
printf("Midi output port set to %d.\n", midiport);
midiOutOpen(&device, midiport, 0, 0, CALLBACK_NULL);
message.data[0] = 0x90; //command byte
message.data[1] = 60; //middle C
message.data[2] = 0; //volume, 0-100
message.data[3] = 0; //not used
}
void MidiOutput::PlayNote(unsigned char Note)
{
message.data[1] = Note;
message.data[2] = 100;
}
void MidiOutput::EndNote()
{
message.data[2] = 0;
}
void MidiOutput::CloseDevice()
{
midiOutReset(device);
midiOutClose(device);
}
精確的錯誤:
錯誤1個錯誤LNK2019:無法解析的外部符號 「市民:無效__thiscall MidiOutput :: FindDevice(INT,CHAR)」?(FindDevice @ MidiOutput @@ QAEXHD @ Z)在函數「public:void __thiscall eventLoop :: FindFinalNote(bool,bool,bool,bool,bool,bool,bool,bool)中引用」(?FindFinalNote @ eventLoop @@ QAEX_N0000000 @ Z)C:\ Users \ Hilly \ documents \ visual studio 2010 \ Projects \ GHX \ GHX \ eventLoop.obj GHX
錯誤2錯誤LNK2019:unresolv編輯外部符號_ imp _midiOutOpen @ 20在函數「void __cdecl FindDevice(int,char * *)」(?FindDevice @@ YAXHPAPAD @ Z)中引用C:\ Users \ Hilly \ documents \ visual studio 2010 \ Projects \ GHX \ GHX \ MidiOutput.obj GHX
錯誤3錯誤LNK2019:解析外部符號_ 小鬼 _midiOutClose @ 4在功能上引用的 「市民:無效__thiscall MidiOutput :: CloseDevice(無效)」?(CloseDevice @ MidiOutput @@ QAEXXZ )C:\用戶\丘陵\文檔\ Visual Studio 2010的\項目\ GHX \ GHX \ MidiOutput.obj GHX
錯誤4錯誤LNK2019:解析外部符號_ 小鬼 _midiOutReset @函數引用「公衆4: void __thiscall MidiOutput :: CloseDevice(void)「(?CloseDevice @ MidiOutput @@ QAEXXZ)C:\ Users \ Hilly \ documents \ visual studio 2010 \ Projects \ GHX \ GHX \ MidiOutput.obj GHX
錯誤5錯誤LNK1120 :4無法解析的外部C:\用戶\ \ Visual Studio 2010的\項目\ GHX \調試\ GHX.exe GHX
在此先感謝和抱歉的代碼在牆上,我不知道丘陵\文件什麼是必要的。
可能重複[什麼是未定義的引用/無法解析的外部符號錯誤,以及如何解決它?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved- –