Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling C++ Project that results in mutiple executables #1296

Open
ganeshkbhat opened this issue Oct 30, 2023 · 1 comment
Open

Compiling C++ Project that results in mutiple executables #1296

ganeshkbhat opened this issue Oct 30, 2023 · 1 comment

Comments

@ganeshkbhat
Copy link

ganeshkbhat commented Oct 30, 2023

I am trying to Compile C++ Project that results in multiple executables https://www.7-zip.org/. The make command generates o files, a single 7z.a file and multiple executables normally without issues. However, when I am trying to use the emcc the command emcc -O2 a.o b.o -o project.js or the emcc project.o libstuff.a -o final.html from the https://emscripten.org/docs/tools_reference/emcc.html#emccdoc is giving me errors saying xxx.o file format cannot be recognised.

What I wish to be doing is use the xx.o file and yy.o file which uses lib7z.a produces xx.exe and yy.exe executable to xx.wasm and yy.wasm respectively to export the functions of xx.exe and yy.exe files appropriately and not really the base functions of lib7z.a directly many of which are then used in a usable mode in the .c and .h files that makes the .exe files.

when the lib7z.a file created to create a lib7z.wasm file generates a lib7z.wasm file but the usage has become a lot more messy because the exported functions are not clear and not documented well. I am also unsure if all the executable functions of all 7z project's different executables exist in a directly usable format inside lib7z.wasm as well.

Commands:

# Compile project to project.o

emmake make

# Link the library and code together.
emcc project.o libstuff.a -o final.html
####FAILS

Alternatively


emmake make

# Link the library and code together.
emcc -02 a.o b.o -o project.js
####FAILS
@sbc100
Copy link
Collaborator

sbc100 commented Oct 30, 2023

If you want to create a static library such as lib7z.a when you need to use emar to create it, and not emcc.

The emcc project.o libstuff.a -o final.html example you give should work assuming things are setup correctly. Please share the full error message if you need more help with that.

If you see errors like xxx.o file format cannot be recognised that probably means have not built xxx.o with emcc but instread with the host compiler (e.g. clang or gcc). You need to make sure you use emcc when building the 7zip project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants