Post

반응형

cocos2d github에서 cpp-tests 폴더 안에 있는 샘플들은 공부하는데 꽤나 유용해보였다.

그래서 이 샘플 가지고 공부를 하기로 결정!

cocos2d github cpp-tests 프로젝트 빌드 파일 실행하기

cocos2d-x-4\cocos2d-x-4\tests

다운받은 코코스 파일 안에 테스트 파일 있는 거 확인(tests폴더)

그래서 해당 프젝을 옮겨서 cmake로 빌드 파일 만들려고 하니까 에러가 난다.

H:\CocosProject\cpp-tests\build>cmake . -G "Visual Studio 17 2022" -A Win32
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
CMake Error at CMakeLists.txt:17 (include):
  include could not find requested file:

    CocosBuildSet


CMake Error at CMakeLists.txt:18 (add_subdirectory):
  add_subdirectory given source "H:/CocosProject/cpp-tests/../../cocos" which
  is not an existing directory.


CMake Error at CMakeLists.txt:403 (setup_cocos_app_config):
  Unknown CMake command "setup_cocos_app_config".


-- Configuring incomplete, errors occurred!

H:\CocosProject\cpp-tests\build>

관련해서 검색해보니까 같은 이슈 발견

https://github.com/cocos2d/cocos2d-x/issues/18696

 

Missing Cmake references · Issue #18696 · cocos2d/cocos2d-x

Hi! I'm trying to build a cocos2d-x3.17 project on Ubuntu 16.04. What I did: > git clone --recursive https://github.com/cocos2d/cocos2d-x. > cd cocos2d- > python download-deps. > git submodule upda...

github.com

반응형

Modules 에 있는 CocosBuildSet.cmake를 복사하라고 한다.

일단 기본프로젝트는 실행이 잘되어서 기본프젝에서 cocosBuildSet 위치를 검색해봤더니

test(프젝)\cocos2d\cmake\Modules에 존재한다.

\test\cocos2d 폴더를 통째로 cpp-tests 폴더에 복사했다.

근데 안된다. 그래서 빌드되는 프로젝트 CMakeLists.txt 와 안되는 프로젝트 CMakeLists.txt의 차이점을 비교함.

cocosBuildSet를 못찾는 거 보니 둘의 기본 경로가 다른 거 같음.

그리고 역시나 경로가 달랐음.

test프로젝트: set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cocos2d)

cpp test 프로젝트: set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../..)

그래서 CMakeLists 복사본 만들고 위치를 test프로젝트처럼 수정.

그러니까 sln 프로젝트 파일 만들어짐!!!! 성공 ㅠㅠㅠㅠㅠㅠ

근데 빌드하니까 에러 발생...

그런데 에러들을 보니까...함수 인자 갯수가 맞지 않는다고 하는 걸 보니

이거 설마 최근 함수 적용이 안된건가 싶다;;;끄으응;;;;

이 프로젝트는 그래도 simple sample이 많은 거 같아서 꼭 돌려보고 싶었는데...;;;;

전부 최신화 시켜줘야 돌아가는건가 싶다;; 일단 보니까 빌드 실패해서 exe파일도 bin 폴더에 안만들어져있음.

(수정중)

일단 에러 하나하나 뜯어보기로 했음

에러 목록

1. 'spine/Debug.h'


오류 C1083 포함 파일을 열 수 없습니다. 'spine/Debug.h': No such file or directory

 일단 쓰는 곳이 없어서 주석 처리.

Label::createWithBMFont("fonts/geneva-32.fnt", "And this is Geneva", TextHAlignment::LEFT, 0, Rect(0, 128, 0, 0));

일단 createWithBMFont 함수 레퍼런스 찾아봄.

https://docs.cocos2d-x.org/api-ref/cplusplus/v4x/db/de4/classcocos2d_1_1_label.html#ab9d3a60682e0d77312e2f154a2840647

 

Cocos2d-x: Label Class Reference

Label is a subclass of Node that knows how to render text labels. More... Inherits Node, LabelProtocol, and BlendProtocol. Inherited by TextFieldTTF. virtual void setString (const std::string &text) override  Sets the text that this Label is to display.

docs.cocos2d-x.org

static Label* createWithBMFont ( const std::string &  bmfontPath,
    const std::string &  text,
    const TextHAlignment  hAlignment = TextHAlignment::LEFT,
    int  maxLineWidth = 0,
    const Vec2  imageOffset = Vec2::ZERO 
  )

Allocates and initializes a Label, with a bitmap font file.

Parameters

bmfontPath A bitmap font file, it's a FNT format.
text The initial text.
hAlignment Text horizontal alignment.
maxLineWidth The max line width.
imageOffset  

ReturnsAn automatically released Label object.See alsosetBMFontFilePath setMaxLineWidth

 

Cocos2d-x: Label Class Reference

Label is a subclass of Node that knows how to render text labels. More... Inherits Node, LabelProtocol, and BlendProtocol. Inherited by TextFieldTTF. virtual void setString (const std::string &text) override  Sets the text that this Label is to display.

docs.cocos2d-x.org

5개 인자라서 false 빼주고 rect 대신 vector 해줌. 어차피 밑에서 벡터 set해주길래 그냥 0, 0으로 넣음. 그리고 어차피 실행이 목적이라 아무 값이나 넣거나 주석 처리 ㄱㄱ

auto label2 = Label::createWithBMFont("fonts/geneva-32.fnt", "And this is Geneva", TextHAlignment::LEFT, 0, Vec2(0, 0));

그랬더니 오류 133개가 튀어나왔다 아...........

으앙...더해보고 안되면 뭐 레퍼런스나 다른 프로젝트 참고를 해야겠어ㅠㅠ

근데 일단 에러나는 파일을 보면

SpineTest.h

SpineTest.cpp

CCConsole.h

ccUTF8.h

이 4개라서 이걸 제외하기로 결정. 일단 CCConsole.h, ccUTF8.h는 하나씩만 에러가 나고

몇백개 대부분 에러는 SpineTest.h, SpineTest.cpp에서 발생.

그래서 SpineTest.h, SpineTest.cpp 사용하는 부분 싹 다 주석처리.

갹!!!성공!!!!

다양한 예제가 있었다.

그리고 이제 또 분석하면 된다...

버그해결>분석>버그해결>분석>버그해결>분석

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

반응형
▲ top