The section

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

says "here is how you build the file $(TARGET).js. It depends on the files
$(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST), and the two
commands that are used to build the .js files are mkdir (create the output
directory) and the em++ compiler invocation itself." The --js-library
statements goes on the same line as the $(CXX) rule. Try out

$(CXX) --js-library my.js $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS)
$(STATICLIBS)

that should link your .js library in. To debug and confirm that the proper
link flags are being passed, use a 'make -n', 'make -d', 'make VERBOSE=1',
or similar statement, see here
http://stackoverflow.com/questions/5820303/how-do-i-force-make-gcc-to-show-me-the-commands





2014-04-15 16:49 GMT+03:00 Roman Kravchenko <
[email protected]>:

> I understand this fact, but I am not a big expert in making Makefiles and
> here it`s no so simple as looked. I try a lot of variants but still it
> can`t find JS function ("Uncaught ReferenceError: _js_send_data is not
> defined"). Here the hole makefile
>
> EXECUTABLE = HelloCpp
>
> INCLUDES = -I.. -I../Classes
>
> SOURCES = main.cpp \
>         ../Classes/AppDelegate.cpp \
>         ../Classes/HelloWorldScene.cpp
>
> RESOURCE_PATH = ../Resources/iphone
>
> RESOURCES = CloseNormal.png \
>             CloseSelected.png \
>             HelloWorld.png
>
> FONT_PATH = ../Resources/fonts
>
> COCOS_ROOT = ../../../..
> include $(COCOS_ROOT)/cocos2dx/proj.emscripten/cocos2dx.mk
>
> SHAREDLIBS += -lcocos2d
> COCOS_LIBS = $(LIB_DIR)/libcocos2d.so
>
> $(TARGET).js: $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST)
> @mkdir -p $(@D)
> $(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS)
>
> $(TARGET).data:
> @mkdir -p $(@D)
> $(eval RESTMP := $(shell mktemp -d /tmp/cocos-emscripten.XXXXXX))
> # Always need a font path, so ensure that it is created first.
> mkdir -p $(RESTMP)/fonts
> (cd $(RESOURCE_PATH) && cp -a $(RESOURCES) $(RESTMP))
> (cd $(FONT_PATH) && cp -a * $(RESTMP)/fonts)
> # NOTE: we copy the system arial.ttf so that there is always a fallback.
> cp /Library/Fonts/Arial.ttf $(RESTMP)/fonts/arial.ttf
> (cd $(RESTMP); python $(PACKAGER) $(EXECUTABLE).data $(patsubst
> %,--preload %,$(RESOURCES)) --preload fonts --pre-run >
> $(EXECUTABLE).data.js)
> mv $(RESTMP)/$(EXECUTABLE).data $@
> mv $(RESTMP)/$(EXECUTABLE).data.js [email protected]
> rm -rf $(RESTMP)
>
> $(BIN_DIR)/index.html: index.html
> @mkdir -p $(@D)
> cp index.html $(@D)
>
> $(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST)
> @mkdir -p $(@D)
> $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@
>
> $(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST)
> @mkdir -p $(@D)
> $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@
>
>
>
> Вівторок, 15 квітня 2014 р. 15:55:12 UTC+3 користувач jj написав:
>>
>> Yeah, that is the preferred way to embed JavaScript code to the project
>> that will be called by C/C++ code. The --js-library directive should come
>> in the link step, which is the step that also has the "-o out.js/.html"
>> command line directive.
>>
>>
>> 2014-04-15 15:35 GMT+03:00 Roman Kravchenko <[email protected]>:
>>
>> Hi.
>>>
>>> I am trying to call javascript implementation websokets from cpp file in
>>> HelloCpp test project. In version what I use it can`t binding JavaScript to
>>> C++, so I use method like test_js_libraries from tests/runner.py with
>>> --js-library.
>>>
>>> And here is a question: where I should write "--js-library my.js" in
>>> project make file, that way it could find my function implamentation? What
>>> you think about this and any ideas how to do this?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "emscripten-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to