Build for linux


#1

hi,

I want to build my app for linux.
But the makefile displays following error:
fatal error: cocos-ext.h: No such file or directory

How to fix it?

PS: I am using 2.1.5 and copied the proj.linux directory from helloCpp project

Thats my makefile:

EXECUTABLE = app

INCLUDES = -I.. -I../Classes

SOURCES = main.cpp \
        ../../Classes/AppDelegate.cpp \
        ../../Classes/SceneControl.cpp \
                ...

COCOS_ROOT = ../..
include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk

SHAREDLIBS += -lcocos2d
COCOS_LIBS = $(LIB_DIR)/libcocos2d.so

$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST)
    @mkdir -p $(@D)
    $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS)

$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST)
    @mkdir -p $(@D)
    $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@

$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST)
    @mkdir -p $(@D)
    $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@

greets


#2

Fixed it.
Needed to add

INCLUDES += ~~I$/extensions/ ~~I$(COCOS_ROOT)/external/chipmunk/include/chipmunk


#3

Hi

I have the same problem with cocos2d-x 2.2.2, Fedora 20, EClipse Kepler,
I added

INCLUDES += -I$(COCOS_ROOT)/extensions
INCLUDES += -I$(COCOS_ROOT)/external/chipmunk/include/chipmunk

and now I get another error, see below my makefile and the error

MAKEFILE

EXECUTABLE = thief

COCOS_ROOT = ../../..

INCLUDES = -I.. -I../Classes
INCLUDES += -I$(COCOS_ROOT)/extensions
INCLUDES += -I$(COCOS_ROOT)/external/chipmunk/include/chipmunk
#INCLUDES += -I$(COCOS_ROOT)/cocos2dx/kazmath/include
#INCLUDES += -I$(COCOS_ROOT)/cocos2dx/include
#INCLUDES += -I$(COCOS_ROOT)/cocos2dx
#INCLUDES += -I$(COCOS_ROOT)/external/
#INCLUDES += -I$(COCOS_ROOT)/CocosDenshion/include
#INCLUDES += -I$(COCOS_ROOT)/extensions/netwrok
#INCLUDES += -I$(COCOS_ROOT)/external/libwebsockets/win32/include


SOURCES = main.cpp \
        ../Classes/AppDelegate.cpp \
        ../Classes/HelloWorldScene.cpp


include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk

SHAREDLIBS += -lcocos2d
COCOS_LIBS = $(LIB_DIR)/libcocos2d.so

$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST)
	@mkdir -p $(@D)
	$(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS)

$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST)
	@mkdir -p $(@D)
	$(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@

$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST)
	@mkdir -p $(@D)
	$(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@
02:56:14 **** Auto Build of configuration Default for project thief ****
make all 
 CXX obj/release/main.o
 CXX obj/release/Classes/AppDelegate.o
 CXX obj/release/Classes/HelloWorldScene.o
 LINK bin/release/thief
obj/release/Classes/AppDelegate.o: In function `_GLOBAL__sub_I_AppDelegate.cpp':
AppDelegate.cpp:(.text.startup+0x72): undefined reference to `cocos2d::gui::Margin::Margin()'
obj/release/Classes/HelloWorldScene.o: In function `HelloWorld::init()':
HelloWorldScene.cpp:(.text+0x50f): undefined reference to `cocos2d::extension::CCScale9Sprite::create(char const*)'
HelloWorldScene.cpp:(.text+0x53f): undefined reference to `cocos2d::extension::CCEditBox::create(cocos2d::CCSize const&, cocos2d::extension::CCScale9Sprite*, cocos2d::extension::CCScale9Sprite*, cocos2d::extension::CCScale9Sprite*)'
HelloWorldScene.cpp:(.text+0x59c): undefined reference to `cocos2d::extension::CCEditBox::setFontColor(cocos2d::_ccColor3B const&)'
HelloWorldScene.cpp:(.text+0x5ab): undefined reference to `cocos2d::extension::CCEditBox::setPlaceHolder(char const*)'
HelloWorldScene.cpp:(.text+0x5b8): undefined reference to `cocos2d::extension::CCEditBox::setMaxLength(int)'
HelloWorldScene.cpp:(.text+0x5c5): undefined reference to `cocos2d::extension::CCEditBox::setReturnType(cocos2d::extension::KeyboardReturnType)'
obj/release/Classes/HelloWorldScene.o: In function `_GLOBAL__sub_I_HelloWorldScene.cpp':
HelloWorldScene.cpp:(.text.startup+0x72): undefined reference to `cocos2d::gui::Margin::Margin()'
collect2: error: ld returned 1 exit status
make: *** [bin/release/thief] Error 1

02:56:15 Build Finished (took 777ms)

I have added

using namespace cocos2d::extension;
using namespace cocos2d::gui;

and

    CCEditBox *m_pEditName = CCEditBox::create(ccp(100,100), CCScale9Sprite::create("input_field.png"));
    m_pEditName->setPosition(ccp(origin.x+visibleSize.width/2, origin.y+visibleSize.height*3/4));
    m_pEditName->setFontColor(ccRED);
    m_pEditName->setPlaceHolder("Name:");
    m_pEditName->setMaxLength(8);
    m_pEditName->setReturnType(kKeyboardReturnTypeDone);
    //m_pEditName->setDelegate(this);
    addChild(m_pEditName);

in the HelloWorldScene.cpp

Can you please help?
Thanks