google-nativeclientppapi

Build and run NaCl code using additional .cc files


I am new to NaCl. I was trying to build and run the sample code as per the instrction provided https://developer.chrome.com/native-client/devguide/tutorial/tutorial-part1

I was able run the original code. Now in this example I created one .cc and .h file and called one of the function in new .cc file from the hello_tutorial.cc(this file already exists). But I am not sure how do I add this new file in the Makefile, so that compiler would include these file as well when I run the make command.

Can anybody help what I am missing here ?


Solution

  • The Makefile for part1 of the tutorial is hand rolled so you need to add a couple of new lines for each source file:

    [new_file].bc: [new_file].cc
    $(PNACL_CXX) -o $@ $< -O2 $(CXXFLAGS) $(LDFLAGS)

    And then add .bc to the dependencies of the pexe:

    hello_tutorial.pexe: hello_tutorial.bc [new_file.bc]

    If you switch to part2 of the tuturial it uses the NaCl SDK build system which makes things a little easier and you just need to add your source to the "SOURCES =" line in the Makefile.