Click here to Skip to main content
Click here to Skip to main content

Tool for Converting VC++2005 Project to Linux Makefile

By , 13 Jul 2012
 

Introduction

This tool automatically converts Visual C++ 8.0 or 9.0 projects to Linux makefile. Important note, there is no loss during the conversion: source code and .sln/.vcproj files are left unchanged. The tool has been implemented in C# VS 2005.

Why?

  • Your application is cross-platform based.
  • Now you are facing a decision to migrate from Visual C++ 6 to 8 or 9.

Both these reasons force you to create a makefile manually and each small change in your project requires hard physical labor in makefile maintenance.

This tool will do it for you automatically and will provide you with the ability to keep .sln/.vcproj and .mak files synchronized.

Using the Tool

The tool is a command line (console application).

There are three cases for tool use I covered in this article:

  1.  You have a .sln - solution that has one or more .vcproj (projects), among which one of them has the same name as the solution itself and is the main/leading project. This leading project should be a target project that will be compiled into .exe or .dll. Other projects in this solution are dependencies for the leading project. Makefiles will not be generated for those projects that do not have dependencies. Sub-projects can have additional dependencies on external precompiled libraries (libs), stdlib.
  2. You should not sign those dependencies explicitly for a tool; it will be parsed from .vcproj files.

    In this case, the usage:

    sln2mak [Solution_FullPath_File_Name].sln

    Example:

    sln2mak c:/myprojects/test/unit_test.sln
  3. The same case as 1, except that the leading project has a name that is different from the solution name. Flag –l for leading followed by leading project name and then solution fullpath.  
  4. In this case, the usage:

    sln2mak -l [LEADING_Project_Name] [Solution_FullPath_File_Name].sln

    Example:

    sln2mak -l unit_test c:/myprojects/test/test.sln
  5. You'd like to create a makefile from a list of projects without solution "wrapper". For example, you'd like to create a makefile with different structures, not like the one you have for WindowsOS.

    You have a main/leading project and other projects are dependencies of that.

    In addition, you have some precompiled libraries (libs) that you'd like to see them as dependencies for the leading project.  However, they are not listed in the main .vcproj. How can it be, you'll ask? For example, in some solution you have your leading project with all its sub-projects. One of those projects, that the leading project is dependent on, has a dependencies to some precompiled libraries and those are listed within its .vcproj file. So if you use the tool for the whole solution, those dependencies for linker will be parsed from this project and will be listed in its .mak file and then linked by linker to the main/leading project well. But now you'd like to compile only specific list of project that don’t involve  the dependent project, so you  are required to list those libs dependencies manually. Flag –d for dependencies followed by the list of those libs dependencies. 

    sln2mak [LEADING_Project_FullPath_Name].vcproj [Project_FullPath_Name_2].vcproj ... 
             [Project_FullPath_Name_n].vcproj -d [lib_Name_1] ... [lib_Name_n]

    Example:

    sln2mak c:/myprojects/tets/unit_test.vcproj c:/myprojects/tets/test_lib.vcproj 
        -d mystaticlib1 mystaticlib2 mystaticlib3 

    For usage, call sln2mak with no arguments.  

    After application runs, you'll find .mak file in path where .vcproj is located with the same name as the project.

    .mak files have all additional libraries path, sources, flags for compiler, linker, preprocessor and target path. 

In .sln path, you'll find Makefile that will handle all target rules (clean, make) and dependencies.

sln2mak/Makefile.JPG

Points of Interest

Parser Class

This class has a static constructor that aims to be known for all classes without instantiation.

It holds regular expression that serves all other classes for parsing .sln and .vcproj files.

