how to build a js with series cpp file.if i build one by one,how to link them together

Asked by blueshell

how to build a js with series cpp file.
if i build them one by one,how to link them together?

example

1.cpp

void webMain()
{
    extern void extern_func();
   extern_func();
}

2.cpp
void extern_func()
{
   client::console.log("extern_func!");
}

I need a method to compile file one by one.thus,when i change one of them,i need not to compile the whole project.
the example is compile .cpp -> .js
is there any way to compile .cpp(s)->.o(s)->.js
if it is already supported, which command should i use when generating a .o file,and which command for link?

Question information

Language:
English Edit question
Status:
Solved
For:
Cheerp Edit question
Assignee:
No assignee Edit question
Solved by:
blueshell
Solved:
Last query:
Last reply:
Revision history for this message
blueshell (shell3000) said :
#1

I need a method to compile file one by one.thus,when i change one of them,i need not to compile the whole project.
the example is compile .cpp -> .js
is there any way to compile .cpp(s)->.o(s)->.js

Revision history for this message
Alessandro Pignotti (a-pignotti) said :
#2

This is fully supported, you can build object files using the -c command line option and link them togheter afterwards. See our wiki (https://github.com/leaningtech/cheerp-wiki/wiki/Getting-started#separate-objects-compilation-and-linking) for more information.

To avoid building already compiled files you should use a system such as make or cmake.

Revision history for this message
blueshell (shell3000) said :
#3

I‘v tested “-c“ without ”-target cheerp“ , so i got a error before.
I'v tested successfully now.