我怀疑这是一个愚蠢的新手问题,但这是我自己无法回答的问题。
我想在Ubuntu 12.04 LTS(32位)上开发一个带有嵌入式javascript引擎的程序。我已经尝试下载SpiderMonkey,但无法解决如何链接它。所以,我已经下载了V8源代码,至少有一个带有Google Developers site链接指令的示例程序。
我已经下载了源代码并内置了/ some / path /或/ other / v8并将示例源代码放入v8Ex1(我原本希望快速移动到示例2,3和4 - 但到目前为止没有运气)在/ some / path /或/ other。
一旦我找到了针对32位而不是64位构建进行更改的内容,我就能够使用命令行构建并运行该示例
g++ -Iv8/include v8Ex1.cc -o v8Ex1 -Wl,--start-group v8/out/ia32.release/obj.target/{tools/gyp/libv8_{base.ia32,snapshot},third_party/icu/libicu{uc,i18n,data}}.a -Wl,--end-group -lrt
我的下一步是确定bash
如何扩展该命令行:
g++ -Iv8/include v8Ex1.cc -o v8Ex1 \
-Wl,--start-group v8/out/ia32.release/obj.target/tools/gyp/libv8_base.ia32.a \
v8/out/ia32.release/obj.target/tools/gyp/libv8_snapshot.a \
v8/out/ia32.release/obj.target/third_party/icu/libicuuc.a \
v8/out/ia32.release/obj.target/third_party/icu/libicui18n.a \
v8/out/ia32.release/obj.target/third_party/icu/libicudata.a \
-Wl,--end-group -lrt
此命令正常工作,构建可执行文件时不会产生任何错误或警告。
我预计我的程序中会有多个源文件,因此我最终会有几个目标文件,需要将它们链接在一起。
我的下一步是构建单独的编译器和链接器命令
g++ -c -Iv8/include v8Ex1.cc -o v8Ex1.o
编译程序就好了,但是我还没有弄清楚相应的链接器命令应该是什么。我最好的猜测是
ld -o v8Ex1 v8Ex1.o --start-group \
v8/out/ia32.release/obj.target/tools/gyp/libv8_base.ia32.a \
v8/out/ia32.release/obj.target/tools/gyp/libv8_snapshot.a \
v8/out/ia32.release/obj.target/third_party/icu/libicuuc.a \
v8/out/ia32.release/obj.target/third_party/icu/libicui18n.a \
v8/out/ia32.release/obj.target/third_party/icu/libicudata.a --end-group -lrt
但这给了我3257个错误,从下面开始:
/usr/bin/ld.bfd.real: warning: cannot find entry symbol _start; defaulting to 000000000804a2e0
v8Ex1.o: In function `main':
v8Ex1.cc:(.text+0x1ab): undefined reference to `_Unwind_Resume'
v8Ex1.o:(.eh_frame+0x4b): undefined reference to `__gxx_personality_v0'
v8/out/ia32.release/obj.target/v8_base.ia32/src/isolate.o: In function `v8::internal::DateCache::~DateCache()':
isolate.cc:(.text._ZN2v88internal9DateCacheD0Ev[_ZN2v88internal9DateCacheD5Ev]+0xb): undefined reference to `operator delete(void*)'
v8/out/ia32.release/obj.target/v8_base.ia32/src/isolate.o: In function `v8::internal::Isolate::FindOrAllocatePerThreadDataForThisThread()':
isolate.cc(.text._ZN2v88internal7Isolate40FindOrAllocatePerThreadDataForThisThreadEv+0x88): undefined reference to `operator new(unsigned int)'
v8/out/ia32.release/obj.target/v8_base.ia32/src/isolate.o: In function `v8::internal::Isolate::StackTraceString()':
isolate.cc:(.text._ZN2v88internal7Isolate16StackTraceStringEv+0x15a): undefined reference to `operator delete[](void*)'
v8/out/ia32.release/obj.target/v8_base.ia32/src/isolate.o: In function `v8::internal::Isolate::PrintStack(_IO_FILE*)':
isolate.cc:(.text._ZN2v88internal7Isolate10PrintStackEP8_IO_FILE+0x15f): undefined reference to `operator delete[](void*)'
isolate.cc:(.text._ZN2v88internal7Isolate10PrintStackEP8_IO_FILE+0x1f0): undefined reference to `operator new(unsigned int)'
isolate.cc:(.text._ZN2v88internal7Isolate10PrintStackEP8_IO_FILE+0x218): undefined reference to `operator new(unsigned int)'
请有人帮我解决正确的链接器命令。我想我可以自己把它包装成Makefile OK,然后我的程序将全速前进。
答案 0 :(得分:0)
您尚未指定您看到的链接器错误,因此我无法解决此问题,但以下信息可能会有所帮助:
如果您有多个源文件,您仍然可以一次编译/链接它们:
g++ -Iv8/include v8Ex1.cc othersource.cc othersource2.cc -o v8Ex1 \
-Wl,--start-group v8/out/ia32.release/obj.target/tools/gyp/libv8_base.ia32.a \
v8/out/ia32.release/obj.target/tools/gyp/libv8_snapshot.a \
v8/out/ia32.release/obj.target/third_party/icu/libicuuc.a \
v8/out/ia32.release/obj.target/third_party/icu/libicui18n.a \
v8/out/ia32.release/obj.target/third_party/icu/libicudata.a \
-Wl,--end-group -lrt
如果要单独编译它们(例如为了节省增量构建的时间),可以使用g ++进行链接 - 只需指定.o文件代替.c / .cc文件:
g++ -Iv8/include v8Ex1.o othersource.o othersource2.o -o v8Ex1 \
-Wl,--start-group v8/out/ia32.release/obj.target/tools/gyp/libv8_base.ia32.a \
v8/out/ia32.release/obj.target/tools/gyp/libv8_snapshot.a \
v8/out/ia32.release/obj.target/third_party/icu/libicuuc.a \
v8/out/ia32.release/obj.target/third_party/icu/libicui18n.a \
v8/out/ia32.release/obj.target/third_party/icu/libicudata.a \
-Wl,--end-group -lrt
这可能会节省一些与ld
的争论的摔跤。