Various issues installing igraph in Visual Studio 2010 and Cygwin/MinGW ("sys/time.h not found") - cygwin

I couldn't get igraph to work with Visual Studio 2010 (supposedly many known issues), and so decided to try installing it in Cygwin. ./configure went fine. But make gave this error:
f2c/dtime_.c:16:23: fatal error: sys/times.h: No such file or directory
Makefile:2190: recipe for target `libf2c_la-dtime_.lo' failed
make[3]: *** [libf2c_la-dtime_.lo] Error 1
I tried installing it in MinGW and get the same error when I make. Should I be providing "sys/time.h" or a path to it? Where is sys/time.h? Using Windows 7.
Edit
The problems in Cygwin and MinGW was due to the wrong version of gcc being used by my clean installation of Cygwin (and a characteristic of MinGW). Solution here: Installing/compiling in Cygwin/MinGW - How to set the include "path"? (symbolic link?)
The problem in Visual Studio 2010 was due to building in "Debug" instead of "Release". One of igraph's creator, Gábor Csárdi, graciously provided an excellent step-by-step guide below that identified and resolved it.

Igraph actually does work with Visual C++ 2010 Express, we test this before releases, and I have just tried it. You need to do the following steps.
Download the source package specifically created for Visual Studio.
Uncompress the file into My Documents\Visual Studio 2010\Projects.
Open the igraph.sln solution file in igraph-0.6-msvc\igraph-0.6-msvc directory from Visual Studio.
Visual Studio offers to convert the solution file to the current format, do that. Just click on Next, Next and Finish.
On the toolbar, change 'Debug' to 'Release' to make release builds.
Choose Debug -> Build solution and wait until the library is built.
To test it you can open the solution file in the igraphtest directory, convert it as well, choose 'Release' builds, and then build it and run it from the command line. It is a simple C++ program that uses igraph to create a graph and write it into the file out.txt.
You don't have to set up include and library directories at all, everything is set up properly in the solution file, both for igraph and igraphtest.

is there an sys/times.h file?
I have a vague memory that I had to make that symlink on a system once.

Related

CMake try_compile() not finding correct Windows 10 SDK

I am trying to compile my fork of ReactOS using CMake 3.9.0-MSVC_2 (as included with Visual Studio 2017, 15.4 update). When I have CMake generate NMake makefiles or Ninja inputs, it works just fine. However, when I tell CMake to generate a Visual Studio 2017 solution, it fails with a weird error. Here's how to reproduce this issue:
Clone git#github.com:SunburstApps/ReactOS. (It's a big repo, so please be patient. I have not been able to consistently reproduce this issue on a smaller project, in case anyone asks.)
In the root of the project directory, run configure.cmd VSSolution from a VS2017 x86 C++ tools command prompt. This will tell CMake to generate a Visual Studio solution (the exact version is inferred from the copy of cl.exe in the path).
I get the following CMake output:
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:24 (project):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
CMake Error at CMakeLists.txt:24 (project):
The CMAKE_CXX_COMPILER:
cl
is not a full path and was not found in the PATH.
-- Configuring incomplete, errors occurred!
Investigating the CMakeError.log file reveals the problem is actually something else. The vcxproj file that CMake generated to identify the compiler is refusing to link, complaining that ucrtd.lib can't be found. If I add the following line of code to the top-level CMakeLists.txt file, it will then progress slightly further (successfully identifying the compiler), only to die of the same issue during a try_compile() run to "detect compiler features".
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION 10.0.15063.0)
I have come to the conclusion that CMake is generating files without the Windows SDK target platform set, which is causing VS to refuse to locate ucrtd.lib. The set() line above tells CMake to add that specific version to the vcxproj files it generates, but clearly it doesn't add it to all of them.
I have tried other solutions I have found searching SO, including installing the Windows 8.1 SDK and running the CMake command as an administrator. Nothing helps. I need to generate a solution file so I can write code for this project using Visual Studio's excellent C++ editor. (I have also tried using the built-in CMake support in VS2017, but have found that it does not quite work due to ReactOS' specific cross-compiling requirements.) Can anyone give me some pointers? Thanks!

error cannot open file 'kernel32.lib'

I have installed VS2013 and VS2015 on Windows 7.
I have an existing C++ Dll project that was building fine but now all of a sudden it wont build using VS2015 and gives me the error:
LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
From this post: fatal error LNK1104: cannot open file 'kernel32.lib' I went looking for the kernel32.lib file and it is located here:
C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86
When I go to my Projects Properties-->Linker-->Input and select Macros I see that this path is indeed there:
My Platform Toolset is set to Visual Studio 2013 - Windows XP (v120_xp) which is what it always has been set to.
Why has my Project all of a sudden stopped building? What could have gone wrong?
I had this similar problem today with Visual Studio 2013 when I changed my VC++ Directories:
Project->Properties->VC++ Directories:
Include Directories
If the cause is some plug-in/extension that changes your props files, it may in consequence change the "Visual C++ Directories" settings of your project.
So, the solution that worked for me is described on my own answer Can't compile 64 bits Visual Studio 2010 projects, which I fully transcribe to here:
After I asked a colleague for help, we noticed, that even getting
clean builds of the projects from TFS, with overwrite option, the
Project's Configuration Properties > VC++ Directories on my computer
were always different from other computers.
Searching more we found the solution on the last post of Reset
include/lib path, which I will fully transcribe:
use "del %HOMEPATH%\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props"
is not always the right way.
Better use "del %USERPROFILE%\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props"
where the application data folder is normally placed in.
Then I've looked inside the contents of Microsoft.Cpp.x64.user.props
and I've seen that there were things added by Visual Leaks Detector.
Which is reasonable, as one month before, I did a memory leak analysis
using VLD.
So, I deleted the file and now everything compiles fine at 64bits!
I had to install the Visual C++ for Desktop Development.
Open Visual Studio Installer and go to Installed tab. Click on the Change Button on your installed Visual Studio Community Edition. -> On the Workloads Tab there should be a option Desktop Development with C++. Activate that option and modify the changes.
Afterwards it was working for me.
I had the same problem today. As it turned out somehow the SDK 10.0.15063.0 got installed on my system but without the Desktop C++ files. Selecting the SDK in the list of installed programs, doing a change install and there selecting the Desktop C++ options added the necessary files and now I can link again.
I got this error fatal error lnk1104: cannot open file 'kernel32.lib'.
this error is getting because there is no path in VC++ directories.
To solve this probelem
open visual studio 2008
go to Tools-options-Projects and Solutions-VC++ directories-*
then at right corner select Library files
here you need to add path of kernel132.lib
In my case It is C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib
Thank you.
I had this following upgrade of some projects from VS2013 to VS2017.
Original project had a manual modification to the "Library Directories" item under VC++ Directories in the project settings.
This meant it did not pick up changes from the upgrade.
Using the option will reset this to something that works (assuming the SDK is installed OK) provided anything other than the default is not needed of course. In my case it was trying to point at the v7.1 SDK but that was not installed for vs2017.
in vs 2019, just run the installer, click modify, and then in the individual components tab, remove windows 10 SDK. then again run the installer and add windows 10 sdk!
I had this similar problem today with Visual Studio 2017. My cause turned out to be a bad environment setting in NETFXSDKDir, specifically:
NETFXSDKDir=C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1
It needed to have a value of:
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x86
I have a more detailed response here:
fatal error LNK1104: cannot open file 'kernel32.lib'
In VS 2022 I was trying to compile an old solution that originally ran in VS 2010 then in VS 2019. It continually gave me the "cannot find Kernel32.lib" error. I spent 8 hours trying everything, including everything on this page. What worked for me: Configuration Properties -> VC++ Directories -> Library Directories and "inherit from parent" (guessing this sets to defaults) fixed this for me. Also note: I'm using winsock and directinput.

Bw tool in sphinxtrain cannot open mdef file on Windows

I am developing an speech recognition application using Sphinx4. I am trying to do acoustic model adaptation. I have followed every step of the instruction on the http://cmusphinx.sourceforge.net/wiki/tutorialadapt tutorial. However, in the step where i need to run the bw, it cannot open the mdef file and shows an Debug Assertion Fail.
I have been working on this for days but still dont know how to solve it. I am using Windows 10, ptm model, visual studio 2015, the latest sphinx4 5prealpha version.
I just found out the answer. I think it could have been because that i forgot to download Perl or something went wrong during my installation of Sphinxbase.
I first installed Perl. However, it still didnt work, so i re-built Sphinxbase and copied it back to Sphinxtrain, and it finally run.
p/s Thanks Nikolay for your help :)
This comment / solution is just based on my experience as I am not an expert on this. I had this same exact error after following all the instructions from adapting-the-model and looks like the mdef file from sourge-forge is corrupted. So I landed up on a comment on some other website where it mentioned to download the setup files for pocketsphinx, sphinxbase and sphinxtrain from github directly. So I downloaded it from here GitHub and followed the same steps from before. Since I was working on windows, I rebuilt using VS Studio later, after upgrading the project from 2012 to latest version.
Steps (from GitHub)-
You should download and unpack it to the same parent directory as PocketSphinx, so that the configure script and project files can find it. On Windows, you will need to rename 'sphinxbase-X.Y' (where X.Y is the SphinxBase version number) to simply 'sphinxbase' for this to work.
To compile the SphinxTrain under MS Visual Studio 2010
load SphinxTrain.sln located in SphinxTrain directory
compile all the projects in SphinxTrain (from SphinxTrain.sln)
MS Visual Studio will build the executables under .\bin\Release or .\bin\Debug (depending on the version you choose on MS Visual Studio), and the libraries under .\lib\Release or .\lib\Build.
Once you finished with compilation, copy the pocketsphinx and sphinxbase tools and dlls from sphinxbase\bin\Releae and pocketsphinx\bin\Release to sphinxtrain\bin\Release folder. This will enable you to run the training process which expects to see all the tools and libraries in sphinxtrain\bin\Release.

Tortoise SVN Build using Visual C++ FAILS

I am trying to build TSVN using Visual Studio and have followed all the steps of the build.txt but I am getting the following errors:
*****ERRORS********* Error 50 fatal error LNK1181: cannot open input file '../../ext/Subversion\release_win32\libsvn_repos.lib' TortoiseProc TortoiseProc
Error 1 fatal error LNK1181: cannot open input file '../../ext/Subversion\release_win32\libsvn_wc-nonet.lib' SubWCRevCOM SubWCRevCOM
The error messages suggest that you don't have all the required libraries. A few variants as to how yo got here:
you either misstyped the path to the include folder (where the .lib files are) - try searching for the files that are not found and adjust the include paths
OR
you have to build the project(s) in a certain order to avoid getting this error messages. Build the projects that output libsvn_repos.lib and libsvn_wc-nonet.lib first. Check the dependencies for each project and build first the projects that do not have dependencies on the other projects in the sollution
I haven't built TSVN myself so these are just guesses. But why don't you just use the install kit and avoid all this trouble ?
TortoiseSVN is a GUI front-end for Subversion, and it uses Subversion libraries as the back-end. Thus, you must compile Subversion or obtain the compiled binaries for your version of Visual Studio before compiling TortoiseSVN. After that, modify the paths that point to Subversion libraries to reflect your setup.

fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

I'm using CUDA (VC++, Visual studio 2008sp1) to debug a FEM program. The program can only run on a Win32 platform, for the insufficiency of cuda. I think the library files linked are all compiled on the x86 platform, but when I compile it, I get the error message
fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'.
I have tried to convert the platform to x64, but it didn't work. Please tell me: what is "module machine type" and what is "target machine type"? How can I overcome it?
I wrote a blog entry about this, as I encountered this maddening problem, and finally yanked my system back into working order.
These are the things to check, in this order:
Check your properties options in your linker settings at: Properties > Configuration Properties > Linker > Advanced > Target Machine. Select MachineX64 if you are targeting a 64 bit build, or MachineX86 if you are making a 32 bit build.
Select Build > Configuration Manager from the main menu in visual studio. Make sure your project has the correct platform specified. It is possible for the IDE to be set to build x64 but an individual project in the solution can be set to target win32. So yeah, visual studio leaves a lot of rope to hang yourself, but that's life.
Check your library files that they really are of the type of platform are targeting. This can be used by using dumpbin.exe which is in your visual studio VC\bin directory. use the -headers option to dump all your functions. Look for the machine entry for each function. it should include x64 if it's a 64 bit build.
In visual studio, select Tools > Options from the main menu. select Projects and Solutions > VC++ Directories. Select x64 from the Platform dropdown. Make sure that the first entry is: $(VCInstallDir)\bin\x86_amd64 followed by $(VCInstallDir)\bin.
Once I did step 4 everything worked again for me. The thing was I was encountering this problem on all my projects where I wanted to compile towards a 64 bit target.
In addition to C Johnson list I would add the following point:
Check in Visual Studio:
Project Properties -> Configuration Properties -> Linker -> Command line.
"Additional Options" should NOT contain /machine:X86
I have such key, generated by CMake output: CMake generated x86 project, then I added x64 platform via Configuration Manager in Visual Studio 2010 - everything was created fine for the new platform except that the linker command line, specified /machine:X86 separately.
I experienced the same problem in VS2008 when I tried to add a X64 build to a project converted from VS2003.
I looked at everything found when searching for this error on Google (Target machine, VC++Directories, DUMPBIN....) and everything looked OK.
Finally I created a new test project and did the same changes and it seemed to work.
Doing a diff between the vcproj files revealed the problem....
My converted project had /MACHINE:i386 set as additional option set under Linker->Command Line. Thus there was two /MACHINE options set (both x64 and i386) and the additional one took preference.
Removing this and setting it properly under Linker->Advanced->Target Machine made the problem disappeared.
All project settings seemed perfect, but I still got the error. Looking into the .vcxproj file and searching for "x86" revealed the problem:
<Lib>
<AdditionalOptions> /machine:X86 %(AdditionalOptions)</AdditionalOptions>
</Lib>
A quick search/replace for all occurrances (ten individual file settings) fixed the problem.
You probably have one .OBJ or .LIB file that's targeted for x64 (that's the module machine type) while you're linking for x86 (that's the target machine type).
Use DUMPBIN /HEADERS on your .OBJ files and check for the machine entry in the FILE HEADER VALUES block.
Since the problem is due to the difference in compilation and target machine specifications (x86 & x64)
Follow the steps below:
Open the C++ project that you want to configure.
Choose the Configuration Manager button to open the Configuration Manager dialog box.
In the Active Solution Platform drop-down list, select the option to open the New Solution Platform dialog box.
In the Type or select the new platform drop-down list, select a 64-bit platform.
It solved my problem.
In Visual Studio 2012 +/-, the property page for "Configuration Properties'.Linker."Command Line" contains a box labeled "Additional Options". If you're building x64, make sure that box doesn't contain /MACHINE:I386. My projects did and it generated the error in question.
I came across this problem when building QT. The instructions I read somewhere suggested that I configure nmake using VS command prompt.
I chose the x64 command prompt and performed configure without much hassle. When i tried nmake, it gave this error.
I think some of the components were pre-built for 32-bit. The error even reported which modules were built for x86.
I used the 32 bit default VS command prompt and it worked.
"project property - CUDA Runtime API - GPU - NVCC Compilation Type"
Set the 64 bit compile option -m64 -cubin
The hint is at compile log.
Like this:
nvcc.exe ~~~~~~ -machine 32 -ccbin ~~~~~
That "-machine 32" is problem.
First set 64bit compile option,
next re setting hybrid compile option.
Then u can see the succeed.
In Visual Studio 2013,
1) Check in the Project Property Pages / Configuration Properties / Linker / All Options and correct all the miss configured machine and directories.
2) Check in the Project Property Pages / Configuration Properties / Linker / Input and correct all the miss configured directories.
See example of 1)
If your solution has lib projects check Target Machine property in Property->Librarian->General
vcxproj file may contain 'MACHINE:i386'
Edit vcxproj file with editor. remove it !
My target is a x64 Windows 10 text mode DOSBox application in C language.
Using "Visual Studio 2019 Community" to compile through DOS prompt "nmake -f makefile".
The error is similar but on the opposite side:
fatal error LNK1112: module machine type 'x32' conflicts with target machine type 'X64'
It's ok to compile by VC++ 2010 on another computer. But failed on this computer by "Visual Studio 2019 Community". So my settings are correct and all above answers do not work.
I'd like to share you that the solution is a make.bat like this:
call "c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
nmake -f makefile
You will find there are many other vcvarsxxxx.bat, only this one words.
In my case, setting environment variable PROCESSOR_ARCHITECTURE to AMD64
fixed the problem.
https://social.msdn.microsoft.com/Forums/en-US/f9303904-81ce-405d-85b3-b66d97e49971
In addition to Jhonson's list, also check library's folders
In visual studio, select Tools > Options from the main menu. select Projects and Solutions > VC++ Directories. Select x64 from the Platform dropdown.
$(VCInstallDir)lib\AMD64;
$(VCInstallDir)atlmfc\lib\amd64;
$(WindowsSdkDir)lib\x64;
This happened to me today because I had added a library directory while still in x86 mode, and accidently removed the inherited directories, making them hardcoded instead.
Then after switching to x64, my VC++ Directories still read:
"...;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);"
instead of the _x64.
I was using CMake & then added a win32 configuration. The property page showed x86 but actually when opening the vcxproj file in a text editor it was x64! Manually changing to x86 solved this.
First of all try the following things:
1. goto configuration Manager and create a new x64 if it is not already there.
2. select the x64 solution.
3. go to project properties and then Linker->Advanced select x64 machine.
4. Now rebuild the solution.
If still you are getting the same error. try clean solution and then rebuild again and open visual studio you will get list of recent opened project , right click on the project and remove it from there. Now go to the solution and reopen the solution again.
It's a very frustrating and annoying problem but once you understand it, it's quite simple: you have some element in you're build that building one architecture type (in your case x64) despite the fact that it's been target for another type (say x86).
You can dissect the source of your problem by looking at which obj file is causing the crash and start looking for the problem there. Every obj will have a source code analog: either in cpp, c, asm etc. There may be special build events around it that are using the wrong tool. Check for that in the property sheets.
I'd look there first before going through C Johnson list of things to do.
I solved this problem by changing Win32 to *64 in Visual Studio 2013.
Many good suggestions above.
Also if you are trying to build in x86 Win32:
Make sure that any libraries you link to in Program Files(x86) are actually x86 libraries because they are not necessarily...
For example a lib file I linked to in C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\SDK threw that error, eventually I found an x86 version of it in C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x86 and everything worked fine.
Properties->configurationManager-> ActiveSolutionPlatform . Here select x64 .thats all.
It should take care of all dependencies and compilation should work smoothly
module machine type is the machine on which you are compiling and the target machine type is the the architecture x86 or x64 for which you are building your binaries.
This problem may also happen if your project set up to have the same intermediate directories in Project Properties -> Configuration Properties -> General
this happens to me when i convert my VS2008 solution to VS2010 & change win32 configuration to X64, in my old solution I have mfcs90d.lib (Configuration->Linker->Input->Additional dependencies), as I am using VS010 i just checked in VS2010 folder where it is mfcs100d.lib, so I changed mfcs90d.lib to mfcs100d.lib in (Configuration->Linker->Input->Additional dependencies) it worked fine.
For those who are with QT Creator, the issue is same (as described by #c-johnson).
Make sure the compiler settings for MSVC in your kit is set to x86 as shown below.
for some using command prompt (dos prompt)
this might be helpful:
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" --help
Error in script usage. The correct usage is:
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" [option]
or
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" [option] store
or
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" [option] [version number]
or
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" [option] store [version number]
where [option] is: x86 | amd64 | arm | x86_amd64 | x86_arm | amd64_x86 | amd64_arm
where [version number] is either the full Windows 10 SDK version number or "8.1" to use the windows 8.1 SDK
:
The store parameter sets environment variables to support
store (rather than desktop) development.
:
For example:
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_arm store
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64 10.0.10240.0
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_arm store 10.0.10240.0
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 8.1
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 store 8.1
:
Please make sure either Visual Studio or C++ Build SKU is installed.
Also If you do like this:
CL "%1%2%3" /EHsc /link user32.lib Gdi32.lib Winmm.lib comctl32.lib *.obj /SUBSYSTEM:CONSOLE /MACHINE:x86
you have to del *.obj before; to avoid confusing linker with both 64 and 32 bit objects left over from prior compilations?
I have fixed this problem for myself as follows.
First of all, I followed the other answers for this question, only to conclude that all the project settings were correct.
Then I inspected the .vcxproj file with an editor and noticed that the < Link > properties for the two (Debug and Release) x64 configurations did not specify < TargetMachine >, while the Win32 configurations both contained < TargetMachine > MachineX86 < /TargetMachine >.
However, I had already verified, looking from Visual Studio at Properties > Configuration Properties > Linker > Advanced > Target Machine, that the x64 configurations said MachineX64 (/MACHINE:X64).
So, I edited the .vcxproj file to include < TargetMachine > MachineX64 < /TargetMachine > in the two x64 configs. Going back to the Visual Studio project properties dialog, I noticed that the MachineX64 (/MACHINE:X64) setting was there as before, except that now it showed in bold (apparently meaning that the value is not the default one).
I rebuilt, and it worked.

Resources