diff --git a/cocos2dx/platform/linux/CCFileUtils.cpp b/cocos2dx/platform/linux/CCFileUtils.cpp index 389b667bbc..c57e2f936a 100644 --- a/cocos2dx/platform/linux/CCFileUtils.cpp +++ b/cocos2dx/platform/linux/CCFileUtils.cpp @@ -84,7 +84,8 @@ const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath) } -const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile) { +const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile) +{ std::string relativeFile = pszRelativeFile; CCString *pRet = new CCString(); pRet->autorelease(); @@ -93,15 +94,21 @@ const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const return pRet->m_sString.c_str(); } -unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize) { - +unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize) +{ string fullPath = pszFileName; unsigned char * pData = 0; + if (!pszFileName || !pszMode) + { + return 0; + } + do { + fullPath = fullPathFromRelativePath(fullPath.c_str()); // read rrom other path than user set it - FILE *fp = fopen(pszFileName, pszMode); + FILE *fp = fopen(fullPath.c_str(), pszMode); CC_BREAK_IF(!fp); fseek(fp,0,SEEK_END); @@ -123,7 +130,8 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz } -string CCFileUtils::getWriteablePath() { +string CCFileUtils::getWriteablePath() +{ //return current resource path return CCApplication::sharedApplication()->getResourceRootPath(); } diff --git a/samples/HelloCpp/proj.linux/Makefile b/samples/HelloCpp/proj.linux/Makefile index 2c5475a2ad..03df0db1f1 100644 --- a/samples/HelloCpp/proj.linux/Makefile +++ b/samples/HelloCpp/proj.linux/Makefile @@ -42,15 +42,19 @@ STATICLIBS = $(STATICLIBS_DIR)/libfreetype.a \ # $(STATICLIBS_DIR)/libGLEW.a \ -SHAREDLIBS = -L../../../lib/linux/Debug -lcocos2d -lrt -lz -lcocosdenshion -Wl,-rpath,../../../lib/linux/Debug/ +SHAREDLIBS = -L../../../lib/linux/Debug -lcocos2d -lrt -lz -lcocosdenshion -Wl,-rpath,../../../../lib/linux/Debug/ SHAREDLIBS += -lglfw -lcurl -SHAREDLIBS += -Wl,-rpath,../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib +SHAREDLIBS += -Wl,-rpath,../../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib SHAREDLIBS += -L../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib -lGLEW #$(shell ../../build-linux.sh $<) + +BIN_DIR=bin + ####### Build rules $(TARGET): $(OBJECTS) - $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -o $(TARGET) $(SHAREDLIBS) $(STATICLIBS) + test -d $(BIN_DIR) || mkdir $(BIN_DIR) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -o $(BIN_DIR)/$(TARGET) $(SHAREDLIBS) $(STATICLIBS) ####### Compile %.o: %.cpp @@ -61,3 +65,4 @@ $(TARGET): $(OBJECTS) clean: rm -f $(OBJECTS) $(TARGET) core + rm -r $(BIN_DIR) diff --git a/samples/HelloCpp/proj.linux/main.cpp b/samples/HelloCpp/proj.linux/main.cpp index 4e1fbc8fb4..f99af29189 100644 --- a/samples/HelloCpp/proj.linux/main.cpp +++ b/samples/HelloCpp/proj.linux/main.cpp @@ -24,7 +24,7 @@ int main(int argc, char **argv) std::string resourcePath = fullpath; resourcePath = resourcePath.substr(0, resourcePath.find_last_of("/")); - resourcePath += "/../Resources/"; + resourcePath += "/../../Resources/"; // create the application instance AppDelegate app; diff --git a/samples/TestCpp/proj.linux/Makefile b/samples/TestCpp/proj.linux/Makefile index 5ef583cbc3..12e381e1c0 100644 --- a/samples/TestCpp/proj.linux/Makefile +++ b/samples/TestCpp/proj.linux/Makefile @@ -147,19 +147,22 @@ endif SHAREDLIBS += -lglfw -lGL #SHAREDLIBS += -lGLEW -SHAREDLIBS += -L../../../lib/linux/Debug -lcocos2d -lrt -lz -lcocosdenshion -Wl,-rpath,../../../lib/linux/Debug/ -SHAREDLIBS += -Wl,-rpath,$(SHAREDLIBS_DIR) -SHAREDLIBS += -Wl,-rpath,../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib +SHAREDLIBS += -L../../../lib/linux/Debug -lcocos2d -lrt -lz -lcocosdenshion -Wl,-rpath,../../../../lib/linux/Debug/ +SHAREDLIBS += -Wl,-rpath,../$(SHAREDLIBS_DIR) +SHAREDLIBS += -Wl,-rpath,../../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib SHAREDLIBS += -L../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib -lGLEW -SHAREDLIBS += -Wl,-rpath,$(STATICLIBS_DIR) +SHAREDLIBS += -Wl,-rpath,../$(STATICLIBS_DIR) SHAREDLIBS += -lcurl +BIN_DIR=bin ####### Build rules -$(TARGET): $(OBJECTS) - $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -o $(TARGET) $(SHAREDLIBS) $(STATICLIBS) $(LIBS) - +$(TARGET): $(OBJECTS) + test -d $(BIN_DIR) || mkdir $(BIN_DIR) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -o $(BIN_DIR)/$(TARGET) $(SHAREDLIBS) $(STATICLIBS) $(LIBS) + + ####### Compile %.o: %.cpp $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ @@ -167,5 +170,7 @@ $(TARGET): $(OBJECTS) %.o: %.c $(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ + clean: rm -f $(OBJECTS) $(TARGET) core + rm -r $(BIN_DIR) diff --git a/samples/TestCpp/proj.linux/main.cpp b/samples/TestCpp/proj.linux/main.cpp index 72efb90db0..f882a2cc66 100644 --- a/samples/TestCpp/proj.linux/main.cpp +++ b/samples/TestCpp/proj.linux/main.cpp @@ -24,7 +24,7 @@ int main(int argc, char **argv) std::string resourcePath = fullpath; resourcePath = resourcePath.substr(0, resourcePath.find_last_of("/")); - resourcePath += "/../Resources/"; + resourcePath += "/../../Resources/"; // create the application instance AppDelegate app; diff --git a/samples/TestJavascript/proj.linux/Makefile b/samples/TestJavascript/proj.linux/Makefile index 87f64720de..89daeee6ff 100644 --- a/samples/TestJavascript/proj.linux/Makefile +++ b/samples/TestJavascript/proj.linux/Makefile @@ -55,17 +55,21 @@ SHAREDLIBS_DIR = ../../../CocosDenshion/third_party/fmod/api/lib SHAREDLIBS = -L$(SHAREDLIBS_DIR) -lfmodex endif -SHAREDLIBS += -L../../../lib/linux/Debug -lcocos2d -lrt -lz -lcocosdenshion -Wl,-rpath,../../../lib/linux/Debug/ +SHAREDLIBS += -L../../../lib/linux/Debug -lcocos2d -lrt -lz -lcocosdenshion -Wl,-rpath,../../../../lib/linux/Debug/ SHAREDLIBS += -lglfw -lcurl #SHAREDLIBS += -lGLEW -SHAREDLIBS += -Wl,-rpath,$(SHAREDLIBS_DIR) -SHAREDLIBS += -Wl,-rpath,../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib +SHAREDLIBS += -Wl,-rpath,../$(SHAREDLIBS_DIR) +SHAREDLIBS += -Wl,-rpath,../../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib SHAREDLIBS += -L../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib -lGLEW #$(shell ../../build-linux.sh $<) + +BIN_DIR=bin + ####### Build rules $(TARGET): $(OBJECTS) - $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -o $(TARGET) $(SHAREDLIBS) $(STATICLIBS) + test -d $(BIN_DIR) || mkdir $(BIN_DIR) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -o $(BIN_DIR)/$(TARGET) $(SHAREDLIBS) $(STATICLIBS) ####### Compile %.o: %.cpp @@ -76,3 +80,4 @@ $(TARGET): $(OBJECTS) clean: rm -f $(OBJECTS) $(TARGET) core + rm -r $(BIN_DIR) diff --git a/samples/TestJavascript/proj.linux/main.cpp b/samples/TestJavascript/proj.linux/main.cpp index 72efb90db0..f882a2cc66 100644 --- a/samples/TestJavascript/proj.linux/main.cpp +++ b/samples/TestJavascript/proj.linux/main.cpp @@ -24,7 +24,7 @@ int main(int argc, char **argv) std::string resourcePath = fullpath; resourcePath = resourcePath.substr(0, resourcePath.find_last_of("/")); - resourcePath += "/../Resources/"; + resourcePath += "/../../Resources/"; // create the application instance AppDelegate app;