VC驿站

 找回密码
 加入驿站

QQ登录

只需一步,快速开始

搜索
查看: 628|回复: 3

[分享] Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

[复制链接]
001
81_avatar_middle
最佳答案
1 
在线会员 发表于 2020-1-31 22:21:50 | 显示全部楼层 |阅读模式
本帖最后由 dark-f 于 2020-2-1 08:12 编辑

这个帖子,应该是我一次最辛苦的经历。为何是最辛苦的?请看我慢慢道来!关于高版本的SpiderMonkey使用静态库的问题,我所遇到的问题,就我现在所知(我所搜索到的,至今无人解决),还是首次有人解决(请允许我小得意一下,因此,关于静态库的使用,可以说这个帖子是全球首发)!!!

在上个帖子:利用 Win10 X64系统利用vs2015编写SpiderMonkey45的win32应用程序

我首先使用的静态库,然而却出现编译连接错误,然后我就改用动态库,顺利完成自己首次关于SpiderMonkey45在Win10系统vs2015上的应用。尽管实现了自己的第一次应用,但心中仍然遗憾,为什么静态库不能用?于是,从1月29日中午发完上面的帖子后,就一直在研究静态库的应用。

首先是上网搜索,用关键词spidermonkey与js_static。结果非常遗憾,尽管有很多人提出了无法使用静态库的问题,却无人有解决之道(因此,我敢说,在spidermonkey以双位数作为(SpiderMonkey17)版本后,此贴是第一个提出使用静态库嵌入c/c++应用的帖子)!

上面那个帖子,已经提到,当使用静态库时,出现连接错误

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

那个静态库是当时编译生成动态库时,在工作目录下的js/src目录里存在的,而不是使用../configure --disable-shared-js构建命令生成的,因此,在这个静态库使用不成功的情况下,首先想到是使用../configure --disable-shared-js构建命令再生成一次。于是着手重新编译SpiderMonkey45,但是,使用vs2015却出现无法构建的情况

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

原来,在上次编译完45版本之后,我又接着编译了59版本,而59版本需要更高的windows SDK版本,当时就安装了win10最新的10.0.18362.0的sdk。在未安装该sdk之前,是可以用vs2015来编译45版的,但在安装之后,再用vs2015编译时,却说sdk不在路径上了,这说明高于win8.1的sdk版本不适合spidermonkey45的。但是vs2013的原始版本c1编译器的版本又不满足45版的编译要求的,没法子,只好再安装vs2013的update5(实际上,我是先安装的update4,也是可以的,但update4的体积比update5的还大,因此,我就保留了update5)。

安装好vs2013update5后,再用Mozilla-build2.2.0的vs2013来编译spidermonkey45,这次使用../configure --disable-shared-js构建命令直接得到静态库(这个是不生成动态库的,实际上,直接用../configure构建命令是既可以生成动态库又有静态库的,虽然这个静态库与带参数命令生成的静态库,在大小上有一点区别,但效用是一样的)。

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

得到这样编译的静态库后,还是用上个帖子里的例子(test),只是这次改成vs2013平台而已,结果与在vs2015中应用的情况是一样的,出现的连接错误有100多个。

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

从上图中可以看出,这些错误,不是Mozilla的函数调用问题,而是PR开头的函数,这是什么?用unresolved external symbol __imp__PR_ NewLock作为关键词去网络搜索,也没有结果。这个问题困扰我的时间很长,从29日中午一直到今天中午,这中间做了无数种尝试,都是无功而返的。于是,我又去D2BS的网站上去看看以前的版本(就是随便逛逛),没想到在其中一个更新spidermonkey版本的文件中看到了一个修改是link设置中的input里添加了nspr4.lib。一看到这个,我立即联想到那个PR_NewLock,也许就是要带上这个动态库。立即打开vs2013,将nspr4.lib添加进去。

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

再编译,果然,PR_NewLock的问题解决了。这是非常关键的一环,这个问题的解决,为后面解决mozglue的问题,提供了解决问题的思路,这是后话。

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

