LNK1181 error when compiling V8 engine on Win10 - c++

I'm following this guide on building V8 but I am hitting some issues on the compilation step. I am running Windows 10 x64. I am trying to compile with options to embed the engine also.
Running the following command:
ninja -C out.gn/x64.release
Gives me this error:
ninja: Entering directory `out.gn/x64.release'
[1/471] LINK mksnapshot.exe mksnapshot.exe.pdb
FAILED: mksnapshot.exe mksnapshot.exe.pdb
C:/Workspace/depot_tools/win_tools-2_7_6_bin/python/bin/python.exe ../../build/toolchain/win/tool_wrapper.py link-wrapper environment.x64 False link.exe /nologo /OUT:./mksnapshot.exe /PDB:./mksnapshot.exe.pdb #./mksnapshot.exe.rsp
LINK : fatal error LNK1181: cannot open input file 'comdlg32.lib'
ninja: build stopped: subcommand failed.
Now I believe I have narrowed down the error to looking for the .lib files in the wrong directory. I have (had) multiple versions installed, so there were multiple folders in my Windows Kit install.
Windows Kits/10/Lib/10.0.16299.0
Windows Kits/10/Lib/10.0.15xxx.0
If I dragged and dropped the comdlg32.lib file from 10.0.16299.0 into the 10.0.15xxx.0 directory then the error changed to a LNK1181 error with a different input file. I did this a few times but I was unsure if this was going to cause issues with different versions and there was probably going to be a lot.
I uninstalled the 10.0.15xxx.0 version which left behind the folder I mentioned, so I removed that and after doing so I have started getting the LNK1181 error with a different input file (advapi32.lib I assume the very first file it can't find). This is how I came to the conclusion about the path being incorrect.
So I have tried a few things to change the path (I hoped just uninstalling the old version would fix it) such as:
Uninstalling the old version.
Going through registry entries to see if I can find an install path or something using that path, which I didn't. I did notice that there was still installation and data in the registry for the 10.0.15xxx.0 install, I might try deleting that from the registry directly as a last resort?
I have tried to explicitly set the path by setting <TargetUniversalCRTVersion>10.0.16299.0</TargetUniversalCRTVersion> in this file: C:\Program Files (x86)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\uCRT.props
I have never used Ninja before so I tried looking for a way to set some kind of lib-path in the command but couldn't really find anything.
I looked through the python scripts being executed to try and locate something to do with the libs path but couldn't see anything.
I would be grateful for any help and suggestions. Thanks.

You can try to compile v8 using Visual Studio as explained here: https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md#using-the-visual-studio-ide
By running the following commands:
$ gn gen --ide=vs out.gn/x64.release
$ cd out.gn/x64.release
$ msbuild all.sln
You can see a full example here: https://github.com/phpv8/v8js/issues/272#issuecomment-262848754
Apparently this method is not officially supported anymore, but I had the same problem as you have and this solved the issue for me.
Note that after this I had another issue, the unit tests failed to be compiled due to a linking error, but I had the necessary libraries to use v8. So there may be deeper problem that is causing all of this that I'm missing.
Edit:
Also, you could try to set the following parameters with gn args:
visual_studio_path = "..."
visual_studio_version = "2017"
wdk_path = "..."
windows_sdk_path = "C:\Program Files (x86)\Windows Kits\10"
To set those parameters, do:
gn args out.gn/x64.release
This will open a text editor where you can write the extra parameters you are interested in.
To see the full list of parameters you can specify:
gn args --list out.gn/x64.release

I was following this guide https://medium.com/dailyjs/how-to-build-v8-on-windows-and-not-go-mad-6347c69aacd4 and also ran into the error
LINK1181: cannot open input file 'advapi32.lib'
I'm pretty sure it was because I had the wrong versions of the Windows 10 SDK. Similar to you I had versions:
Windows Kits/10/Lib/10.0.10240.0
Windows Kits/10/Lib/10.0.16299.0
But according to https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md#Setting-up-Windows (Which I think is relevant) you need version 10.0.15063.0
After installing version 10.0.15063.0 (with the visual studio installer) to
Windows Kits/10/Lib/10.0.15063.0
I was able to continue with the build.

Related

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

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 out directory 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.
Ok, seems my first mistake was changing the prompt to v8\tools\dev\ and working from there. The "normal" steps I found actually only work properly from the root of the source. I ended up with v8\tools\dev\out\x64.release then ninja -C out/x64.release v8 failed because v8 was not accepted in this setup for some reason.
The other thing I did wrong was to edit the args.gn file directly and save it. The CORRECT process is to run gn args out.gn\x64.release so that after you save AND close the editor, it automatically re-generates/updates the files. Most likely changing the file has no effect on its own, and you'll get confused because ninja won't even see the changes.
The linker error about corrupt files is because is_clang is true by default. Setting is_clang=false fixes that error. It just works, I have no idea why; just take it and go ... ;)
The correct way, from the root that worked for me is:
python tools\dev\v8gen.py x64.release
python tools\dev\v8gen.py ia32.release
python tools\dev\v8gen.py x64.debug
python tools\dev\v8gen.py ia32.debug
This will output files that can be compiled in the "v8\out.gn" folder.
Tip: Run "python tools\dev\v8gen.py list" to see a list of possible build configurations.
Next I updated the build arguments:
gn args out.gn\x64.release
Using these:
is_debug = false <-(or true for debug builds)
target_cpu = "x64"
is_component_build = false
v8_static_library = true
use_custom_libcxx = false
use_custom_libcxx_for_host = false
v8_use_external_startup_data = false <-(or true to use the bin startup files)
is_clang = false
And again for the 32-bit version (changing "x64" above to "x86" of course):
gn args out.gn\ia32.release
Then repeated all the above for x64.debug and ia32.debug.
And compiled them:
ninja -C out.gn/x64.debug v8
ninja -C out.gn/ia32.debug v8
ninja -C out.gn/x64.release v8
ninja -C out.gn/ia32.release v8
Visual Studio 2017 now builds and links my project against them again now (was an old project I resurrected).
Note: Linking against debug versions of V8 libraries may give an error that _ITERATOR_DEBUG_LEVEL does not match. To fix this I simply went to the C++ project settings (Confiuration Properties->C/C++->Preprocessor->Preprocesor Definitions) and added ;_ITERATOR_DEBUG_LEVEL=0 so it matches.

Error while compiling workspace-d

I tried to install workspace-d on Windows 10 using Administrator privilege but failed.
Here is the error message.I haved installed dmd, dub and git.
PS C:\Users\U\Desktop\workspace-d-installer> .\workspace-d-installer.exe
Welcome to the workspace-d installation guide.
Make sure, you have dmd, dub and git installed.
Which external components do you want to install?
[1] DCD - auto completion
[2] DScanner - code linting
[3] dfmt - code formatting
Enter a comma separated list of numbers
Selected [all]:
Cloning workspace-d into C:\Users\U\AppData\Local\Temp\workspaced-install-635958600835730563
Checking out v2.6.0
Compiling...
Error: Error writing file '..\..\..\..\..\..\U\AppData\Roaming\dub\packages\painlesstraits-0.1.0\.dub\build\library-release-windows-x86-dmd_2071-92537C3AEFB87AC450BFCCEE2ECBED44\painlesstraits.lib'
dmd failed with exit code 1.
Error while compiling workspace-d.
This is a bug with workspace-d-installer. Even though it just runs the shell commands, it has some permission problems on windows. I have opened an issue on the project page if you want to do anything on it: https://github.com/Pure-D/workspace-d-installer/issues/2
The only solution right now is to manually clone each repository (workspace-d, dfmt, dscanner, dcd) and follow their build instructions. I'm trying to fix that issue so you can use workspace-d-installer.

Install mod_wsgi with Python 2.7 on Windows 64 bit

I'm trying to deploy my Django website, which is written using Python 2.7, on a windows 64 bit machine (Windows Server 2008 R2). I installed the pre-compiled version of Apache (Apache 2.4.16 x64) from https://www.apachehaus.com/cgi-bin/download.plx (due to lack of option provided by Apache Lounge***), and have checked that Python 2.7 runs on 64 bit and compiles with VC9. I wasn't able to find a pre-built binary for mod_wsgi (for Windows 64 bit and compiled with VC9), so I downloaded the source code for mod_wsgi from https://github.com/GrahamDumpleton/mod_wsgi/releases/tag/4.4.13 and followed the direction from https://github.com/GrahamDumpleton/mod_wsgi/blob/develop/win32/README.rst, changing the ap24py27-win64-VC9.mk file to point at the right directories for APACHE_ROOTDIR and PYTHON_ROOTDIR, and using C++ 2008 64-bit Command Prompt to run the command nmake -f ap24py27-win64-VC9.mk clean. However, this gave me the error:
wsgi_memory.obj : error LNK2019: unresolved external symbol GetProcessMemoryInfo referenced
in function getPeakRSS
mod_wsgi.so : fatal error LINK1120: 1 unresolved externals
NMAKE : fatal error U1077: `"...\Visual C++ for Python\9.0\VC\Bin\amd64\c1.EXE"` :
return code `0x2`
Stop.
I have read the installation and configuration documents for mod_wsgi multiple times and have searched the web including SO for the past few hours to no avail. What am I doing wrong here and how could I fix it?
***I know the official document for installing mod_wsgi warns against using binaries from other sources than Apache Lounge but I don't seem to be able to find the right compiled version (for VC9 and Windows 64 bit) from the site. Could this be a problem and if so, how could I fix it?
Update: following Adelin's suggestion, I was able to get namke -f ap24py27-win64-VC9.mk clean to run. However, when I try running namke -f ap24py27-win64-VC9.mk or namke -f ap24py27-win64-VC9.mk install, I get pages of warnings that say: warning C4820: '...' : '...' bytes padding added after data member '...' until the compiler quits with
fatal error C1083: Cannot open include file: 'Python.h': No such file or directory
...\mod_wsgi-4.4.13\src\server\wsgi_memory.c<124> : warning C4711: function 'getCurrentRSS' selected for automatic inline expansion
NMAKE: fatal error U1077: '"C:\...\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\c1.EXE"' : return code '0x2'
Stop.
Does anyone have any idea why this might be and how I should go about fixing it?
I had this same error.
The problem is that the cl.exe doesn't find the psapi.lib. This lib includes the function referenced in wsgi_memory.c - GetProcessMemoryInfo.
To fix this, you should follow these steps:
Locate psapi.lib (run a search on C:\)
Open the ap24py27-win64-VC9.mk file you are using to compile, with
any text editor
See what other .mk file it includes. Most probably common-VC9.mk
Open that file (common-VC9.mk) with any text editor
Under LDFLAGS, append yet another line of /LIBPATH:"PATH_FOUND_AT_STEP_1"\
Save changes and retry
What a pain in the ass this was for me too :)
P.S. If you don't find psapi.lib anywhere, it's because you don't have the Windows SDK. I installed both Windows 7 and Windows 8 SDKs and eventually had the psapi.lib located here C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x64
Edit:
To give you a solution for your newest errors in a somewhat general way, whenever nmake throws "No such file" errors, the location for the file is not properly referenced in common-VC9.mk file.
There are two types of files nmake will look for: .h or .lib.
If a .h is not found, the corresponding path should be properly referenced under the CPPFLAGS variable of common-VC9.mk file.
If a .lib is not found, you need to update LDFLAGS path accordingly.
How? The same way you included the path for psapi.lib: locate the file and append the corresponding path to the proper variable: CPPFLAGS or LDFLAGS.

Exe built using pyinstaller on a Django with pylucene app giving JVM error

I am getting an error:
"Error occurred during initialization of VM
Unable to load native library: Can't find dependent libraries"
The error arises when I try to execute my exe file.
I have created exe file through pyinstaller on a django application. Application uses pylucine library. I think it may be the issue of error.
How to fix the error?
Since I can't be certain given you've provided very few details here is a shot in the dark to help solve your problem:
First, try removing the jvm.dll file that gets packaged with the pyinstaller -D youmodule.py command (for now work with the directory command rather than -F option). The reason why is here.
With that jvm.dll file gone, you should start seeing the actual error code - and with that the java class or dependency that isn't being loaded.
If it's a java class that isn't being properly loaded then you know instantly it must not be correcly represented in the classpath environment variable and you should do everything in your power to make sure it is:
e.g.: os.environ['CLASSPATH'] += 'the/path/to/the/jar'
Otherwise, consider bulking up your question with more details, especially if you can get a more meaningful error output.
I had the same error trying to run a .exe built with PyInstaller through wine.
My problem went away by adding C:\Program Files\Java\ [your jdk version here] \jre\bin\server to the PATH environment variable in wine - I suppose it might be the same in Windows.
It also reappeared if I tried to build with C:\Program Files\Java\ [your jdk version here] \jre\bin\server in my PATH, so I had to build without it and then append it before running it (I have no explanation as to why this happens).

wxWidgets-2.9.4\include and \lib\gcc_lib\mswu No such file or directory error on CodeBlocks

I'm trying to learn C++ programming with wxWidgets and CodeBlocks (with MinGW) and earlier today I succeeded in installing the software (after some trouble) to my Windows 7 computer with the guidance given to me in this post:
wxWidget 2.8.12 not working in Codeblocks
Later on the same day, I did the exact same steps on another Windows 7 machine and after creating a wxWidgets project and trying to compile and run it I got the following errors:
\wxWidgets-2.9.4\include: No such file or directory
\wxWidgets-2.9.4\lib\gcc_lib\mswu: No such file or directory
I have checked and these folders really do exist on those locations...so what seems to be the problem here again?...on the earlier post user asanth kumar guided me that if the steps given in the guide don't get the job done, then I'm missing an important compiler search path in my build options.
Ok, so what do I do? Where do I enter the search path? What is the search path, etc. I'm very new with wxWidgets and CodeBlocks so I don't know very much terminology. If anyone should know what to do, could you please give me like step by step instruction what to do e.g. like Click Project --> Build options --> ... and so on
I have used the latest CodeBlocks (12.11) and wxWidgets (2.9.4) installers
Thank you for any help :)
UPDATE:
here is the build log: (I'm using CodeBlocks 12.11 and wxWidgets 2.9.4)
-------------- Build: Debug in TEST (compiler: GNU GCC Compiler)---------------
windres.exe -I"C:\Users\Jonne\Omat ohjelmat\wxWidgets-2.9.4\include" -I"C:\Users\Jonne\Omat ohjelmat\wxWidgets-2.9.4\lib\gcc_lib\mswu" -J rc -O coff -i C:\Users\Jonne\DOCUME~1\CODEBL~1\TEST\resource.rc -o obj\Debug\resource.res
gcc: error: ohjelmat\wxWidgets-2.9.4\include: No such file or directory
gcc: error: ohjelmat\wxWidgets-2.9.4\lib\gcc_lib\mswu: No such file or directory
windres.exe: preprocessing failed.
Process terminated with status 1 (0 minutes, 0 seconds)
3 errors, 0 warnings (0 minutes, 0 seconds)
Here is also a picture where you can see Build options, global variables and build log on my CodeBlocks:
NOTICE FUTURE READERS: Install wxWidgets to a directory without whitespace in the path name. The problems in this post was because the directory path had spaces in it
When you create a wxWidgets project.Have you did this?
File->New->Project->wxWidgets Project->Click Go->Click on Next->click on the suitable wxWidgets 2...version->click Next->Give project Name->Click on Next->Click on Next
After that the Following below Screen comes in the Wizard. Give the wxWidgets Location(Path where You installed the wxWidgets 2.9.4)
After that click on Finish.
For Environment Variable Path Setting
Follow the Below Steps:
Right click on MyComputer->Click on Advanced Systems settings->click on Environment Variables->click on New->Give variable name=Path and variable value="C:\Program Files (x86)\CodeBlocks\MinGW\bin" -> click ok
`
Try The Following Steps.It will work.
Updates about Build settings:
I am having the same problem as this and I somehow solved my problem.
I transfer my wxWidget folder to another location path that don't have white space name on it's path. For example above, "C:\Users\Jonne*Omat ohjelmat*\wxWidgets-2.9.4\include"
the path has white space between Omat ohjelmat. Try transfering it where the path contains no white spaces. For me, I put it on C:\wxWidgets-3.1.2