I'm trying to compile my project as a shared library using scons. I'm using Windows 7, and the Visual Studio 2013 RC. In the project, I'm using boost.
The project compiles fine. However, when it tries to link, I get the following:
scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
scons: Reading SConscript files ...
Compiling Glr
scons: Reading SConscript files ...
Parsing Shaders into header ShaderData.h
Done parsing Shaders into header ShaderData.h
scons: done reading SConscript files.
scons: Building targets ...
Using tempfile c:\users\jarrett\appdata\local\temp\tmpecwym3.lnk for command line:
link /nologo /dll /out:build\glr.dll /implib:build\glr.lib /LIBPATH:build /LIBPATH:src /LIBPATH:C:\Users\Jarrett\projects\angelscript-sdk\angelscript\lib /LIBPATH:C:\Users\Jarrett\projects\sqlite3 /LIBPATH:C:\Users\Jarrett\projects\berkelium-win32\lib /LIBPATH:C:\Users\Jarrett\projects\SFML\lib "/LIBPATH:C:\Program Files\Assimp\lib\x86" "/LIBPATH:C:\Program Files (x86)\Boost\lib" /LIBPATH:C:\Users\Jarrett\projects\FreeImage\Dist "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib" opengl32.lib glew32.lib berkelium.lib sfml-system.lib sfml-window.lib assimp.lib freeimage.lib libboost_log-vc120-mt-1_54.lib libboost_log_setup-vc120-mt-1_54.lib libboost_date_time-vc120-mt-1_54.lib libboost_thread-vc120-mt-1_54.lib libboost_wave-vc120-mt-1_54.lib libboost_regex-vc120-mt-1_54.lib libboost_filesystem-vc120-mt-1_54.lib libboost_system-vc120-mt-1_54.lib build\BasicSceneManager.obj build\BasicSceneNode.obj build\Camera.obj build\GlrProgram.obj build\GraphicsEngine.obj build\Light.obj build\Window.obj build\common\math\Math.obj build\common\io\File.obj build\BasicSceneManager.obj build\BasicSceneNode.obj build\Camera.obj build\GlrProgram.obj build\GraphicsEngine.obj build\Light.obj build\Window.obj build\exceptions\Exception.obj build\exceptions\FormatException.obj build\exceptions\GlException.obj build\exceptions\IoException.obj build\gui\CallbackParameter.obj build\gui\GUI.obj build\gui\GUIObject.obj build\gui\HtmlGuiComponent.obj build\models\Animation.obj build\models\AssImpLoader.obj build\models\Model.obj build\models\ModelLoader.obj build\models\ModelManager.obj build\glw\Animation.obj build\glw\AnimationManager.obj build\glw\Constants.obj build\glw\Material.obj build\glw\MaterialManager.obj build\glw\Mesh.obj build\glw\MeshManager.obj build\glw\OpenGlDevice.obj build\glw\Texture.obj build\glw\TextureManager.obj build\glw\shaders\CPreProcessor.obj build\glw\shaders\GlrParser.obj build\glw\shaders\GlrPreProcessor.obj build\glw\shaders\GlrShader.obj build\glw\shaders\GlrShaderProgram.obj build\glw\shaders\GlslShader.obj build\glw\shaders\GlslShaderProgram.obj build\glw\shaders\ShaderProgramManager.obj
link #c:\users\jarrett\appdata\local\temp\tmpecwym3.lnk
Using tempfile c:\users\jarrett\appdata\local\temp\tmpep9gzl.lnk for command line:
link /nologo /dll /out:build\glr.dll /implib:build\glr.lib /LIBPATH:build /LIBPATH:src /LIBPATH:C:\Users\Jarrett\projects\angelscript-sdk\angelscript\lib /LIBPATH:C:\Users\Jarrett\projects\sqlite3 /LIBPATH:C:\Users\Jarrett\projects\berkelium-win32\lib /LIBPATH:C:\Users\Jarrett\projects\SFML\lib "/LIBPATH:C:\Program Files\Assimp\lib\x86" "/LIBPATH:C:\Program Files (x86)\Boost\lib" /LIBPATH:C:\Users\Jarrett\projects\FreeImage\Dist "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib" opengl32.lib glew32.lib berkelium.lib sfml-system.lib sfml-window.lib assimp.lib freeimage.lib libboost_log-vc120-mt-1_54.lib libboost_log_setup-vc120-mt-1_54.lib libboost_date_time-vc120-mt-1_54.lib libboost_thread-vc120-mt-1_54.lib libboost_wave-vc120-mt-1_54.lib libboost_regex-vc120-mt-1_54.lib libboost_filesystem-vc120-mt-1_54.lib libboost_system-vc120-mt-1_54.lib build\BasicSceneManager.obj build\BasicSceneNode.obj build\Camera.obj build\GlrProgram.obj build\GraphicsEngine.obj build\Light.obj build\Window.obj build\common\math\Math.obj build\common\io\File.obj build\BasicSceneManager.obj build\BasicSceneNode.obj build\Camera.obj build\GlrProgram.obj build\GraphicsEngine.obj build\Light.obj build\Window.obj build\exceptions\Exception.obj build\exceptions\FormatException.obj build\exceptions\GlException.obj build\exceptions\IoException.obj build\gui\CallbackParameter.obj build\gui\GUI.obj build\gui\GUIObject.obj build\gui\HtmlGuiComponent.obj build\models\Animation.obj build\models\AssImpLoader.obj build\models\Model.obj build\models\ModelLoader.obj build\models\ModelManager.obj build\glw\Animation.obj build\glw\AnimationManager.obj build\glw\Constants.obj build\glw\Material.obj build\glw\MaterialManager.obj build\glw\Mesh.obj build\glw\MeshManager.obj build\glw\OpenGlDevice.obj build\glw\Texture.obj build\glw\TextureManager.obj build\glw\shaders\CPreProcessor.obj build\glw\shaders\GlrParser.obj build\glw\shaders\GlrPreProcessor.obj build\glw\shaders\GlrShader.obj build\glw\shaders\GlrShaderProgram.obj build\glw\shaders\GlslShader.obj build\glw\shaders\GlslShaderProgram.obj build\glw\shaders\ShaderProgramManager.obj
build\BasicSceneManager.obj : warning LNK4042: object specified more than once; extras ignored
build\BasicSceneNode.obj : warning LNK4042: object specified more than once; extras ignored
build\Camera.obj : warning LNK4042: object specified more than once; extras ignored
build\GlrProgram.obj : warning LNK4042: object specified more than once; extras ignored
build\GraphicsEngine.obj : warning LNK4042: object specified more than once; extras ignored
build\Light.obj : warning LNK4042: object specified more than once; extras ignored
build\Window.obj : warning LNK4042: object specified more than once; extras ignored
LINK : fatal error LNK1104: cannot open file 'libboost_log-vc110-mt-1_54.lib'
scons: building terminated because of errors.
scons: *** [build/glr.dll] Error 1104
I'm curious why it's trying to link to libboost_log-vc110-mt-1_54.lib instead of libboost_log-vc120-mt-1_54.lib, which is what I specified in the link command. Also, as far as I can tell, vcxxx is the compiler tag boost uses to tell what version of the compiler built the boost library...so it's almost like scons thinks boost was built using Visual Studio 2012, which would be vc110...I'm not sure.
Turns out, this is an issue with boost 1.54 not being aware of MSVC 2013.
I downloaded the boost trunk (1.55), compiled, and it linked properly.
Related
I have a Visual Studio 2017 project, where I'm trying to interface a C++ and Assembly program. So I have a header ("indexof.h") that has the Prototypes for the assembly procedures in an extern "C" block, and a main.cpp, which includes indexof.h and uses the procedures made available in it, and then an IndexOf.asm file that contains my assembly code (which also has prototypes for its procedures, before the .code section). Unfortunately, when I attempt to run it, I get this error:
1>Assembling IndexOf.asm...
1>MASM : fatal error A1000: cannot open file : IndexOf.asm
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\BuildCustomizations\masm.targets(50,5): error MSB3721: The command "ml.exe /c /nologo /Zf /Zi /Fo"Debug\IndexOf.obj" /W3 /errorReport:prompt /TaIndexOf.asm" exited with code 1.
1>Done building project "IndexOf_asm.vcxproj" -- FAILED.
I desperately need help (It's due tomorrow), this was a project setup provided by my class, I'm just trying to run it, and I haven't even gotten to the actual thing I need to do yet. Thank you!
I am trying to compile a simple program using scons + MSVC compiler under Windows. Program source is just simple "Hello world".
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!\n";
return 0;
}
SConstruct is utterly simple:
Program("hw.cc")
When I run scons in the source directory, I get
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fohw.obj /c hw.cc /TP /nologo
scons: *** [hw.obj] Error 123
scons: building terminated because of errors.
in the console and pop-up message with 0xc000007b error.
Aslo results of where command:
where cl
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\bin\Hostx86\x86\cl.exe
where scons
C:\Python35-32\Scripts\scons.bat
I don't have any clue what's wrong.
UPD
SCons debug output
UPD 2
After some experiments with cl and scons I have finally figured out what was wrong and how to fix it.
First of all, cl should be available from the command line. If after entering command cl in the console you get errors like command not found, you should add path to cl.exe to the PATH system variable. In my case
PATH=<rubbish>;C:\Microsoft\VC\Tools\MSVC\14.14.26428\bin\Hostx86\x86;
After this you should set up variables INCLUDE and LIB to tell compiler and linker where to find include files and libs. And this part is a little bit tricky, because, to my surprise, cl does not compiling anything without Windows Kits 10 (whatever it is). Thus, you should specify its includes and libs accordingly. In my case
INCLUDE=C:\Microsoft\VC\Tools\MSVC\14.14.26428\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt
LIB=C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17134.0\ucrt\x86;C:\Microsoft\VC\Tools\MSVC\14.14.26428\lib\x86;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17134.0\um\x86
When these variables are set up correctly, hw.cc should compile fine.
And, probably, this should do the trick for scons too, but to make one hundred percent sure it works correctly, SConstruct should be modified to something like this
import os
env = Environment(ENV = os.environ)
flags = ["/EHsc"] # Flags are completely optional
env.Program("hw.cc", CXXFLAGS=flags)
With all these steps, everything should compile fine.
Trying to build libxml2 from source from the current master branch:
https://github.com/GNOME/libxml2
I'm working in Windows 10 environment and trying to build the msvc variant. Following the readme here:
https://github.com/GNOME/libxml2/tree/master/win32
My steps for building are:
1. Open Developer Command Prompt for VS 2017 as admin.
2. Navigate to libxml2\win32.
3. Running the following command: cscript configure.js compiler=msvc prefix=c:\opt include=c:\opt\include lib=c:\opt\lib debug=yes
4. nmake /f Makefile.msvc
5. Getting the following: LINK : fatal error LNK1104: cannot open file 'iconv.lib'
Note that i do have the required environment variables set for the libiconv that I use for other projects in my LIB and LIBPATH variable, I also tried adding to PATH even though it's not nececcasry as VS environment cmd reads the LIB and LIBPATH.
(C:\projects\libraries\libiconv\1.9.2-vc110-32bit\Release\lib)
I'm thinking the reason I get this linking error, is because libiconv needs to be build under msvc141(VS17) too?
https://git.savannah.gnu.org/git/libiconv.git
That would cool if it's not the case, as I might need to change a lot in the project if things are updated there, because when I tried building libxml2 with VS12 and VS15 developer command prompt, I got different error in code compatibility, as I guess the owner of the repo doesn't support these versions anymore or they just work in VS17 environment.
Thanks in advance for the help!
Full output:
C:\projects\libraries\libxml\2.7.8-vc110-32bit\Release\bin\libxmlNEW\libxml2\win32>nmake /f Makefile.msvc
Microsoft (R) Program Maintenance Utility Version 14.12.25835.0
Copyright (C) Microsoft Corporation. All rights reserved.
if not exist bin.msvc mkdir bin.msvc
if not exist int.msvc mkdir int.msvc
cl.exe /EP /nologo /I..\include /D "NOLIBTOOL" /D "_REENTRANT" libxml2.def.src > int.msvc\libxml2.def
libxml2.def.src
rc -Fo int.msvc\libxml2.res libxml2.rc
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation. All rights reserved.
cl.exe /nologo /D "_WINDOWS" /D "_MBCS" /D "NOLIBTOOL" /W3 /wd4244 /wd4267 /MD /I.. /I..\include /Ic:\opt\include /D "_REENTRANT" /D "HAVE_WIN32_THREADS" /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /D "_DEBUG" /Od /Z7 /Foint.msvc\ /c ..\buf.c ..\c14n.c ..\catalog.c ..\chvalid.c ..\debugXML.c ..\dict.c ..\DOCBparser.c ..\encoding.c ..\entities.c ..\error.c ..\globals.c ..\hash.c ..\HTMLparser.c ..\HTMLtree.c ..\legacy.c ..\list.c ..\nanoftp.c ..\nanohttp.c ..\parser.c ..\parserInternals.c ..\pattern.c ..\relaxng.c ..\SAX2.c ..\SAX.c ..\schematron.c ..\threads.c ..\tree.c ..\uri.c ..\valid.c ..\xinclude.c ..\xlink.c ..\xmlIO.c ..\xmlmemory.c ..\xmlreader.c ..\xmlregexp.c ..\xmlmodule.c ..\xmlsave.c ..\xmlschemas.c ..\xmlschemastypes.c ..\xmlunicode.c ..\xmlwriter.c ..\xpath.c ..\xpointer.c ..\xmlstring.c
buf.c
c14n.c
catalog.c
chvalid.c
debugXML.c
dict.c
DOCBparser.c
encoding.c
entities.c
error.c
globals.c
hash.c
HTMLparser.c
HTMLtree.c
legacy.c
list.c
nanoftp.c
..\nanoftp.c(927): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winsock2.h(2218): note: see declaration of 'gethostbyname'
..\nanoftp.c(929): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winsock2.h(2218): note: see declaration of 'gethostbyname'
nanohttp.c
parser.c
parserInternals.c
Generating Code...
Compiling...
pattern.c
relaxng.c
SAX2.c
SAX.c
schematron.c
threads.c
tree.c
uri.c
valid.c
xinclude.c
xlink.c
xmlIO.c
xmlmemory.c
xmlreader.c
xmlregexp.c
xmlmodule.c
xmlsave.c
xmlschemas.c
xmlschemastypes.c
xmlunicode.c
Generating Code...
Compiling...
xmlwriter.c
xpath.c
xpointer.c
xmlstring.c
Generating Code...
link.exe /nologo /VERSION:2.9 /LIBPATH:bin.msvc /LIBPATH:c:\opt\lib /DEBUG /DLL /IMPLIB:bin.msvc\libxml2.lib /OUT:bin.msvc\libxml2.dll int.msvc\buf.obj int.msvc\c14n.obj int.msvc\catalog.obj int.msvc\chvalid.obj int.msvc\debugXML.obj int.msvc\dict.obj int.msvc\DOCBparser.obj int.msvc\encoding.obj int.msvc\entities.obj int.msvc\error.obj int.msvc\globals.obj int.msvc\hash.obj int.msvc\HTMLparser.obj int.msvc\HTMLtree.obj int.msvc\legacy.obj int.msvc\list.obj int.msvc\nanoftp.obj int.msvc\nanohttp.obj int.msvc\parser.obj int.msvc\parserInternals.obj int.msvc\pattern.obj int.msvc\relaxng.obj int.msvc\SAX2.obj int.msvc\SAX.obj int.msvc\schematron.obj int.msvc\threads.obj int.msvc\tree.obj int.msvc\uri.obj int.msvc\valid.obj int.msvc\xinclude.obj int.msvc\xlink.obj int.msvc\xmlIO.obj int.msvc\xmlmemory.obj int.msvc\xmlreader.obj int.msvc\xmlregexp.obj int.msvc\xmlmodule.obj int.msvc\xmlsave.obj int.msvc\xmlschemas.obj int.msvc\xmlschemastypes.obj int.msvc\xmlunicode.obj int.msvc\xmlwriter.obj int.msvc\xpath.obj int.msvc\xpointer.obj int.msvc\xmlstring.obj int.msvc\libxml2.res wsock32.lib ws2_32.lib iconv.lib kernel32.lib
LINK : fatal error LNK1104: cannot open file 'iconv.lib'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\bin\HostX86\x86\link.exe"' : return code '0x450'
Stop.
Note for future readers.
There is a way to build libxml2 without iconv dependency.
For that you need to use:
cscript configure.js compiler=msvc prefix=c:\opt include=c:\opt\include lib=c:\opt\lib debug=yes iconv=no
first, you need to make sure all these packages are build under same arch, which is either all x86 or x64, then libxml2's makefile don't recognize custom INCLUDE and LIB folders, you need to add those folder's into INCLUDE and LIB enviroment variables.
set INCLUDE=%INCLUDE%;<your include dir>
set LIB=%LIB%;<your lib dir>
which should let you compile.
I'm trying to compile a C++ program from the VS2013 command window with includes and linked libraries. Pretty standard stuff. However, Microsoft's website explaining the syntax is not very clear to me.
I'm trying the following command:
cl /EHsc program.cpp /I "\path\to\includes"
/LIBPATH:"\path\to\library\directory" /LINK libfile1.lib libfile2.lib
Note: It's all on one line when I execute it, but for readability I've split it here.
The quotes are because some of the directories in the paths have whitespace in them beyond my control (like Program Files).
I'm trying to adapt this command from a property sheet I made using the Visual Studio interface, so if it helps, the mapping I'm making is:
IncludePath --> /I
LibraryPath --> /LIBPATH:
AdditionalDependencies (under Link) --> /LINK
I am running this as an admin in the x64 Native Tools Command Prompt on a machine running 64-bit Windows 10. However, it gives me these warnings and errors:
cl: Command line warning D9002: ignoring unknown option '/LIBPATH:\path\to\library\directory'
cl: Command line warning D9002: ignoring unknown option '/LINK'
LINK : fatal error LNK1181: cannot open input file 'libfile1.lib'
Where am I going wrong?
The /link option must be lowercase and place the /LIBPATH option after it:
cl /EHsc program.cpp /I "\path\to\includes" /link /LIBPATH:"\path\to\library\directory" libfile1.lib libfile2.lib
try to add the lib's path to your Library Directories (Configuration Properties >> VC++ Directories).
and compile again
I am getting a really strange linker error appearing:
link.exe : fatal error LNK1107: invalid or corrupt file: cannot read at 0x270
But this is strange, because usually the error message tells you what object is invalid or corrupt. In other words, typically this error message looks something like this:
myDLL.dll : fatal error LNK1107: ....
However, in this case, the invalid object is the application itself (link.exe) that is running!
I've tried replacing the executable with another copy that I know is valid. Same error.
The command I am running is this:
../vendor/microsoft/msdev80_2005/VC/bin/link.exe /NOLOGO /SUBSYSTEM:CONSOLE /LIB
PATH:../vendor/microsoft/msdev80_2005/VC/atlmfc/lib /LIBPATH:../vendor/microsoft
/msdev80_2005/VC/lib /LIBPATH:../vendor/microsoft/msdev80_2005/VC/PlatformSDK/Li
b /LIBPATH:lib/win32/dbg /OUT:bin/win32/dbg/bugshow.exe Advapi32.lib ws2_32.lib
bugshow/obj/win32/dbg/main.o libA.lib libB.lib libC.lib libD.lib
main.o is getting compiled using the following compiler directive:
../vendor/microsoft/msdev80_2005/VC/bin/cl.exe /nologo /X /w /EHsc -I../vendor/m
icrosoft/msdev80_2005/VC/atlmfc/include -I../vendor/microsoft/msdev80_2005/VC/in
clude -I../vendor/microsoft/msdev80_2005/VC/PlatformSDK/Include /D_WIN32 /DBOOST
_USE_WINDOWS_H /DWIN32_LEAN_AND_MEAN /D_WIN32_WINNT=0x0501 /DBOOST_THREAD_USE_LI
B /DBOOST_ALL_NO_LIB /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /Z7
/MTd /c -I../vendor/boost.org/boost/1.45.0/include /Fobugshow/obj/win32/dbg/main.o
bugshow/main.cpp
Any ideas why link.exe would be failing like this?
UPDATE:
When I add the folder that link.exe resides in to my PATH, and then call link.exe without the path prefix, I get the following error instead:
LINK: fatal error LNK1181: cannot open input file 'link.exe'
Why is link.exe trying so desperately to open itself??!?!
I figured out the problem!
There is a nasty little ENVIRONMENT variable that the MSVC linker uses (described here) on Microsoft's MSDN page. It says:
LINK, if defined, prepends arguments in the command line.
My system had the environment variable LINK defined as STATIC by a recent application I installed. This caused link.exe to interpret the command-line instantiation of itself as follows:
STATIC link.exe /NOLOGO /SUBSYSTEM:CONSOLE ...
In other words, *argv[1] which is usually the first command line parameter, was actually link.exe. It basically bumped all the arguments down by one offset. This in turn caused link.exe to try and interpret itself as its first input file!
Absolutely, unbelievably frustrating and hard to detect problem...
I read that it produces this error when you've included a header file (.h) in your Linker. I had this problem and solved it by removing the .h in Linker > Input > Addtl Dependencies