lld-link: error: <root>: undefined symbol: mainCRTStartup when building V8

1,125 views
Skip to first unread message

James W

unread,
Mar 3, 2019, 6:36:48 PM3/3/19
to v8-dev

I've spent a whole day on this now and I can't seem to get the .lib files to build with VS 2017. I followed the V8 docs here:

https://v8.dev/docs/build

Following the instructions does work, but I end up with a V8 command line program in the outdirectory and .lib that do NOT work with Visual Studio 2017.

fatal error LNK1107: invalid or corrupt file: cannot read at 0x1422A

I executed this to try to get the build files for the libraries only:

gn gen out/lib --args="v8_static_library=true v8_use_snapshot=true v8_use_external_startup_data=false v8_monolithic=true icu_use_data_file=false is_component_build=false is_debug=false"

Then ran this: ninja -C out/lib

And this was the final result:

ninja: Entering directory `out/lib'
[1632/1645] LINK cctest.exe cctest.exe.pdb
FAILED: cctest.exe cctest.exe.pdb
ninja -t msvc -e environment.x64 -- ../../../../third_party/llvm-build/Release+Asserts/bin/lld-link.exe /nologo /OUT:./cctest.exe /PDB:./cctest.exe.pdb @./cctest.exe.rsp
lld-link: error: <root>: undefined symbol: mainCRTStartup
[1634/1645] LINK generate-bytecode-expectations.exe generate-bytecode-expectations.exe.pdb
ninja: build stopped: subcommand failed.

I think I'm missing something, but I have no idea at the moment.

James W

unread,
Mar 3, 2019, 6:38:14 PM3/3/19
to v8-dev
My biggest issue is that no matter what I do, Visual Studio says the lib files are corrupt.

danny...@gmail.com

unread,
Mar 4, 2019, 7:51:09 AM3/4/19
to v8-dev
Hi James,

I think that you also need to use option:

is_clang=false

The default setup produces CLang libraries, which is not the format that Visual Studio expects. I also build with:

--fatal_linker_warnings=false
--msvc_use_absolute_paths=true

because I like full path names in the error messages and the linker produces warnings (though I can't remember what they are right now).

Dan
Reply all
Reply to author
Forward
0 new messages