上图红圈中的三个错误,又困扰了我。但是,图中的数字56,在上个帖子编译完成后运行test时,是需要三个icuXX56.dll文件的,难道这个56与那个56是有联系的吗?于是,我再次编译spidermonkey45,这次仔细观察构建的内容,而不是只看能否构建成功,果然,功夫没有白费,很快就看到了构建时的这些信息

  1. intl\icu\target> configure: creating cache e:/spider/mozjs-45.0.2/js/src/build_OPT.OBJ/intl/icu/target/config.cache
  2. intl\icu\target> checking for ICU version numbers... release 56.1, library 56.1, unicode version 8.0
  3. intl\icu\target> checking build system type... i686-pc-mingw32
  4. intl\icu\target> checking host system type... i686-pc-mingw32
  5. intl\icu\target> checking whether to build debug libraries... no
  6. intl\icu\target> checking whether to build release libraries... yes
  7. intl\icu\target> checking for i686-pc-mingw32-clang... cl
  8. intl\icu\target> checking whether the C compiler works... yes
  9. intl\icu\target> checking for C compiler default output file name... conftest.exe
  10. intl\icu\target> checking for suffix of executables... .exe
  11. intl\icu\target> checking whether we are cross compiling... no
  12. intl\icu\target> checking for suffix of object files... obj
  13. intl\icu\target> checking whether we are using the GNU C compiler... no
  14. intl\icu\target> checking whether cl accepts -g... yes
  15. intl\icu\target> checking for cl option to accept ISO C89... none needed
  16. intl\icu\target> checking whether we are using the GNU C++ compiler... no
  17. intl\icu\target> checking whether cl accepts -g... yes
  18. intl\icu\target> checking for i686-pc-mingw32-pkg-config... no
  19. intl\icu\target> checking for pkg-config... no
  20. intl\icu\target> checking for ICULEHB... no
  21. intl\icu\target> checking how to run the C preprocessor... cl -E
  22. intl\icu\target> checking for a BSD-compatible install... /usr/bin/install -c
  23. intl\icu\target> checking for gmake... no
  24. intl\icu\target> checking for gnumake... no
  25. intl\icu\target> checking for doxygen... no
  26. intl\icu\target> checking checking for executable suffix... .exe
  27. intl\icu\target> checking whether strict compiling is on... no
  28. intl\icu\target> checking for grep that handles long lines and -e... /usr/bin/grep
  29. intl\icu\target> checking for egrep... /usr/bin/grep -E
  30. intl\icu\target> checking for ANSI C header files... yes
  31. intl\icu\target> checking for sys/types.h... yes
  32. intl\icu\target> checking for sys/stat.h... yes
  33. intl\icu\target> checking for stdlib.h... yes
  34. intl\icu\target> checking for string.h... yes
  35. intl\icu\target> checking for memory.h... yes
  36. intl\icu\target> checking for strings.h... no
  37. intl\icu\target> checking for inttypes.h... yes
  38. intl\icu\target> checking for stdint.h... yes
  39. intl\icu\target> checking for unistd.h... no
  40. intl\icu\target> checking size of void *... 4
  41. intl\icu\target> checking whether runnable 64 bit binaries are built by default... no
  42. intl\icu\target> checking which Makefile fragment to use for i686-pc-mingw32... mh-msys-msvc
  43. intl\icu\target> checking for floor in -lm... no
  44. intl\icu\target> checking whether to build shared libraries... yes
  45. intl\icu\target> checking whether to build static libraries... no
  46. intl\icu\target> checking whether to enable auto cleanup of libraries... no
  47. intl\icu\target> checking whether to enable draft APIs... yes
  48. intl\icu\target> checking for i686-pc-mingw32-ranlib... echo not_ranlib
  49. intl\icu\target> checking for i686-pc-mingw32-ar... lib
  50. intl\icu\target> checking whether to enable renaming of symbols... yes
  51. intl\icu\target> checking whether to enable function and data tracing... no
  52. intl\icu\target> checking elf.h usability... no
  53. intl\icu\target> checking elf.h presence... no
  54. intl\icu\target> checking for elf.h... no
  55. intl\icu\target> checking whether to enable dynamic loading of plugins. Ignored if plugins disabled.... yes
  56. intl\icu\target> checking dlfcn.h usability... no
  57. intl\icu\target> checking dlfcn.h presence... no
  58. intl\icu\target> checking for dlfcn.h... no
  59. intl\icu\target> checking for library containing dlopen... no
  60. intl\icu\target> checking for dlopen... no
  61. intl\icu\target> checking for gettimeofday... no
  62. intl\icu\target> checking if we have a C++ compiler... Good
  63. intl\icu\target> checking if #include <string> works... yes
  64. intl\icu\target> checking if #include <atomic> works... yes
  65. intl\icu\target> checking for pthread_attr_init in -lpthread... no
  66. intl\icu\target> checking for library containing pthread_mutex_destroy... no
  67. intl\icu\target> checking for pthread_mutex_init in -lpthread... no
  68. intl\icu\target> checking for pthread_mutex_lock... no
  69. intl\icu\target> checking for mmap... no
  70. intl\icu\target> checking for genccode assembly...
  71. intl\icu\target> checking for inttypes.h... (cached) yes
  72. intl\icu\target> checking dirent.h usability... no
  73. intl\icu\target> checking dirent.h presence... no
  74. intl\icu\target> checking for dirent.h... no
  75. intl\icu\target> checking whether byte ordering is bigendian... no
  76. intl\icu\target> checking for nl_langinfo... no
  77. intl\icu\target> checking for namespace support... yes
  78. intl\icu\target> checking for properly overriding new and delete... yes
  79. intl\icu\target> checking for placement new and delete... yes
  80. intl\icu\target> checking for popen... no
  81. intl\icu\target> checking for tzset... yes
  82. intl\icu\target> checking for tzname... yes
  83. intl\icu\target> checking for timezone... yes
  84. intl\icu\target> checking for int8_t... yes
  85. intl\icu\target> checking for uint8_t... yes
  86. intl\icu\target> checking for int16_t... yes
  87. intl\icu\target> checking for uint16_t... yes
  88. intl\icu\target> checking for int32_t... yes
  89. intl\icu\target> checking for uint32_t... yes
  90. intl\icu\target> checking for int64_t... yes
  91. intl\icu\target> checking for uint64_t... yes
  92. intl\icu\target> checking wchar.h usability... yes
  93. intl\icu\target> checking wchar.h presence... yes
  94. intl\icu\target> checking for wchar.h... yes
  95. intl\icu\target> checking for library containing wcscpy... no
  96. intl\icu\target> checking size of wchar_t... 2
  97. intl\icu\target> checking for UTF-16 string literal support... unknown
  98. intl\icu\target> checking for a library suffix to use... none
  99. intl\icu\target> CPPFLAGS= -DU_USING_ICU_NAMESPACE=0 -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1 -DUCONFIG_NO_LEGACY_CONVERSION -DUCONFIG_NO_TRANSLITERATION -DUCONFIG_NO_REGULAR_EXPRESSIONS -DUCONFIG_NO_BREAK_ITERATION -DU_CHARSET_IS_UTF8 -Ie:/spider/mozjs-45.0.2/intl/icu/source/common -Ie:/spider/mozjs-45.0.2/intl/icu/source/i18n  $(THREADSCPPFLAGS)  -DHAVE_DLOPEN=0 -DU_HAVE_ATOMIC=1 -DU_HAVE_MMAP=0 -DU_HAVE_DIRENT_H=0 -DU_HAVE_POPEN=0 -DU_HAVE_WCSCPY=0
  100. intl\icu\target> CFLAGS= -TC -nologo -wd4819 -D_HAS_EXCEPTIONS=0 -W3 -Gy -arch:IA32 -FS -wd4244 -wd4267 -we4553 -Zi -UDEBUG -DNDEBUG -O2 -MD $(THREADSCFLAGS)
  101. intl\icu\target> CXXFLAGS=-TP -nologo -wd4345 -wd4351 -wd4800 -wd4819 -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -W3 -Gy -arch:IA32 -FS -wd4244 -wd4267 -wd4251 -we4553 -GR -Zi -UDEBUG -DNDEBUG -O2 -MD $(THREADSCXXFLAGS)
  102. intl\icu\target> configure: updating cache e:/spider/mozjs-45.0.2/js/src/build_OPT.OBJ/intl/icu/target/config.cache
  103. intl\icu\target> configure: creating ./config.status
  104. intl\icu\target>
  105. intl\icu\target> ICU for C/C++ 56.1 is ready to be built.
  106. intl\icu\target> === Important Notes: ===
  107. intl\icu\target> Data Packaging: library
  108. intl\icu\target>  This means: ICU data will be linked with ICU. A shared data library will be built.
  109. intl\icu\target>  To locate data: ICU will use the linked data library. If linked with the stub library located in stubdata/, the application can use udata_setCommonData() or set a data path to override.
  110. intl\icu\target> Building ICU: Use a GNU make such as make to build ICU.
  111. intl\icu\target> checking the version of "make"... 3.81.90 (we wanted at least 3.80)
  112. intl\icu\target> ok
  113. intl\icu\target> config.status: creating icudefs.mk
  114. intl\icu\target> config.status: creating Makefile
  115. intl\icu\target> config.status: creating data/pkgdataMakefile
  116. intl\icu\target> config.status: creating config/Makefile.inc
  117. intl\icu\target> config.status: creating config/icu.pc
  118. intl\icu\target> config.status: creating config/pkgdataMakefile
  119. intl\icu\target> config.status: creating data/Makefile
  120. intl\icu\target> config.status: creating stubdata/Makefile
  121. intl\icu\target> config.status: creating common/Makefile
  122. intl\icu\target> config.status: creating i18n/Makefile
  123. intl\icu\target> config.status: creating layout/Makefile
  124. intl\icu\target> config.status: creating layoutex/Makefile
  125. intl\icu\target> config.status: creating io/Makefile
  126. intl\icu\target> config.status: creating extra/Makefile
  127. intl\icu\target> config.status: creating extra/uconv/Makefile
  128. intl\icu\target> config.status: creating extra/uconv/pkgdataMakefile
  129. intl\icu\target> config.status: creating extra/scrptrun/Makefile
  130. intl\icu\target> config.status: creating tools/Makefile
  131. intl\icu\target> config.status: creating tools/ctestfw/Makefile
  132. intl\icu\target> config.status: creating tools/toolutil/Makefile
  133. intl\icu\target> config.status: creating tools/makeconv/Makefile
  134. intl\icu\target> config.status: creating tools/genrb/Makefile
  135. intl\icu\target> config.status: creating tools/genccode/Makefile
  136. intl\icu\target> config.status: creating tools/gencmn/Makefile
  137. intl\icu\target> config.status: creating tools/gencnval/Makefile
  138. intl\icu\target> config.status: creating tools/gendict/Makefile
  139. intl\icu\target> config.status: creating tools/gentest/Makefile
  140. intl\icu\target> config.status: creating tools/gennorm2/Makefile
  141. intl\icu\target> config.status: creating tools/genbrk/Makefile
  142. intl\icu\target> config.status: creating tools/gensprep/Makefile
  143. intl\icu\target> config.status: creating tools/icuinfo/Makefile
  144. intl\icu\target> config.status: creating tools/icupkg/Makefile
  145. intl\icu\target> config.status: creating tools/icuswap/Makefile
  146. intl\icu\target> config.status: creating tools/pkgdata/Makefile
  147. intl\icu\target> config.status: creating tools/tzcode/Makefile
  148. intl\icu\target> config.status: creating tools/gencfu/Makefile
  149. intl\icu\target> config.status: creating test/Makefile
  150. intl\icu\target> config.status: creating test/compat/Makefile
  151. intl\icu\target> config.status: creating test/testdata/Makefile
  152. intl\icu\target> config.status: creating test/testdata/pkgdataMakefile
  153. intl\icu\target> config.status: creating test/hdrtst/Makefile
  154. intl\icu\target> config.status: creating test/intltest/Makefile
  155. intl\icu\target> config.status: creating test/cintltst/Makefile
  156. intl\icu\target> config.status: creating test/iotest/Makefile
  157. intl\icu\target> config.status: creating test/letest/Makefile
  158. intl\icu\target> config.status: creating test/perf/Makefile
  159. intl\icu\target> config.status: creating test/perf/collationperf/Makefile
  160. intl\icu\target> config.status: creating test/perf/collperf/Makefile
  161. intl\icu\target> config.status: creating test/perf/collperf2/Makefile
  162. intl\icu\target> config.status: creating test/perf/dicttrieperf/Makefile
  163. intl\icu\target> config.status: creating test/perf/ubrkperf/Makefile
  164. intl\icu\target> config.status: creating test/perf/charperf/Makefile
  165. intl\icu\target> config.status: creating test/perf/convperf/Makefile
  166. intl\icu\target> config.status: creating test/perf/normperf/Makefile
  167. intl\icu\target> config.status: creating test/perf/DateFmtPerf/Makefile
  168. intl\icu\target> config.status: creating test/perf/howExpensiveIs/Makefile
  169. intl\icu\target> config.status: creating test/perf/strsrchperf/Makefile
  170. intl\icu\target> config.status: creating test/perf/unisetperf/Makefile
  171. intl\icu\target> config.status: creating test/perf/usetperf/Makefile
  172. intl\icu\target> config.status: creating test/perf/ustrperf/Makefile
  173. intl\icu\target> config.status: creating test/perf/utfperf/Makefile
  174. intl\icu\target> config.status: creating test/perf/utrie2perf/Makefile
  175. intl\icu\target> config.status: creating test/perf/leperf/Makefile
  176. intl\icu\target> config.status: creating samples/Makefile
  177. intl\icu\target> config.status: creating samples/date/Makefile
  178. intl\icu\target> config.status: creating samples/cal/Makefile
  179. intl\icu\target> config.status: creating samples/layout/Makefile
