Skip to content

Link errors when compiling cpp file with emcc -s USE_BOOST_HEADERS=1 in Windows #3

@twopelu

Description

@twopelu

I'm trying to compile a cpp file to make some tests with the Boost library port for Emscripten in C++ but I get link errors when trying to compile it in Windows with the emcc command.

I think I'm missing some includes or links but I can't find the way to make it work and I can't find any documentation except the Emcscripten guide:

https://emscripten.org/docs/compiling/Building-Projects.html#emscripten-ports

https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-link-against-system-libraries-like-sdl-boost-etc

I have seen other posts with solutions for cmake but for for plain emcc in Windows.

Code

https://www.boost.org/doc/libs/1_48_0/libs/locale/doc/html/hello_8cpp-example.html

Emcc

emcc boost_suite.cpp -s USE_BOOST_HEADERS=1 -s LLD_REPORT_UNDEFINED -o target/boost_suite.html

Errors

 D:\DANI\wasm\boostsuite>emcc boost_suite.cpp -s USE_BOOST_HEADERS=1 -s LLD_REPORT_UNDEFINED -o target/boost_suite.html
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::generator::generator()
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::generator::~generator()
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::generator::generate(std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> > const&) const
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::ios_info::get(std::__2::ios_base&)
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::ios_info::display_flags(unsigned long long)
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::ios_info::get(std::__2::ios_base&)
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::ios_info::display_flags(unsigned long long)
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::ios_info::get(std::__2::ios_base&)
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::ios_info::display_flags(unsigned long long)
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::ios_info::get(std::__2::ios_base&)
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::ios_info::display_flags(unsigned long long)
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::ios_info::get(std::__2::ios_base&)
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::ios_info::domain_id() const
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::converter<char>::id
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::details::format_parser::format_parser(std::__2::ios_base&, void*, void (*)(void*, std::__2::locale const&))
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::details::format_parser::set_one_flag(std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> > const&, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> > const&)
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::details::format_parser::get_position()
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::details::format_parser::~format_parser()
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::ios_info::get(std::__2::ios_base&)
    wasm-ld: error: C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o: undefined symbol: boost::locale::details::format_parser::restore()
    wasm-ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
    emcc: error: 'D:/DANI/wasm/emsdk/upstream/bin\wasm-ld.exe -o target/boost_suite.wasm C:\Users\dani\AppData\Local\Temp\emscripten_temp_7wl1l58q\boost_suite_0.o -LD:\DANI\wasm\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten D:\DANI\wasm\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libboost_headers.a D:\DANI\wasm\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libgl.a D:\DANI\wasm\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libal.a D:\DANI\wasm\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libhtml5.a D:\DANI\wasm\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libc.a D:\DANI\wasm\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libcompiler_rt.a D:\DANI\wasm\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libc++-noexcept.a D:\DANI\wasm\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libc++abi-noexcept.a D:\DANI\wasm\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libdlmalloc.a D:\DANI\wasm\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libc_rt_wasm.a D:\DANI\wasm\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libsockets.a -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined-file=C:\Users\dani\AppData\Local\Temp\tmp2cj831u_.undefined --strip-debug --export main --export emscripten_stack_get_end --export emscripten_stack_get_free --export emscripten_stack_init --export stackSave --export stackRestore --export stackAlloc --export __wasm_call_ctors --export fflush --export __errno_location --export malloc --export free --export setThrew --export-table -z stack-size=5242880 --initial-memory=16777216 --entry=main --max-memory=16777216 --global-base=1024' failed (1)
(both examples taken from the official documentation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions