我用c ++编写了一个程序,但是需要把它变成javascript才能在iPad上运行。唯一的问题是我的程序使用CImg。这是编译命令
em++ -std=c++11 -Wall -L./lib -lX11 -ljpeg -lpng -I./include -I./include/include main.cpp obj/object1.o obj/object2.o -o bin/executable.js
./include
包含我的程序头文件,./include/include
包含运行CImg所需的/opt/X11/include
中的所有文件。我收到以下错误:
warning: unresolved symbol: XUnlockDisplay
warning: unresolved symbol: XMoveWindow
warning: unresolved symbol: png_read_info
warning: unresolved symbol: XWindowEvent
warning: unresolved symbol: XFreeColormap
warning: unresolved symbol: XAllocClassHint
warning: unresolved symbol: XCreatePixmapCursor
warning: unresolved symbol: png_set_sig_bytes
warning: unresolved symbol: XGetWindowAttributes
warning: unresolved symbol: pthread_testcancel
warning: unresolved symbol: XSync
warning: unresolved symbol: jpeg_start_decompress
warning: unresolved symbol: jpeg_CreateDecompress
warning: unresolved symbol: jpeg_stdio_src
warning: unresolved symbol: XQueryKeymap
warning: unresolved symbol: png_create_write_struct
warning: unresolved symbol: jpeg_destroy
warning: unresolved symbol: png_read_end
warning: unresolved symbol: XCreateImage
warning: unresolved symbol: png_write_image
warning: unresolved symbol: XSetWindowColormap
warning: unresolved symbol: pthread_cancel
warning: unresolved symbol: XGrabKeyboard
warning: unresolved symbol: png_read_image
warning: unresolved symbol: XSetWMProtocols
warning: unresolved symbol: png_write_end
warning: unresolved symbol: png_set_gray_to_rgb
warning: unresolved symbol: XCheckTypedEvent
warning: unresolved symbol: png_init_io
warning: unresolved symbol: XFree
warning: unresolved symbol: png_set_filler
warning: unresolved symbol: XUnmapWindow
warning: unresolved symbol: png_set_longjmp_fn
warning: unresolved symbol: XCreateSimpleWindow
warning: unresolved symbol: XMapRaised
warning: unresolved symbol: XCloseDisplay
warning: unresolved symbol: XLockDisplay
warning: unresolved symbol: png_create_info_struct
warning: unresolved symbol: png_set_IHDR
warning: unresolved symbol: jpeg_write_scanlines
warning: unresolved symbol: XSelectInput
warning: unresolved symbol: jpeg_finish_compress
warning: unresolved symbol: XPutImage
warning: unresolved symbol: XCheckWindowEvent
warning: unresolved symbol: XUndefineCursor
warning: unresolved symbol: XVisualIDFromVisual
warning: unresolved symbol: jpeg_set_quality
warning: unresolved symbol: jpeg_CreateCompress
warning: unresolved symbol: XFreePixmap
warning: unresolved symbol: XCreateBitmapFromData
warning: unresolved symbol: pthread_create
warning: unresolved symbol: XStoreColors
warning: unresolved symbol: XInitThreads
warning: unresolved symbol: XLookupString
warning: unresolved symbol: png_get_valid
warning: unresolved symbol: jpeg_read_header
warning: unresolved symbol: jpeg_stdio_dest
warning: unresolved symbol: XSetInputFocus
warning: unresolved symbol: jpeg_std_error
warning: unresolved symbol: jpeg_destroy_decompress
warning: unresolved symbol: png_set_palette_to_rgb
warning: unresolved symbol: png_create_read_struct
warning: unresolved symbol: pthread_setcanceltype
warning: unresolved symbol: png_read_update_info
warning: unresolved symbol: jpeg_set_defaults
warning: unresolved symbol: png_set_expand_gray_1_2_4_to_8
warning: unresolved symbol: jpeg_read_scanlines
warning: unresolved symbol: jpeg_start_compress
warning: unresolved symbol: png_destroy_read_struct
warning: unresolved symbol: XResizeWindow
warning: unresolved symbol: png_get_IHDR
warning: unresolved symbol: jpeg_destroy_compress
warning: unresolved symbol: XCheckMaskEvent
warning: unresolved symbol: XCreateColormap
warning: unresolved symbol: XGetVisualInfo
warning: unresolved symbol: pthread_setcancelstate
warning: unresolved symbol: XDestroyWindow
warning: unresolved symbol: png_write_info
warning: unresolved symbol: XDefineCursor
warning: unresolved symbol: XUngrabKeyboard
warning: unresolved symbol: XSetClassHint
warning: unresolved symbol: png_set_tRNS_to_alpha
warning: unresolved symbol: jpeg_finish_decompress
warning: unresolved symbol: png_sig_cmp
warning: unresolved symbol: png_destroy_write_struct
warning: unresolved symbol: _ZTVSt9exception
我很确定它与链接库有关。但我不知道在通过Emscripten转换时是否可以使用CImg。
答案 0 :(得分:0)
任何可移植的C或C ++代码库都应该有效。但是您确实需要移植所有依赖项。看起来该应用程序使用Xlib和libpng,基于这些警告。您可能需要将X内容移植到emscripten已经支持的内容,例如SDL。对于png,周围有几个端口(或者你可以自己编译),例如: https://github.com/hachque-Emscripten/libpng-1.2.49
答案 1 :(得分:0)
如果您不需要CImg的X11功能(基本上,如果您不想在CImgDisplay窗口中显示图像),那么您可以通过在编译时定义宏cimg_display=0
来禁用它基于CImg的代码。