复制代码


上面这些信息中,有一个重要提示

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

提示说明,icu是不能建成静态库的,只能使用ICU的共享库。注意到这个提示后,我就去追查icu的configure设置,结果看到下图的信息

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

说是--enbale-static的默认设置是no。那么这个参数要怎么使用呢?能否改成yes呢?不得已,只好打开configure的帮助,configure的帮助信息如下:

  1. $ ../configure --help
  2. Usage: configure [options] [host]
  3. Options: [defaults in brackets after descriptions]
  4. Configuration:
  5.   --cache-file=FILE       cache test results in FILE
  6.   --help                  print this message
  7.   --no-create             do not create output files
  8.   --quiet, --silent       do not print `checking...' messages
  9.   --version               print the version of autoconf that created configure
  10. Directory and file names:
  11.   --prefix=PREFIX         install architecture-independent files in PREFIX
  12.                           [/usr/local]
  13.   --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
  14.                           [same as prefix]
  15.   --bindir=DIR            user executables in DIR [EPREFIX/bin]
  16.   --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
  17.   --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
  18.   --datadir=DIR           read-only architecture-independent data in DIR
  19.                           [PREFIX/share]
  20.   --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
  21.   --sharedstatedir=DIR    modifiable architecture-independent data in DIR
  22.                           [PREFIX/com]
  23.   --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
  24.   --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
  25.   --includedir=DIR        C header files in DIR [PREFIX/include]
  26.   --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
  27.   --infodir=DIR           info documentation in DIR [PREFIX/info]
  28.   --mandir=DIR            man documentation in DIR [PREFIX/man]
  29.   --srcdir=DIR            find the sources in DIR [configure dir or ..]
  30.   --program-prefix=PREFIX prepend PREFIX to installed program names
  31.   --program-suffix=SUFFIX append SUFFIX to installed program names
  32.   --program-transform-name=PROGRAM
  33.                           run sed PROGRAM on installed program names
  34. Host type:
  35.   --build=BUILD           configure for building on BUILD [BUILD=HOST]
  36.   --host=HOST             configure for HOST [guessed]
  37.   --target=TARGET         configure for TARGET [TARGET=HOST]
  38. Features and packages:
  39.   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  40.   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  41.   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  42.   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  43.   --x-includes=DIR        X include files are in DIR
  44.   --x-libraries=DIR       X library files are in DIR
  45. --enable and --with options recognized:
  46.   --enable-build-backend={AndroidEclipse,CppEclipse,VisualStudio,FasterMake,CompileDB}
  47.                          Enable additional build backends
  48.   --enable-release        Build with more conservative, release engineering-oriented options.
  49.                           This may slow down builds.
  50.   --disable-compile-environment
  51.                           Disable compiler/library checks.
  52.   --disable-shared-js
  53.                           Do not create a shared library.
  54.   --disable-export-js
  55.                           Do not mark JS symbols as DLL exported/visible.
  56.   --with-gonk=DIR
  57.                location of gonk dir
  58.   --with-gonk-toolchain-prefix=DIR
  59.                           prefix to gonk toolchain commands
  60.   --with-android-ndk=DIR
  61.                           location where the Android NDK can be found
  62.   --with-android-toolchain=DIR
  63.                           location of the Android toolchain
  64.   --with-android-gnu-compiler-version=VER
  65.                           gnu compiler version to use
  66.   --with-android-cxx-stl=VALUE
  67.                           use the specified C++ STL (stlport, libstdc++, libc++)
  68.   --with-android-version=VER
  69.                           android platform version, default 9
  70.   --with-ios-sdk=TYPE
  71.                           Type of iOS SDK to use (iphonesimulator, iphoneos)
  72.                           and optionally version (like iphoneos8.2)
  73.   --enable-ios-target=VER (default=8.0)
  74.                           Set the minimum iOS version needed at runtime
  75.   --with-compiler-wrapper[=path/to/wrapper]
  76.     Enable compiling with wrappers such as distcc and ccache
  77.   --with-ccache[=path/to/ccache]
  78.                           Enable compiling with ccache
  79.   --enable-rust           Include Rust language sources
  80.   --with-windows-version=WINSDK_TARGETVER
  81.                           Windows SDK version to target. Win8.1 (603) is
  82.                           currently the minimum supported version.
  83.   --enable-macos-target=VER (default=10.6)
  84.                           Set the minimum MacOS version needed at runtime
  85.   --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)
  86.   --with-x                use the X Window System
  87.   --with-arch=[[type|toolchain-default]]
  88.                            Use specific CPU features (-march=type). Resets
  89.                            thumb, fpu, float-abi, etc. defaults when set
  90.   --with-thumb[[=yes|no|toolchain-default]]
  91.                           Use Thumb instruction set (-mthumb)
  92.   --with-thumb-interwork[[=yes|no|toolchain-default]]
  93.                            Use Thumb/ARM instuctions interwork (-mthumb-interwork)
  94.   --with-fpu=[[type|toolchain-default]]
  95.                            Use specific FPU type (-mfpu=type)
  96.   --with-float-abi=[[type|toolchain-default]]
  97.                            Use specific arm float ABI (-mfloat-abi=type)
  98.   --with-soft-float[[=yes|no|toolchain-default]]
  99.                            Use soft float library (-msoft-float)
  100.   --enable-address-sanitizer       Enable Address Sanitizer (default=no)
  101.   --enable-memory-sanitizer       Enable Memory Sanitizer (default=no)
  102.   --enable-thread-sanitizer       Enable Thread Sanitizer (default=no)
  103.   --enable-llvm-hacks       Enable workarounds required for several LLVM instrumentations (default=no)
  104.   --enable-warnings-as-errors
  105.                           Enable treating warnings as errors
  106.   --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)
  107.   --disable-ion      Disable use of the IonMonkey JIT
  108.   --enable-debug[=DBG]    Enable building with developer debug info
  109.                            (using compiler flags DBG)
  110.   --with-debug-label=LABELS
  111.                           Define DEBUG_<value> for each comma-separated
  112.                           value given.
  113.   --enable-debug-symbols[=DBG]
  114.                           Enable debugging symbols (using compiler flags DBG)
  115.   --enable-cpp-rtti       Enable C++ RTTI
  116.   --enable-gold           Enable GNU Gold Linker when it is not already the default
  117.   --disable-icf          Disable Identical Code Folding
  118.   --enable-pie           Enable Position Independent Executables
  119.   --enable-dtrace         build with dtrace support if available (default=no)
  120.   --with-linux-headers=DIR
  121.                           location where the Linux kernel headers can be found
  122.   --with-pthreads         Force use of system pthread library with NSPR
  123.   --enable-update-channel=CHANNEL
  124.                           Select application update channel (default=default)
  125.   --with-nspr-cflags=FLAGS
  126.                           Pass FLAGS to CC when building code that uses NSPR.
  127.                           Use this when there's no accurate nspr-config
  128.                           script available.  This is the case when building
  129.                           SpiderMonkey as part of the Mozilla tree: the
  130.                           top-level configure script computes NSPR flags
  131.                           that accomodate the quirks of that environment.
  132.   --with-nspr-libs=LIBS   Pass LIBS to LD when linking code that uses NSPR.
  133.                           See --with-nspr-cflags for more details.
  134.   --enable-nspr-build     Configure and build NSPR from source tree
  135.   --with-system-nspr      Use an NSPR that is already built and installed.
  136.                           Use the 'nspr-config' script in the current path,
  137.                           or look for the script in the directories given with
  138.                           --with-nspr-exec-prefix or --with-nspr-prefix.
  139.                           (Those flags are only checked if you specify
  140.                           --with-system-nspr.)
  141.   --enable-posix-nspr-emulation
  142.                           Enable emulation of NSPR for POSIX systems
  143.   --with-nspr-prefix=PFX  Prefix where NSPR is installed
  144.   --with-nspr-exec-prefix=PFX
  145.                           Exec prefix where NSPR is installed
  146.   --with-system-zlib[=PFX]
  147.                           Use system libz [installed at prefix PFX]
  148.   --enable-system-ffi       Use system libffi (located with pkgconfig)
  149.   --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)
  150.   --enable-ui-locale=ab-CD
  151.                           Select the user interface locale (default: en-US)
  152.   --disable-tests         Do not build test libraries & programs
  153.   --disable-optimize      Disable compiler optimization
  154.   --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]
  155.   --disable-trace-logging   Disable trace logging
  156.   --enable-dmd            Enable DMD; also enables jemalloc and replace-malloc
  157.   --disable-jemalloc       Don't replace memory allocator with jemalloc
  158.   --enable-wrap-malloc    Wrap malloc calls (gnu linker only)
  159.   --with-wrap-malloc=DIR  Location of malloc wrapper library
  160.   --enable-small-chunk-size  Allocate memory for JS GC things in smaller chunks
  161.   --enable-gc-trace  Enable tracing of allocation and finalization
  162.   --enable-valgrind       Enable Valgrind integration hooks (default=no)
  163.   --enable-simulator=ARCH
  164.                           Enable a JIT code simulator for the specified arch.
  165.                           (arm, arm64, mips32, mips64).
  166.   --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.
  167.   --enable-instruments    Enable instruments remote profiling. Implies --enable-profiling.
  168.   --enable-callgrind      Enable callgrind profiling. Implies --enable-profiling.
  169.   --enable-vtune          Enable vtune profiling. Implies --enable-profiling.
  170.   --enable-jitspew        Enable the Jit spew and IONFLAGS.
  171.   --enable-gczeal         Enable zealous GCing
  172.   --enable-perf           Enable Linux perf integration
  173.   --enable-more-deterministic
  174.                           Enable changes that make the shell more deterministic
  175.   --enable-oom-breakpoint
  176.                           Enable a breakpoint function for artificial OOMs
  177.   --enable-clang-plugin   Enable building with the mozilla clang plugin
  178.   --with-sixgill=path/to/sixgill
  179.                           Enable static checking of code using sixgill
  180.   --enable-strip          Enable stripping of libs & executables
  181.   --enable-install-strip  Enable stripping of libs & executables when packaging
  182.   --jitreport-granularity=N
  183.                            Default granularity at which to report JIT code
  184.                            to external tools
  185.                              0 - no info
  186.                              1 - code ranges for whole functions only
  187.                              2 - per-line information
  188.                              3 - per-op information
  189.   --enable-xterm-updates  Update XTERM titles with current command.
  190.   --enable-readline       Link js shell to system readline library
  191.   --enable-ctypes         Enable js-ctypes (default=no)
  192.   --with-qemu-exe=path   Use path as an arm emulator on host platforms
  193.   --with-cross-lib=dir   Use dir as the location for arm libraries
  194.   --with-system-icu
  195.                           Use system ICU (located with pkgconfig)
  196.   --with-intl-api, --with-intl-api=build, --without-intl-api
  197.     Determine the status of the ECMAScript Internationalization API.  The first
  198.     (or lack of any of these) builds and exposes the API.  The second builds it
  199.     but doesn't use ICU or expose the API to script.  The third doesn't build
  200.     ICU at all.
复制代码


从上面的最后部分可以看到,关于ICU的设置,有三种参数附带:第一种就是默认的,第二种自然也没有--enable-static的设置,没法子,只好选择第三种,完全不建立ICU了。于是,再次编译spidermonkey45,这次采用../configure --disable-shared-js --without-intl-api来构建。用这样建立的静态库,果然那三个与56有关的连接错误没有了。

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

而上图中与time有关的连接问题,fiefox在他的帖子中已经解决过了,只要将Winmm.lib添加进去即可。

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

然后,GetProcessMemory的问题

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

在网络上搜索一下就有很多,解决方法是添加Psapi.lib,同样将其添加进去。

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

然后,就剩下最后的6个错误了。这个错误的解决,是受到nspr4.lib和icu56的解决方法的启发,因为在动态库应用例子里,最后运行test时,提示需要mozglue这个库,这里自然就想到可能与这个库有关,于是将这个库也添加进去

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

至此,所有问题全部解决,编译成功(警告就不管了)

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

测试下,同样在windows中run-cmd命令切换到test所在目录,运行test,出现没有两个库的提示(因为这2个是连接的动态库,所以运行时要带上的)

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

最后,把宏设置的情况也展示一下,红圈中的三个宏是添加上去的,其他的是vs2013自带的。

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

前两个宏,在上个帖子里已经有介绍了,至于第三个宏,在include目录里的jstypes.h文件里有说明:

Win10_vs2013嵌入SpiderMonkey45静态库(js_static.lib)的程序编译过程

完帖,希望有朋友喜欢这个帖子!

评分

参与人数 2威望 +2 驿站币 +4 热心值 +4 收起 理由
77_avatar_small Health + 2 + 2 很给力!
01_avatar_small admin + 2 + 2 + 2 支持原创!

查看全部评分





上一篇:Win10 X64系统利用vs2015编写SpiderMonkey45的win32应用程序
下一篇:WinInet发送或接收函数超时的Bug &amp; 解决办法
01_avatar_middle
最佳答案
39 
online_admins 发表于 2020-2-1 00:51:55 | 显示全部楼层
支持原创!好东西,有技术含量
38_avatar_middle
最佳答案
0 
在线会员 发表于 2020-2-1 08:35:53 来自手机 | 显示全部楼层
不错,我也在学vc
77_avatar_middle
最佳答案
31 
online_vip 发表于 2020-2-2 17:42:49 | 显示全部楼层
支持啊,只要功夫深铁杵磨成针,我也要加油了
您需要登录后才可以回帖 登录 | 加入驿站 qq_login

本版积分规则

×【发帖 友情提示】
1、请回复有意义的内容,请勿恶意灌水;
2、纯数字、字母、表情等无意义的内容系统将自动删除;
3、若正常回复后帖子被自动删除,为系统误删的情况,请重新回复其他正常内容或等待管理员审核通过后会自动发布;
4、感谢您对VC驿站一如既往的支持,谢谢合作!

关闭

站长提醒上一条 /2 下一条

QQ|小黑屋|手机版|VC驿站 ( 辽ICP备09019393号 )|网站地图wx_jqr

GMT+8, 2020-10-26 02:43

Powered by CcTry.CoM

© 2009-2020 cctry.com

快速回复 返回顶部 返回列表