On Wed, May 9, 2018, 6:28 AM zhatian diao <[email protected]> wrote:
> Hello everyone , I m new to emcc.
>
> Today I followed the user guide to install emcc and run the hello
> world example successfully.
>
Welcome! :)
> However, things went wrong when I tried to compile another c file to
> js file.
>
> At first, I got an error
>
> testfiles/getip.c:10:17: fatal error: 'linux/if_link.h' file not
> found
> #include <linux/if_link.h>
> ^~~~~~~~~~~~~~~~~
> 1 error generated.
> ERROR:root:compiler frontend failed to generate LLVM bitcode, halting
>
> The strange thing is that I compiled the c file early with gcc without
> error. It can be run successfully.
>
emscripten is not Linux, and does not include Linux-specific kernel
interfaces. Think of it as cross-compiling to another operating system...
If your source code needs linux/if_link.h for Linux-specific code, it will
need to be modified to build for emscripten.
Note that the networking support in emscripten is limited because the web
runtime limited what is possible; you can't look up IP addresses or connect
to arbitrary hosts or ports. Make sure your test program is something that
would actually work.
> So I changed my code and removed "<linux/if_link.h>". I got another
> compile warning: warning:unresolved symbol: htons.
>
It s source c code can also be compiled with gcc.
>
> Is there anything I missed or unconfigured?
>
>
>
>
> Compile enviroment : ubuntu
>
> head include:
>
> #include <arpa/inet.h>
> #include <sys/socket.h>
> #include <netdb.h>
> #include <ifaddrs.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <string.h>
> #include <linux/if_link.h>
>
htons is defined in arpa/inet.h which you're also including, so it should
work. Can you provide a minimal test case? (Small complete .c file that can
be compiled, and the command-line flags you're using to compile it)
-- brion
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.