Repository navigation
Problem Building Node (had errors about multiply-defined symbols and such) #24448
Description
Activity
Hello @DragonOsman and thank you for the report.
It seems like you computer has a previously installedzlib1.dll, and it's added the the linker's LIBPATH so it finds two library files that defines those symbols (yourzlib1.dlland thezlib.libwe build from our tree).- One option is to disable you globally installed zlib (it's usually installed with Chocolatery or NuGet)
- Another option is to run the configure script with
--shared-zlib:
python configure --shared-zlib --with-pch --dest-cpu=x64 --verbose ^^^^^^^^^^^^^- addedquestionIssues asking questions about Node.js.Issues asking questions about Node.js.windowsIssues and PRs related to the Windows platform.Issues and PRs related to the Windows platform.buildIssues and PRs related to Node.js builds or CI infrastructure.Issues and PRs related to Node.js builds or CI infrastructure.zlibIssues and PRs related to the zlib module and its compression dependencies.Issues and PRs related to the zlib module and its compression dependencies.
on Nov 17, 2018 Thanks for the reply. I'll try the second option.
By the way, I forgot to mention earlier that I'm using Visual Studio 2017 (latest version).
I have these warnings:
rand_egd.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library [C:\node\deps\openssl\openssl.vcxproj] ecp_nistputil.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library [C:\node\deps\openssl\openssl.vcxproj] ecp_nistp521.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library [C:\node\deps\openssl\openssl.vcxproj] ecp_nistp256.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library [C:\node\deps\openssl\openssl.vcxproj] ecp_nistp224.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library [C:\node\deps\openssl\openssl.vcxproj] ebcdic.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library [C:\node\deps\openssl\openssl.vcxproj]Do I need to worry?
Do I need to worry?
No, it's expected. I often see it while building locally.
I got the same errors again:
zlib.lib(adler32.obj) : error LNK2005: adler32 already defined in zlib.lib(zlib1.dll) [C:\node\node.vcxproj] zlib.lib(adler32.obj) : error LNK2005: adler32_combine already defined in zlib.lib(zlib1.dll) [C:\node\node.vcxproj] zlib.lib(adler32.obj) : error LNK2005: adler32_z already defined in zlib.lib(zlib1.dll) [C:\node\node.vcxproj] zlib.lib(crc32.obj) : error LNK2005: crc32 already defined in zlib.lib(zlib1.dll) [C:\node\node.vcxproj] zlib.lib(crc32.obj) : error LNK2005: crc32_combine already defined in zlib.lib(zlib1.dll) [C:\node\node.vcxproj] zlib.lib(crc32.obj) : error LNK2005: crc32_z already defined in zlib.lib(zlib1.dll) [C:\node\node.vcxproj] zlib.lib(crc32.obj) : error LNK2005: get_crc_table already defined in zlib.lib(zlib1.dll) [C:\node\node.vcxproj] C:\node\Release\node.exe : fatal error LNK1169: one or more multiply defined symbols found [C:\node\node.vcxproj]How do I disable the other zlib installation?
I had zlib installed in the C drive in a folder called "libraries". I completely deleted that folder and then tried to build Node again, but had the same errors as before.
2. Another option is to run the configure script with
--shared-zlib:python configure --shared-zlib --with-pch --dest-cpu=x64 --verbose ^^^^^^^^^^^^^What I forgot to say is that if you build with
vcbuild.batthen you need to set an env varconfig_flags. So:set config_flags=--shared-zlib vcbuild release x64
I even removed the vcpkg for zlib from my system and tried to build again with the commands you just gave. Got these errors at the end:
LINK : fatal error LNK1181: cannot open input file 'z.lib' [C:\node\tools\icu\icupkg.vcxproj] LINK : fatal error LNK1181: cannot open input file 'z.lib' [C:\node\tools\icu\iculslocs.vcxproj] LINK : fatal error LNK1181: cannot open input file 'z.lib' [C:\node\tools\icu\genccode.vcxproj] LINK : fatal error LNK1181: cannot open input file 'z.lib' [C:\node\tools\icu\genrb.vcxproj]Any ideas?
Any ideas?
So it's either/or. If you removed the global zlib.dll you need to build the "in tree" version (i.e. "not share zlib"):
set config_flags= vcbuild release x64
If that doesn't work, try searching your whole computer for
zlib.dlland rename them all.Got the same errors.
So what do you mean by renaming them all? What should I rename them to? And what if I just delete them all?
I wonder if you could help me with compiling a C++ webserver app I have to WebAssembly? I want to use it on the backend as a Node.js module. I can't get
em++to generate .wasm code for it, though. I get .o and .js, but no .wasm. The source code is here: https://github.com/DragonOsman/currency_converter , and the command I used is:em++ -std=c++17 -Wall -pedantic -D variant_CONFIG_SELECT_VARIANT=variant_VARIANT_NONSTD -I C:/Jinja2Cpp/install_x64/include -I C:/json/single_include -I C:/boost_1_68_0/ -I C:/Users/Osman/emsdk/emscripten/1.38.18/system/include/ currency_converter.cpp -L C:/Jinja2Cpp/install_x64/lib/static/jinja2cpp.lib -L C:/boost_1_68_0/lib64-msvc-14.1/libboost_system-vc141-mt-x64-1_68.lib -lpthread -o currency_converter.js -o currency_converter.o currency_converter.js -s WASM=1 -s DISABLE_EXCEPTION_CATCHING=0 -s USE_PTHREADS=1I understand that when wanting to call
embindforstd::shared_ptrin JavaScript code, one has to useEMSCRIPTEN_BINDINGSand some other code in there to be able to do it. Does this apply to Node.js? Could this be why it won't generate WebAssembly code? If so, how do I useEMSCRIPTEN_BINDINGSonstd::make_shared_from_this<>? I want to use the one that will let the pointer translate to an actualstd::shared_ptron the Node.js side rather than a regular, raw pointer.I also tried asking about this in the emsdk GitHub. That's here (the two replies there is just me giving more info and updates) and here. I also asked something else two months ago about
cwrap, and I asked about this there as well: link. As you can see, I don't have replies on the latest comments I made. If you can help me on this, that'd be great.Note: The "same errors" I mentioned before are the same ones I was getting at first:
zlib.lib(adler32.obj) : error LNK2005: adler32 already defined in zlib.lib(zlib1.dll) [C:\node\node.vcxproj] zlib.lib(adler32.obj) : error LNK2005: adler32_combine already defined in zlib.lib(zlib1.dll) [C:\node\node.vcxproj] zlib.lib(adler32.obj) : error LNK2005: adler32_z already defined in zlib.lib(zlib1.dll) [C:\node\node.vcxproj] zlib.lib(crc32.obj) : error LNK2005: crc32 already defined in zlib.lib(zlib1.dll) [C:\node\node.vcxproj] zlib.lib(crc32.obj) : error LNK2005: crc32_combine already defined in zlib.lib(zlib1.dll) [C:\node\node.vcxproj] zlib.lib(crc32.obj) : error LNK2005: crc32_z already defined in zlib.lib(zlib1.dll) [C:\node\node.vcxproj] zlib.lib(crc32.obj) : error LNK2005: get_crc_table already defined in zlib.lib(zlib1.dll) [C:\node\node.vcxproj] C:\node\Release\node.exe : fatal error LNK1169: one or more multiply defined symbols found [C:\node\node.vcxproj]6 remaining items
I need advice on what to rename zlib1.dll into. I have lots of instances of it; some in vcpkg's files, some in Visual Studio 2017's files. If I try to set the
--shared-zlibflag, I get a linker error saying that it can't open z.lib.I tried to run this command to try to build it this way:
vcbuild release x64 build-release no-cctest staticBut I keep getting this message:
Looking for WiX installation for Visual Studio 2017... Failed to find WiX install for Visual Studio 2017 VS2017 support for WiX is only present starting at version 3.11 Failed to find a suitable Visual Studio installation. Try to run in a "Developer Command Prompt" or consult https://github.com/nodejs/node/blob/master/BUILDING.md#windows-1even after I both installed WiX and added it to the PATH, and also installed a Visual Studio 2017 Extension for WiX. Do I put WiX as the first thing mentioned in the PATH, or is that not a problem?
I think I'll just run the
fetch v8 commandand get only V8, that way. And quit trying to build all of Node.js since it's giving me trouble because of zlib.@nodejs/platform-windows ☝️
I have zlib dll instances in vcpkg and VS2017 installation directories, and I've also built zlib myself. I want to know if it's possible to just use the zlib I built myself with Node and just make Node ignore the one inside its source tree. Is this possible, and if so, how do I do it?
I mainly just want V8, so I've also been trying to build it. Haven't had any luck. I'm using VS2017 and have tried to follow the instructions here: https://medium.com/dailyjs/how-to-build-v8-on-windows-and-not-go-mad-6347c69aacd4 because the ones on the main documentation for V8 also didn't really help. But I got errors when I ran the command mentioned there, I got this error message:
Hint: You can raise verbosity (-vv) to see the output of failed commands. Traceback (most recent call last): File "C:\v8\tools\dev\v8gen.py", line 304, in <module> sys.exit(gen.main()) File "C:\v8\tools\dev\v8gen.py", line 298, in main return self._options.func() File "C:\v8\tools\dev\v8gen.py", line 166, in cmd_gen gn_outdir, File "C:\v8\tools\dev\v8gen.py", line 208, in _call_cmd stderr=subprocess.STDOUT, File "C:\Python27\lib\subprocess.py", line 223, in check_output raise CalledProcessError(retcode, cmd, output=output) subprocess.CalledProcessError: Command '['C:\\Python27\\python.exe', '-u', 'tools\\mb\\mb.py', 'gen', '-f', 'infra\\mb\\mb_config.pyl', '-m', 'developer_default', '-b', 'x64.release', 'out.gn/x64.release']' returned non-zero exit status 1The command I ran was:
python tools/dev/v8gen.py x64.release. I also tried going inside thetools/devdirectory and executing it there, though I left out thepythoncommand from the beginning of it. Same result.When I try to follow the instructions on the official documentation, it tries to run the
termiosmodule which of course it can't because it's not there on Windows.@Trott Why did you post that? Is there something for me to do there?
I still need to try building it with the Release configuration, since I've only tried with the Debug one so far, but it seems choosing
dllin thevcbuildarguments, instead ofstatic, did it. I still have .lib files, though. I didn't setbuild-release, and built it manually using the IDE itself. IIRC (I already closed the command prompt window I did it in, so I'll have to say from memory), the command I ran wasvcbuild release no-cctest x64 dll. I may have gotten the order wrong on some of that, but that's the gist of it. And I still managed to buildcctesteven though I'd putno-cctest. Also, I'm not sure if it made a difference, but I build node.vcxproj first.Update to above post: Turns out that although it worked with the Debug configuration, it didn't work with the Release configuration. I get "undefined symbol" errors because of zlib1.dll when I try to build node.vcxproj. I do have node.lib and zlib.lib in my
Release/libdirectory, though.Again, I'd like to know how I can make it ignore those
zlib1.dlls and use the zlib I built myself. If this possible, I'd really like to know how to do it. Thanks in advance.Is there a way for me to provide the path to the zlib I built when trying to use shared-zlib? So that it doesn't look for z.lib (I have zlib.lib and zlibstatic.lib, and I built the latest version of zlib).
Edit to add: I put in the path to the zlib include and lib directories in the project property pages, and also put in
zlib.libas the input file name for the linker to look for. I'm trying to build node.vcxproj again now.In the node.vcxproj linker command line, it has `C:/node/lib/Release/node.lib" as one of the linker input files. Why? I don't even see it under the linker input settings under "Linker" in Project Properties, so I don't know how to take it out of there. It's causing the project to fail to build. I asked on MSDN forums here, as well: link . Originally it was to ask about how to add library input files to the linker command line, but I decided to ask about this there, as well.
@nodejs/build
I tried specifying
staticandnobuildforvcbuildwhen generating project files and then tried to build the other projects before the main node.vcxproj one. But node.vcxproj keeps failing with linker errors. I have the log file. Gist link: https://gist.github.com/DragonOsman/ea32bd66414064d5c390854ce3ac1db2 . The reason it's so long with so much info is because I chose the setting for the most detailed diagnostic in MSBuild. It gives you info on the whole build environment everything too, not just on the build information.Anyway, I'd really like some help here.
I already have this issue where I'm asking about this (in the Nodejs Help repo): nodejs/help#1656
I downloaded the source code for version 11.6.0 from the Nodejs website and tried to build it (directly using IDE GUI). Before running
vcbuild, I ran this command:set config_flags=--shared-zlib --shared-zlib-libname=zlibstatic.lib --shared-zlib-libpath="C:\\zlib_library\\lib" --shared-zlib-includes="C:\\zlib_library\\include" --fully-static --with-ltcg --dest-cpu=x64 --without-etwAnd then I ran
vcbuildlike this:.\vcbuild release static vs2017 noetw ltcg no-cctest nobuildMost of it builds successfully, but I have these linker errors when I try to build node.vcxproj:
39>zlibstatic.lib(gzlib.obj) : error LNK2001: unresolved external symbol __imp_open 39>OLDNAMES.lib(open.obi) : error LNK2001: unresolved external symbol __imp_open 39>zlibstatic.lib(gzread.obj) : error LNK2001: unresolved external symbol __imp_read 39>OLDNAMES.lib(read.obi) : error LNK2001: unresolved external symbol __imp_read 39>zlibstatic.lib(gzwrite.obj) : error LNK2001: unresolved external symbol __imp_write 39>OLDNAMES.lib(write.obi) : error LNK2001: unresolved external symbol __imp_write 39>C:\node-v11.6.0\Release\node.exe : fatal error LNK1120: 3 unresolved externalsWhat library am I missing? Could someone please help me out? Thanks in advance.
There's been no further activity on this. Closing. Can reopen if necessary
@DragonOsman I think you can do vcpkg integration remove, and then it should work, this works for me
Tips: even if you do not install vcpkg yourself, Visual Studio may install automate as it's part of Visual Studio solutionvcpkg integration remove

I went into my Node root with the .git folder and ran
.\vcbuild, and it built a lot of the stuff but then ended with the errors:I want to build Node and then V8. Any help would be greatly appreciated.