emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
2.98k stars 681 forks source link

wasm-ld: error: unknown file type: .\src\file.obj #879

Open PowerNow opened 3 years ago

PowerNow commented 3 years ago

Hi, I want to use 'gifsicle-wasm' on Win10 using nmake with a makefile.w32 for compiling and emcc for linking, but for all generated .obj files I get this error: wasm-ld: error: unknown file type: .\src\file.obj

emcc .\src\clp.obj .\src\fmalloc.obj .\src\giffunc.obj .\src\gifread.obj .\src\gifunopt.obj .\src\merge.obj .\src\optimize.obj .\src\quantize.obj .\src\support.obj .\src\xform.obj .\src\gifsicle.obj .\src\gifwrite.obj --pre-fs .\pre.js -s MODULARIZE=1 -s EXPORT_NAME=Gifsicle -s ALLOW_MEMORY_GROWTH=1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -o gs.html

What am I doing wrong here?

sbc100 commented 3 years ago

You must use emcc for compiling too. The object file produced by other compilers cannot be consumed by emcc (wasm-ld) at link time.

PowerNow commented 3 years ago

I see and how can I call emmake with nmake? Because the 'Makefile.w32' is for nmake and not make...

sbc100 commented 3 years ago

You can try it. It really depends if the Makefile honors the CC/CXX/LD/etc environment variables. All emmake really does is set those to point the tools in the emscripten toolchain.

Alternatively you can edit the makefile to change the compiler. If the makefile is specifically designed for windows thought its unlikly that just overriding the tools will be enough, you make also need to update/remove any windows-specific compiler flags. It really depends how portable (or not) the software you are working with is. If it only works with nmake its likely is not portable software (since that tool is windows only).

PowerNow commented 3 years ago

As I know in make is gcc the compiler. For Windows there are make (for windows) and mingw32-make, both are using gcc. At 'gifsicle-wasm' on Github in the /src folder there are .am, .bcc, .mingw and .w32 Makefiles. But if I use mingw-make which creates .o files I'm getting the same error?

wasm-ld: error: unknown file type: .\src\file.o

emcc .\src\clp.o .\src\fmalloc.o .\src\giffunc.o .\src\gifread.o .\src\gifunopt.o .\src\merge.o .\src\optimize.o .\src\quantize.o .\src\support.o .\src\xform.o .\src\gifsicle.o .\src\gifwrite.o --pre-fs .\pre.js -s MODULARIZE=1 -s EXPORT_NAME=Gifsicle -s ALLOW_MEMORY_GROWTH=1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -o gs.html

And I'm wondering why 'gifsicle-wasm' mention to compile the .c files with nmake if can't use the .obj files afterwards with the wasm-id linker?

On the otherside they deliver a em-configure.sh and em-make.sh where they call emconfigure, emmake and emcc. So their building process is perpared for Linux. I just installed WSL2. Do I have to install the complete emsdk toolchain (Python,...) there or is it also possible to call the windows installations e.g. emsdk-main out from WSL2?

sbc100 commented 3 years ago

WSL2 would need a completely separate version of emsdk, you cannot use the windows version of emsdk.