Regex m_ProjectGuid      = new Regex(@"ProjectGUID=""\{(.*)\}"""        ) ;
Regex m_SlnExtention     = new Regex(@"(.*)(.[Ss][Ll][Nn])$"            ) ;
Regex m_VcprojExtention  = new Regex(@"(.*)(.[Vv][Cc][Pp][Rr][Oo][Jj])$") ;
Regex m_ProjectRegex     = new Regex(@"Project\(""\{(.*)\}""\) = ""(.*)"", ""(.*)"",
   ""\{(.*)\}""") ;

VcSlnInfo Class

This class parses solution file and creates Makefile with target rules.

This class uses stream reader for reading .sln file line by line. During reading .sln file, it recognizes an active project (its name is similar to the solution name) and creates four dictionaries that hold information about all main and dependent projects:

  • Key = Guid number , Value = ProjectName
  • Key = ProjectName , Value = ProjectFullPath
  • Key = ProjectName , Value = MakeFileName
  • Key = ProjectName , Value = ProjectDependencies
Dictionary<string, string>  m_ProjGuidName = new Dictionary<string, string>() ;

Then method ParseVcproj is called - public VcProjInfo class's function, but first for each .vcproj  instance of VcProjInfo object created with projectName, projectFullPath and projectMakFileName.

VcProjInfo Class

In this class, VCProjectEngine object is used for retrieving all the necessary information about .vcproj, like target type and name, compiler flags, additional libraries, linker flags, sources and filters, preprocessor definitions, configurations, etc.

using Microsoft.VisualStudio.VCProjectEngine;
VCProjectEngine vcprojEngine = new VCProjectEngineObject();
//Init VCProject vcProj object
VCProject m_VcProj = (VCProject)vcprojEngine.LoadProject(vcProjFile);

//Init vcproj configurations list 
IVCCollection m_ConfigCollection = (IVCCollection)m_VcProj.Configurations;

All these helped me to create .mak file with CFLAGS, LDFLAGS, OBJS, etc.

Important Notes

  • There is no loss during the conversion: source code stays unchanged.  
  • Probably I did not cover all flags during parsing from .vcproj to .mak, but now you have all necessary information to be able to add anything I've missed.
  • During my work I inspect that there are few differences between VC++ 8 solution/vcproj and VC++ 9, so you can use this tool for both.
  • If you convert this source code to Visual Studio 2008, please use proper Microsoft.VisualStudio.VCProjectEngine reference version 9.0.0.0 instead of 8.0.0.0.

History  

Prior to writing the application, I tried to find a similar tool on the internet, but was only successful in finding other people's questions on online forums regarding the issue.
Then I attempted to understand XML-schema of a VC++8 solution and project, but the schema wasn't clear enough.

Suddenly I found a Microsoft.VisualStudio.VCProjectEngine reference with VCProjectEngine object within .NET components which helped me to understand the structure of a VC++ 2005 project. I used this object in my application for .vcproj parsing instead of using System.Xml for XML tree reading, and this without proper XML schema documentation.

sln2mak/reference.JPG

Disclaimer 

The information provided on this page comes without any warranty whatsoever.  

This tool has been extensively tested before being published, but always there is the possibility to find some weakness. I strongly recommend that you back up your project before using this tool. Moreover, though I am willing to know if there is anything I can do in order to improve it, let me clearly say that it's not my fault if your project is corrupted by this tool.

Update History  

  • 20/4/2009 Bug fixes (sorry for long delay)
    • Added some spaces in dependencies
    • Removed a loop which was creating multiple rules for a single project
    • Added uppercase WIN32 to be replaced by uppercase LINUX
    • Removed -o option for CPP files
    • Removed printing of "else"
    • Full path for dependent project fixed.

    Especially thanks to Ahmad and Adrej, who helped me to find and fix all listed bugs.

  • 6/9/2008 Bug fixes
    • Uses sln2mak.exe from the same path as .sln/.vcproj.
  • 16/9/2008 Bug fixes 
    • Handles null reference for VC compiler tool, recursive file filters expanding during sources list creation

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Maria Adamsky
Software Developer EFC Real Solutions on Time,LTD
Israel Israel
Member
Software developer at EFC Real Solutions on Time,LTD(Israel) in infrastructure team.
Developing Grid computing application for data communication simulations.
Writing Cross-Platform Software (Windows and Linux).

Comments and Discussions

 
QuestionProblems when using sln2mak in VS2010 [modified]memberShuai Zhang13 May '13 - 2:47 
Hi Maria,
 
I'm trying to use sln2mak to work with VS2010 solutions, and i think i have made the necessary changes to the sln2mak project, just as PeterFig put it.
 
(1)Set Target Framework to 4.0 (right click your project node, click “Properties”, click “Application” tab, set the target framework to .net framework 4.)
(2)Add a reference to Microsoft.VisualStudio.VCProjectEngine (that got rid of the old reference to 8.0 that was yellow-flagged)
(3)Add a reference to Microsoft.CSharp

 
the sln2mak can be compiled successfully, but i got a System.Runtime.InteropServices.COMException with the following code when trying to run the exe:
VCProjectEngine vcprojEngine = new VCProjectEngineObject();
it seemed that a question in the stackoverflow had solve the COMException by changing platform target to x86. Well, the COMException did indeed disappear but a System.InvalidCastException is caused, saying :
 
An unhandled exception of type 'System.InvalidCastException' occurred in ProjectEngine.exe
Additional information: Unable to cast object of type 'Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectEngineShim' to type 'Microsoft.VisualStudio.VCProjectEngine.VCProjectEngineObject'.

 
I tried to find a solution to fix this InvalidCastException but with little success.
 
can you kindly give me any hits?
i am looking forward to hearing from you.
Thanks and best regards.
 
shuai
 
http://stackoverflow.com/questions/4021796/error-80040154-class-not-registered-exception-when-initializing-vcprojectengin[^]
http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/f8c373da-9c3c-427d-a46c-b8739071eb1b[^]

modified yesterday.

QuestionUse sln2mak for fortran projectsmemberMartin Estrada22 Mar '13 - 6:45 
I am working on a big fortran solutions with 4 projects that was already implemented in Visual Studio. I need a makefile for that so I can continue working in linux.
 
May I use sln2mak to generate makefiles from Visual Studio fortran solutions and projects?
AnswerRe: Use sln2mak for fortran projectsmemberMaria Adamsky23 Mar '13 - 0:38 
You should download the code and customize it, because project files have different extensions. For additional, i am pretty sure that fortrain project may have different flags for compiler and linker, but the main solution design should be fine, only some small changes.
There is nothing impossible.

QuestionUnhandled COMExceptionmemberMember 938139515 Mar '13 - 7:39 
Debugging the application in VisualStudio 8, on
 
VCProjectEngine vcprojEngine = new VCProjectEngineObject();
 

I get the following error:
 
COMException was unhandled
Recupero della class factory COM per il componente con CLSID {FBBF3C66-2428-11D7-8BF6-00B0D03DAA06} non riuscito a causa del seguente errore: 80040154.
 
The reference in the Solution Explorer seems to be ok, but it doesn't work.
 
Can you give me a hint?
Thank you in advance.
Alessandro Piersanti.
AnswerRe: Unhandled COMExceptionmemberMaria Adamsky23 Mar '13 - 0:47 
I am not familiar with this error, try google it.
Or remove and add again the reference.
There is nothing impossible.

AnswerRe: Unhandled COMExceptionmemberHowitZer2619 Apr '13 - 8:08 
You may need to run regsvr32 on the VCProjectEngine dll.
GeneralRe: Unhandled COMExceptionmemberMaria Adamsky20 Apr '13 - 1:27 
Thumbs Up | :thumbsup:
There is nothing impossible.

QuestionUnhandle ExceptionmemberMrKyaw1 Nov '12 - 6:55 
Dear Maria,
 

I tried to compile many times and here is my error below(I added sln2mak in the *.sln folder then run)
 
C:\Users\PicTrans_src\PicTrans>sln2mak.exe PicTrans.sln
sln2mak.exe - Generates a Makefile from a .sln/.vcproj file .
c Maria Adamsky (www.EFC.CO.IL)
 
Creating file Makefile...
Going to read project file 'PicTrans/PicTrans.csproj'
aiming to write result to file 'PicTrans/PicTrans.csproj'
With no dependencies.
 

Unhandled Exception: System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {FBBF3C66-2428-11D7-8BF
6-00B0D03DAA06} failed due to the following error: 80040154.
at sln2mak.VcProjInfo..ctor(String vcProjFile, String outFile, String[] projDependencies)
at sln2mak.VcSlnInfo.iSendToParseVcprojFiles()
at sln2mak.VcSlnInfo.GenerateMakefile(Boolean parseVcproj)
at sln2mak.VcSlnInfo.GenerateMakefile()
at sln2mak.Parser.ParseSln(String projName, String slnFName)
at sln2mak.Program.Main(String[] args)
 

Pls advise me and i am looking forward to hearing from you.
 
Thanks and best regards
AnswerRe: Unhandle ExceptionmemberMaria Adamsky1 Nov '12 - 8:23 
Hi,
Is your solution VS2008?
If so, read "Important notes" section that explains what reference should be replaced to work with VS2008 projects.
Regards, Maria.
There is nothing impossible.

AnswerRe: Unhandle ExceptionmemberMaria Adamsky1 Nov '12 - 8:30 
On second opinion, it could be because you placed the tool into the same folder where sln is, put it on separate folder, but on passing to it arguments give the whole solution path.
I hope it will help.
Regards,
Maria.
There is nothing impossible.

GeneralRe: Unhandle ExceptionmemberPeterFig21 Nov '12 - 10:00 
I am getting the same exception in the VcProjInfo ctor. The tool is not in the same folder. I am using VS2010 and replaced the reference per my message below (VS 2010 thread). Mine says "Class not registered." It certainly sounds like a VS configuration problem and not anything wrong with your code. Still, I don't what to do (I don't understand the error or what is causing it).
GeneralRe: Unhandle ExceptionmemberNamrata Shet5 Dec '12 - 1:37 
Dear Maria,
 
I am have VS2005 solution . I am trying to generate Makefile
I am getting following exception :
 
E:\Internal_project\sln2mak>sln2mak.exe E:/Project/abc_11252/abc.sln
sln2mak.exe - Generates a Makefile from a .sln/.vcproj file .
c Maria Adamsky (www.EFC.CO.IL)
 
Creating file E:\Project\abc_11252/Makefile...
 
Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given
key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at sln2mak.VcSlnInfo.iPrintDefaultTargetRule()
at sln2mak.VcSlnInfo.GenerateMakefile(Boolean parseVcproj)
at sln2mak.VcSlnInfo.GenerateMakefile()
at sln2mak.Parser.ParseSln(String projName, String slnFName)
at sln2mak.Program.Main(String[] args)
GeneralRe: Unhandle Exceptionmemberc0mas25 Mar '13 - 7:09 
It happened when the name of the project in .sln file was different from the name in the .vcproj.
GeneralRe: Unhandle ExceptionmemberMaria Adamsky25 Mar '13 - 8:19 
In this case, see the usage.
There is nothing impossible.

GeneralRe: Unhandle Exceptionmemberc0mas26 Mar '13 - 0:15 
Indeed, that fixes the issue, but I didn't knew the crash cause without a little debugging Smile | :)
AnswerRe: Unhandle Exceptionmemberc0mas25 Mar '13 - 7:06 
I had the same problem, I fixed it by compiling it as x86 instead of "any CPU" or x64.
Questionnot working crapmemberVadim Zyarko8 Oct '12 - 8:43 
gives me stack dump on each/any run
AnswerRe: not working crapmemberMaria Adamsky10 Oct '12 - 2:12 
Not too much information....
There is nothing impossible.

GeneralRe: not working crapmemberHenry Fang28 Oct '12 - 17:24 
Hi, Maria!
I can't download the zip files(sln2mak.zip and sln2mak_bin.zip). Can you email them to my emailbox: fanghongbing@126.com?
 
Thanks
QuestionVisual Studio 10 and 11membervit_lynx13 Jul '12 - 1:13 
How about Visual Studio 10 and 11?
GeneralRe: Visual Studio 10 and 11memberMaria Adamsky13 Jul '12 - 4:22 
I never tested it on VS 10 and 11, but i don't think it should be problem. Just convert the project and replace maybe the reference to VCProjectEngine.
There is nothing impossible.

AnswerRe: Visual Studio 10 and 11memberPeterFig21 Nov '12 - 8:48 
To get sln2mak to build in VS2010, I did this:
(1)Set Target Framework to 4.0 (right click your project node, click “Properties”, click “Application” tab, set the target framework to .net framework 4.)
(2)Add a reference to Microsoft.VisualStudio.VCProjectEngine (that got rid of the old reference to 8.0 that was yellow-flagged)
(3)Add a reference to Microsoft.CSharp
 
Now let's see how well it works!
GeneralRe: Visual Studio 10 and 11memberMaria Adamsky21 Nov '12 - 10:10 
I'll be glad to hear how it worked.
There is nothing impossible.

QuestionRe: Visual Studio 10 and 11memberHowitZer265 Dec '12 - 5:23 
Peter, did you ever get this to work? I'm using VS2012 -- when I try to allocate a VCProjectEngine as follows:
VCProjectEngine m_vcprojEngine = new VCProjectEngineObject(); 
I get the following error:
 
Retrieving the COM class factory for component with CLSID {4547A58D-FC1C-4502-84
FA-0163EE766635} failed due to the following error: 80040154 Class not registere
d (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

 
I've tried the mechanism to register the .dll that worked in VS2008 (using regsvr32) but that does not work on the new VS2012 .dll. Any suggestions much appreciated.
Questiondoes not work in XP ??memberMember 915682722 Jun '12 - 4:49 
not functional: can not find path error or argument length less than zero error Confused | :confused:
AnswerRe: does not work in XP ??memberMaria Adamsky12 Jul '12 - 21:34 
Works fine in XP.
You are not the first with this error, try follow answers posted earlier.
There is nothing impossible.

QuestionWin 7 x32 attempt?memberKenLThomas7 Jun '12 - 10:36 
I was wondering if you or anyone else has tried using on a Win 7 32 machine? Specifically recompiling on the Win 7 platform (with MSVS 2008) and run the sln2mak exe on the same platform. I have not been able to have it run without crashing.
 
Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given
key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at sln2mak.VcSlnInfo.iPrintDefaultTargetRule()
at sln2mak.VcSlnInfo.GenerateMakefile(Boolean parseVcproj)
at sln2mak.VcSlnInfo.GenerateMakefile()
at sln2mak.Parser.ParseSln(String projName, String slnFName)
at sln2mak.Program.Main(String[] args)
GeneralRe: Win 7 x32 attempt?memberMember 795545011 Jul '12 - 14:08 
A have same problem. Win 7 Ultimate, 64-bit.
Creating file Makefile...
 
Neošetřená výjimka: System.Collections.Generic.KeyNotFoundException: Daný klíč není ve slovníku k dispozici.
   v System.ThrowHelper.ThrowKeyNotFoundException()
   v System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   v sln2mak.VcSlnInfo.iPrintDefaultTargetRule()
   v sln2mak.VcSlnInfo.GenerateMakefile(Boolean parseVcproj)
   v sln2mak.VcSlnInfo.GenerateMakefile()
   v sln2mak.Parser.ParseSln(String projName, String slnFName)
   v sln2mak.Program.Main(String[] args)
(I'm sorry, but I have a Czech distribution of Windows.)
GeneralRe: Win 7 x32 attempt?memberMaria Adamsky12 Jul '12 - 21:33 
There is nothing related to Win7 or 64 bit or Czech distribution, just wrong argument line or solution structure is not tool expects. You are not the first with this error, try follow answers posted earlier.
There is nothing impossible.

QuestionLittle improvement for non-project directories in slnmemberMember 895463610 May '12 - 1:12 
Very good software! It works fine and fast, really it is a very nice tool.
 

I have used it successfully ... after a small modification. I quickly expose it here if it can help.
 
My SLN links towards some directories where there is no vcproj; the application crashes somewhere when parsing, with a great message:

Exception: System.ArgumentOutOfRangeException: The length cannot be negative.
Name of parameter : length
in System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
...
 
In order to do the job correctly, I have put a little test when parsing the names of sub-projects (file VcSlnInfo.cs, line 113):
if (matchProjInfo.Groups[3].Value == matchProjInfo.Groups[2].Value)
{
    continue;
}
 
Basically, it is just based on the fact that the parsing put the name of the directory if no vcproj is found. This a little rough ... but it works after all Smile | :) .
AnswerRe: Little improvement for non-project directories in slnmemberMaria Adamsky11 May '12 - 1:21 
Thank youSmile | :)
There is nothing impossible.

QuestionSome bugs?memberGzork22 Mar '12 - 11:01 
Hello!
 
I had some troubles running the application when ONLY ONE vcproj file is passed as argument.
 
The following methods throws an exception since no path for solution file is set:
iPrintTargetRules        (         ) ;  //PHONY:target
iPrintClenOrDependsRules ("clean"  ) ;  //PHONY:clean
 
I think the line
Int32 stripStart = Path.GetDirectoryName(m_SlnFullPath).Length + 1;
must be replaced with
Int32 stripStart = (m_SlnFullPath != String.Empty) ? Path.GetDirectoryName(m_SlnFullPath).Length + 1 : 0;
In order to avoid those exceptions.
 
Thanks a lot!!!
AnswerRe: Some bugs?memberMaria Adamsky12 Jul '12 - 21:38 
If you run the tool with one vcproj and use for it 'case 3' arguments template, then the code will never reach those lines you try to fixSmile | :)
There is nothing impossible.

GeneralMy vote of 5memberLaxmikant_Yadav18 Nov '11 - 0:58 
Greak Work !!!!!
Questionextracting project makefile pathmemberAmy Phillips 74 Nov '11 - 6:17 
Hello Maria,
 
Firstly I'd like to say thank you - I've just been using your tool to generate makefiles and it has saved me hours!
 
I had a problem with some of your code that I don't fully understand:
 
Int32 stripStart = Path.GetDirectoryName(m_SlnFullPath).Length + 1;
Int32 stripLength = m_ProjMakFilePath[projectName].Length - stripStart - 4 - projectName.Length;
String projMakFilePath = m_ProjMakFilePath[projectName].Substring(stripStart, stripLength);
 
When I ran I was getting a negative number in stripLength, which caused Substring to throw an exception. This may be because the proj and sln files are in different directories on my setup. I think the code is trying to get the directory that the project lives in? I changed the code locally to
 
String projMakFilePath = Path.GetDirectoryName(m_ProjMakFilePath[projectName]);
 
Which seems to work for me. If that does what you expect maybe you could fold my change into your code?
 
Cheers,
 
Amy
AnswerRe: extracting project makefile pathmemberMaria Adamsky4 Nov '11 - 11:58 
Hi,
I will not insert your changes in my code, since this tool is more article then released tool that can cover all solution structures. Because there are infinite possibilities to it.
This article was born to show how solution for VS 2005 and 2008 looks like and how it can be translated to Linux makefile. I glad that a lot of people may use this tool as is, but someone need some fixes in my original code in aim to adjust to their projects.
Thank you.
Regards,
Maria.
There is nothing impossible.

QuestionNeed the correct comandmemberMember 81264623 Aug '11 - 19:54 
Hi Maria,
I need to change the project in VS2008 to Linux.
I have the sln file like this a.sln
In the sln file i have projects like this:
b.vcproj---This is a library
a.vcproj--- This is the main dll and it is dependent on all other Library.
c.vcproj---This is a library
d.vcproj---This is a library
 
All the above prjts have relative path in the solution file.
 
I have tried giving
sln2mak -l a.vcproj a.sln
 
I am able to successfully generate the makefile but it is generating only for the main project(a.vcproj) for rest
of the proj(b.vcproj, c.proj and d.vcproj) in not generating.
 
Let me know the correct command line for this ?
giving command
sln2mak a.vcproj -d b c d
 
but it is giving some error for it.
 
Creating file a.mak...
 
Unhandled Exception: System.ArgumentException: The path is not of a legal form.
at System.IO.Path.NormalizePathFast(String path, Boolean fullCheck)
at System.IO.Path.GetDirectoryName(String path)
at sln2mak.VcSlnInfo.iPrintTargetRules() in C:\Codes\sln2mak\sln2mak\sln2mak\
VcSlnInfo.cs:line 271
at sln2mak.VcSlnInfo.GenerateMakefile(Boolean parseVcproj) in C:\Codes\sln2ma
k\sln2mak\sln2mak\VcSlnInfo.cs:line 436
at sln2mak.Parser.CreateMakefile(List`1 projectsList, String[] mainProjectDep
endencies) in C:\Codes\sln2mak\sln2mak\sln2mak\Parser.cs:line 92
at sln2mak.Program.Main(String[] args) in C:\Codes\sln2mak\sln2mak\sln2mak\Pr
ogram.cs:line 115
 
Thanks,
Himanshu.
AnswerRe: Need the correct comandmemberMaria Adamsky3 Aug '11 - 20:44 
Hi,
If your solution has been built like you described, i mean main project has the same name as solution itself and all other libraries are dependencies, so your command line should be like this:
 
sln2mak a.sln
There is nothing impossible.

GeneralRe: Need the correct comandmemberMember 81264623 Aug '11 - 20:56 
Doing this give me following error:
sln2mak a.sln
 
Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given
key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at sln2mak.VcSlnInfo.iPrintDefaultTargetRule()
at sln2mak.VcSlnInfo.GenerateMakefile(Boolean parseVcproj)
at sln2mak.VcSlnInfo.GenerateMakefile()
at sln2mak.Parser.ParseSln(String projName, String slnFName)
at sln2mak.Program.Main(String[] args)
GeneralRe: Need the correct comandmemberMaria Adamsky3 Aug '11 - 21:55 
1)Does sln2mak tool placed within your solution folder?
2)Otherwise, when you call sln2mak a.sln a=full path to your sln?
3)Did you replaced the reference as described here?
If you convert this source code to Visual Studio 2008, please use proper Microsoft.VisualStudio.VCProjectEngine reference version 9.0.0.0 instead of 8.0.0.0.
There is nothing impossible.

GeneralRe: Need the correct comandmemberMember 81264624 Aug '11 - 0:22 
I have put the sln2mak in the sln folder, done the changes of version 9.0.0.0. but same error
 
This is my a.sln file
 
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "b", "..\..\www\b.vcproj", "{49984C9E-831C-45D2-97DE-422ED8A41AED}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "a", "..\a.vcproj", "{1572A4FD-07A6-4351-BCFB-48390D0F0B47}"
ProjectSection(ProjectDependencies) = postProject
{49984C9E-831C-45D2-97DE-422ED8A41AED} = {49984C9E-831C-45D2-97DE-422ED8A41AED}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c", "..\c.vcproj", "{02DCDF92-76AB-43BA-9AC7-B4EE8365C3B5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "d", "..\d.vcproj", "{2F427394-483C-407B-A1D9-61A87E03B053}"
EndProject
Global
GeneralRe: Need the correct comandmemberMaria Adamsky4 Aug '11 - 0:42 
please call to the tool with full path to the sln, otherwise relative path to a ("..\a.vcproj") can not be calculated properly.
There is nothing impossible.

GeneralRe: Need the correct comandmemberMember 81264624 Aug '11 - 0:52 
I am calling the tool with full path of sln.
Do i need to put full path for all the projects mentioned in sln?
GeneralRe: Need the correct comandmemberMaria Adamsky4 Aug '11 - 1:05 
No.
There is nothing impossible.

GeneralRe: Need the correct comandmemberMember 81264624 Aug '11 - 1:12 
one more thing i am getting exception(System.Collections.Generic.KeyNotFoundException)at this line:
(d < m_ProjDependencies[m_MainProjectName].Length)
while running like this
sln2mak a.sln
GeneralRe: Need the correct comandmemberMaria Adamsky4 Aug '11 - 1:26 
As i remember, i assumed that the main project always placed in the same folder as .sln. In your case a placed in relative path. Please, try to debug the tool and fix the bug or change your solution to be as assumed.
I hope it will help.
There is nothing impossible.

GeneralRe: Need the correct comandmemberMember 81264624 Aug '11 - 2:43 
I have the main file name as CPa.vcproj rest sln mentioned previously is same
 
and I am giving :
sln2mak -l CPa "Full_Path\a.sln
 
and it is genarting the Makefile and a.mak but not generating b.mak , c.mak is this the bug in tool or I am not giving the correct command.
 
Thanks,
Himanshu.
GeneralRe: Need the correct comandmemberMaria Adamsky4 Aug '11 - 2:57 
the command is right and creation of Makefiel and a.mak is right.
in aim to create b.mak and c.mak they should be dependencies of a within a.vcproj.
There is nothing impossible.

QuestionIssue when using with VS2005memberMember 22164234 Jul '11 - 3:58 
Hi,
 
I tried using the tool and I get following issues (on Windows 7, x86, VS 2005).
'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll while executing from sources.
 
From command line, I get:
 
Unhandled Exception: System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class f
actory for component with CLSID {FBBF3C66-2428-11D7-8BF6-00B0D03DAA06} failed due to the following error:
80040154.
at sln2mak.VcProjInfo..ctor(String vcProjFile, String outFile, String[] projDependencies) in at sln2mak.Program.Main(String[] args) in ..\sln2mak\sln2mak\Program.cs:line 109
 
Can you please suggest any solution? The exact format to use command was followed with no dependency.
 
Regards,
Swapneel.
AnswerRe: Issue when using with VS2005memberMaria Adamsky4 Jul '11 - 6:54 
Hi,
In aim to suggest you a proper command line, please send me a command line you use and explain how your solution is build.
Regards,
Maria.
There is nothing impossible.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Comment 232 messages have been posted for this article Visit http://www.codeproject.com/Articles/28908/Tool-for-Converting-VC-2005-Project-to-Linux-Makef to post and view comments on this article, or click here to get a print view with messages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130513.1 | Last Updated 13 Jul 2012
Article Copyright 2008 by Maria Adamsky
Everything else Copyright © CodeProject, 1999-2013
Terms of Use