2017-12-23 6 views
0

링크 2001 오류 그래서 내 작은 프로그램에서 여러 파일이 있습니다, 무슨 일이 일어나고 내 헤더 파일과 cpp 파일 중 하나 사이에 link2001 오류가 발생하고 있습니다. 내가 별도의 파일로 이동 MAIN.CPP 모든 것을 가지고 있었다 전에해결되지 않은 외부 기호

#include "stdafx.h" 
#include <Windows.h> 
#include <iostream> 
#include <string> 

void startup::checkUpToDate() 
{ 
    if (startup::currentVersion == startup::latestVersion) 
    { 
     startup::upToDate = true; 
    } 
    if (startup::currentVersion != startup::latestVersion) 
    { 
     startup::upToDate = false; 
    } 
} 
void startup::consoleStartup() 
{ 
    startup::checkUpToDate(); 
    HANDLE hConsole; 
    hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 
    FlushConsoleInputBuffer(hConsole); 
    SetConsoleTextAttribute(hConsole, color::red); 
    std::cout << R"(
     _,.-------.,_ 
    ,;~'    '~;, 
    ,;      ;, 
    ;       ; 
,'       ', 
,;       ;, 
; ;  .   .  ; ; 
| ; ______  ______ ; | 
| `/~"  ~" . "~  "~\' | 
| ~ ,-~~~^~, | ,~^~~~-, ~ | 
| |  }:{  | | 
| l  /| \  ! | 
.~ (__,.--" .^. "--.,__) ~. 
|  ---;'/| \ `;---  | 
    \__.  \/^\/  .__/ 
    V| \    /|V 
    | |T~\___!___!___/~T| | 
    | |`IIII_I_I_I_IIII'| | 
    | \,III I I I III,/ | 
    \ `~~~~~~~~~~' /
     \ .  . / 
     \. ^ ./ 
)" << std::endl; 

    SetConsoleTextAttribute(hConsole, color::green); 
    std::cout << "---------------------The ----------------------" << std::endl; 
    SetConsoleTextAttribute(hConsole, color::purple); 
    if (startup::upToDate == true) 
    { 
     std::cout << "  [You are all up to date! Your version: " + startup::currentVersion + " Latest version: " + startup::latestVersion + "]" << std::endl; 
    } 
    else if (startup::upToDate == false) 
    { 
     std::cout << "  [You are running on a old update! Your version: " + startup::currentVersion + " Latest version: " + startup::latestVersion + "]" << std::endl; 
    } 
    SetConsoleTextAttribute(hConsole, color::white); 
} 

모든 것이 잘 작동 : 여기 내 헤더 파일과

struct startup 
{ 
    static std::string latestVersion; 
    static std::string currentVersion; 
    static std::string latestUpdate; 
    static bool upToDate; 
    static void checkUpToDate(); 
    static void consoleStartup(); 

}; 

내 CPP 파일입니다. 나는 내가 무엇을 잘못하고 있는지를 100 % 확신하지는 않는다. 내가 link2001 오류가 무엇인지 알 수는 있지만 그것을 고칠 수 없을 것 같다.

Severity Code Description Project File Line Suppression State 
Error LNK2001 unresolved external symbol "public: static bool startup::upToDate" ([email protected]@@2_NA) FileEncryptionDecryptions C:\Users\Jonitoi\Desktop\Projects\Visual Studio\cpp\FileEncryptionDecryptions\FileEncryptionDecryptions\startup.obj 1 
+2

빌드 ERR에 대한 질문을 게시 할 때 –

+0

상점 ASCII 두개골 당신은 전체 오류 메시지 – Asesh

+1

를 게시해야 ors는 항상 전체 텍스트와 전체 텍스트를 복사 (수정없이)하여 본문에 붙여 넣습니다. 잠시 시간을내어 [좋은 질문을하는 법을 읽어보십시오] (http://stackoverflow.com/help/how-to-ask). –

답변

0

upToDate 당신이 그것을 초기화 할 수 있도록 정적 멤버 변수는 다음과 같습니다

내 코드는 메신저는 여전히 또한 여기 :)

를 사전에 감사를 배우고, 아주 나쁜 될 수는 오류 메시지입니다 전역 범위에서 :

struct startup 
{ 
    static std::string latestVersion; 
    static std::string currentVersion; 
    static std::string latestUpdate; 
    static bool upToDate; 
    static void checkUpToDate(); 
    static void consoleStartup(); 
}; 

bool startup::upToDate = false;