The idea is to compile a C++ program. It contains a main.cpp
, a printer.cpp
, a printer.h
, a scanner.cpp
and scanner.h
. These source files have one function print "hello". Now I am trying to create the object files and executables from the command line through a Python script and using cl.exe
.
The error I get is LNK2019
so I know the issue is in the linking. I have looked though the options and I am using this for my Python !!
build = subprocess.Popen(['vcvarsall.bat', 'amd64_x86', '&&', 'cl', 'kernel32.lib',...[skipping some files]'uuid.lib','/I' + qtpath,'C:\\Users\\ROY_S\\Desktop\\CppMaker\\main.cpp','/ZI','/Gm','/EHsc','/MDd','/GS','/Fo'+path,'/Fe'+path+'main.exe','/link','/LIBPATH:'+qtlib,'/DEFAULTLIB:'+ qtlib+'QtMainIsar','/DEFAULTLIB:'+ qtlib+'QtCore','/DEFAULTLIB:'+ qtlib+'QtGuiIsar4','/DEFAULTLIB:'+ qtlib+'QtNetwork','/DEFAULTLIB:'+ qtlib+'QtOpenGLIsar4','/DEFAULTLIB:'+ ...[skipping...] qtlib+'QtWebKitIsar4','/INCREMENTAL','/NOLOGO','/TLBID:1','/DYNAMICBASE','/MANIFEST','/NXCOMPAT','/ERRORREPORT:PROMPT','/MACHINE:'+'X86','/OUT:'+path+'main.exe' ] , stdout=subprocess.PIPE)
I removed some libs so that its easier to read. I dont understand how do I link everything even after specifying the lib files in my script.
I can also move on to other solution instead of using cl.exe
. Anything that has easy control over the commandline I am okay with it.
In windows I think it's a good idea to use Visual Studio project/solution and build it using MsBuild. Project/solution file may be created manually or in Visual Studio. You may also create properties in project/solution and pass them in MsBuild (see MsBuild documentation)