For a client I am attempting to recreate a command line based build tool in the Visual Studio 2010 IDE. The compilation of the libs from projects including the C/C++ source files I have nailed, the link command line is giving me grief because the executable only links correctly if the libs are given in precisely the same order as the command line tool.
The command line is something like this:
link.exe -subsystem:console -machine:I386 -verbose:lib
-nodefaultlib:libc.lib -nodefaultlib:libcd.lib -nodefaultlib:libcmt.lib -nodefaultlib:libcmtd.lib
-DEBUG
-out:myout.exe
-pdb:myout.pdb
-libpath:../../path/to/libs
libcmtd.lib kernel32.lib user32.lib ws2_32.lib netapi32.lib comctl32.lib gdi32.lib comdlg32.lib advapi32.lib winmm.lib imagehlp.lib shell32.lib
x_mylib.lib a_mylib.lib y_mylib3.lib z_my.lib etc....
If the .libs the IDE compiles are linked with this command line then the .exe is correct, however I cannot get the IDE to link with precisely this .lib order – it insists on sorting all the libs alphabetically and linking.
Any ideas anyone?
avoiding the temptation to wander off into philosphical debates about the sense of this all, I can’t change the command line based build tool
So, after much fiddling an answer as such…
As described above there are projects in the solution that link to their corresponding static libs:
a_mylib.vcxprojb_mylib.vcxproj
...
x_mylib.vcxproj
y_mylib.vcxproj
z_mylib.vcxproj
Adding another static library project
my_libs.vcxprojwhich has no source files but contains all the above as dependencies makes the whole source code easy to build. Finally the executablemy_exe.vcxprojis added which contains only my_libs as a dependency and all the ?_mylib.libs as specific linker input in the order required.Easy when you know how.