 |
|
 |
Hi,
Thanks for creating a great tool. However, for me it doesn't (yet) work... When I execute the binary it crashes with the following output:
============================================= sln2mak.exe - Generates a Makefile from a .sln/.vcproj file . c Maria Adamsky (www.EFC.CO.IL)
Creating file 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) =============================================
I downloaded the sources but cannot open them in VC++2008 (9.0). Some forum post here talks about a ".vcproj" file. but I only have a ".csproj" file. Perhaps I need to download the C# version of Express? Any help is appreciated.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
All this sources and binaries were compiled in VC2005 (C#) and accordingly suitable to parse VC2005(C++) projects. You cam convert sln2mak to VC2008, but don't forget to change reference, as described above.
There is nothing impossible.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks for your quick reply. So I'd have to create a C# project in VC# 2008 to recompile right? Does anyone have every converted VC2008 projects. Currently, I'm looking at a different approach, using cmake to manually create the makefile, and then automatically generate a visual c project file for it. Works like a charm! 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hello, has anyone tried building this project in VS2008 under Vista x64?
I have changed Microsoft.VisualStudio.VCProjectEngine to reference version 9.0.0.0 in sln2mak.vcproj as instructed. The project builds fine. Problem is when I run the tool:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in sln2mak.exe
Additional information: Die COM-Klassenfactory für die Komponente mit CLSID {D19A00C4-A7F9-4E14-A5E1-D060B7EB57F3} konnte aufgrund des folgenden Fehlers nicht abgerufen werden: 80040154.
(In English: Retrieving the COM class factory for component with CLSID {blah} failed due to the following error: 80040154.)
I know this has more to do with my system possibly being setup incorrectly than with this project specifically but maybe someone has got some hints?
Things I've checked: I've found the CLSID {D19A00C4-A7F9-4E14-A5E1-D060B7EB57F3} in my registry under HKEY_CLASSES_ROOT\VisualStudio.VCProjectEngine.9.0
I've also found and tried regsvr32'ing these DLLs (as admin): C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.VCProjectEngine.dll C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages\VCProjectEngine.dll C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\VCProjectEngine.dll
I've used a tool to verify the correct installation of Windows SDK 3.5, 2.0
So far no further progress. Any ideas? Thanks for any help y
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Yes, I've got exactly the same error here when running it on Vista x64.
I solved my problem when running configuration on x86 platform. Default is 'Any platform' I think.
Hope it works for you!
/smygarn
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thank you.
Changing the project properties Build->Platform target to x86 instead of Any platform solved it.
y
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
In order to use it, you have to create XML-config for this tool. How are you going to do it? Manually? There is a tool to do it AUTOMATICALY! 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
.. so you have to do it yourself But it's really a great work Maria! Thanks.
Hmm.. I think I found a bug when generating if/endif for configurations, atleast for my sln/vcproj files.
ifeq "$(CFG)" "Release" ... ifndef TARGET TARGET=libcf.a endif ifeq "$(CFG)" "Debug_DLL" .. ifndef TARGET TARGET=cf.dll endif .. endif endif endif endif
the endif should be placed before the next ifeq I think 
Anyone still supporting this tool?
/Stefan
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Great job!
I've applyed path from madiyaan. But there are some issues.
Consider following project structure:
/ + solution.sln +\project1\projec1.vcproj +\project1\projec1.cpp +\project2\projec2.vcproj +\project2\projec2.cpp
Project 1 - lib Project 2 - exe, dependent from Project 1.
Let's generate makefiles! sln2mak -l project2 solution.sln
When we try to make it, we'll face folowing issues:
1. make clean in root directory has no effect 2. project 2 will never buid, as: 2.1 cd project2 was absent, and when make -f project2/project2 is invoked, gcc could not find source files. 2.2 Linker not able to find libproject1.a, as it in project1 directory.
I'we prepared a path for issue 2 (see next post).
modified on Saturday, March 21, 2009 9:46 PM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
There is a path, whitch included changes, made bu Ahmad (see earlier in comments to this article)
diff -u -a -4 -t -r old\sln2mak\VcProjInfo.cs new\sln2mak\VcProjInfo.cs --- old\sln2mak\VcProjInfo.cs Tue Sep 16 12:18:26 2008 +++ new\sln2mak\VcProjInfo.cs Sun Mar 22 03:43:00 2009 @@ -68,8 +68,9 @@ //Init Filters collection m_FileFilterCollection = (IVCCollection)m_VcProj.Filters; + Console.WriteLine("Creating file " + m_MakeFileName + "..."); //Open StreamWriter for writing into makFileName m_MakFWriter = new StreamWriter(m_MakeFileName); m_SRCGroups = "SRCS="; @@ -82,9 +83,9 @@ /****************************************************************/ public void ParseVcproj() { //this specifies the name of the 'rm -f' or equivalent command - string rm = "rm -f"; + string rm = "rm -f -v"; //this specifies the default name for the dependencies file string dependencies = ".dependencies"; string cflags = ""; @@ -123,9 +124,10 @@ { //print else for "$(CFG)" section in case it is not first config in makefile if (0 != m_NumOfConfigs) { - m_MakFWriter.WriteLine("else"); + // fix + //m_MakFWriter.WriteLine("else"); } //print ifeq "$(CFG)" "CONFIG_NAME" m_MakFWriter.WriteLine("ifeq \"$(CFG)\" \"{0}\"", config.ConfigurationName); @@ -220,17 +222,17 @@ m_MakFWriter.WriteLine("\t$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<"); m_MakFWriter.WriteLine(""); m_MakFWriter.WriteLine("%.o: %.cc"); - m_MakFWriter.WriteLine("\t$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $<"); + m_MakFWriter.WriteLine("\t$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<"); m_MakFWriter.WriteLine(""); m_MakFWriter.WriteLine("%.o: %.cpp"); - m_MakFWriter.WriteLine("\t$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $<"); + m_MakFWriter.WriteLine("\t$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<"); m_MakFWriter.WriteLine(""); m_MakFWriter.WriteLine("%.o: %.cxx"); - m_MakFWriter.WriteLine("\t$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $<"); + m_MakFWriter.WriteLine("\t$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<"); m_MakFWriter.WriteLine(""); m_MakFWriter.WriteLine("%.res: %.rc"); m_MakFWriter.WriteLine("\t$(RC) $(CPPFLAGS) -o $@ -i $<"); @@ -432,9 +434,9 @@ option = compTool.PreprocessorDefinitions; if (option != null) { option = option.Replace(";", " -D"); - option = "D" + option; + option = "-D" + option; } else option = ""; @@ -477,17 +479,18 @@ else { libs = ""; } - + for (int i = 0; i < m_VcProjDependencies.Length; i++) { if (m_VcProjDependencies[i].Equals("v_to_c")) { libs += " -LVTOC/i686-RHEL3-gcc-3.2.3/lib -lvtoc "; } else if (!(m_VcProjDependencies[i].Equals("cross_platform"))) { + libs += "-L../" + m_VcProjDependencies[i] + " "; libs += " -l" + m_VcProjDependencies[i] + " "; } } @@ -641,8 +644,10 @@ line = line.Replace("odbc32", ""); line = line.Replace("odbccp32", ""); line = line.Replace("Win32", "Linux"); line = line.Replace("-D_MSC_VER", ""); + // ahmad added + line = line.Replace("WIN32", "LINUX"); m_MakFWriter.WriteLine(line); } m_MakFWriter.Close(); diff -u -a -4 -t -r old\sln2mak\VcSlnInfo.cs new\sln2mak\VcSlnInfo.cs --- old\sln2mak\VcSlnInfo.cs Sat Sep 06 23:01:16 2008 +++ new\sln2mak\VcSlnInfo.cs Sun Mar 22 03:09:13 2009 @@ -41,8 +41,9 @@ { m_MakefileFullPath = "Makefile"; } //Console.WriteLine("Makefile ceated - {0}\n", m_MakefileFullPath); + Console.WriteLine("Creating file " + m_MakefileFullPath + "..."); m_MakefileWriter = new StreamWriter(m_MakefileFullPath) ; m_ProjGuidName = new Dictionary<string,> () ; m_ProjNamePath = new Dictionary<string,> () ; @@ -118,16 +119,18 @@ m_ProjNamePath.Add(matchProjInfo.Groups[2].Value, vcprojPath); //replace .vcproj extention to .mak for makefile name makeFileName = vcprojPath; + makeFileName = makeFileName.Replace(".vcproj", ".mak"); +#if false if (!(Path.GetDirectoryName(m_SlnFullPath).Equals(""))) { //add full path of main project to makefile. makeFileName = Path.GetDirectoryName(m_SlnFullPath) + "\\" + makeFileName; makeFileName = makeFileName.Replace("\\", "/"); } - +#endif //Key = ProjectName , Value = MakeFileName m_ProjMakFilePath.Add(matchProjInfo.Groups[2].Value, makeFileName); } @@ -254,17 +257,18 @@ for (int d = 0; d < m_ProjDependencies[m_MainProjectName].Length; d++) { - pd_tmp = pd_tmp + m_ProjDependencies[m_MainProjectName][d]; + pd_tmp = pd_tmp + " " + m_ProjDependencies[m_MainProjectName][d]; k++; } m_MakefileWriter.WriteLine("{0}:{1}", projectName, pd_tmp); if (!(m_ProjMakFilePath[projectName].Equals(""))) { - m_MakefileWriter.WriteLine("\t$(MAKE) -f {0}", m_ProjMakFilePath[projectName]); + String projMakFilePath = m_ProjMakFilePath[projectName].Substring(0, m_ProjMakFilePath[projectName].Length - 5 - projectName.Length); + m_MakefileWriter.WriteLine("\tcd {0} && $(MAKE) -f {1}", projMakFilePath, projectName + ".mak"); } m_MakefileWriter.WriteLine(); } @@ -275,21 +279,24 @@ String pd_tmp = ""; for (int d = 0; d < m_ProjDependencies[m_MainProjectName].Length; d++) { - if ((!(m_MainProjectName.Equals(projectName )))) + if (!(m_MainProjectName.Equals(projectName))) { for (int k = 0; k < m_ProjDependencies[projectName].Length ; k++) { - pd_tmp = pd_tmp + m_ProjDependencies[projectName][k]; + pd_tmp = pd_tmp + " " + m_ProjDependencies[projectName][k]; } m_MakefileWriter.WriteLine(".PHONY: {0}", projectName); m_MakefileWriter.WriteLine("{0}:{1}", projectName, pd_tmp /*m_ProjDependencies[projectName]*/); if (!(m_ProjMakFilePath[projectName].Equals(""))) { - m_MakefileWriter.WriteLine("\t$(MAKE) -f {0}", m_ProjMakFilePath[projectName]); + //m_MakefileWriter.WriteLine("\t$(MAKE) -f {0}", m_ProjMakFilePath[projectName]); + // ahmad changed this. + String projMakFilePath = m_ProjMakFilePath[projectName].Substring(0, m_ProjMakFilePath[projectName].Length - 5 - projectName.Length); + m_MakefileWriter.WriteLine("\tcd {0} && $(MAKE) -f {1}", projMakFilePath, projectName+".mak"); } m_MakefileWriter.WriteLine(); } }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, Thank you for your work and comments. In this message i can't understand what is original source and where are your changes, could you send me source after your changes to mail: maria.adamsky@gmail.com and i'will upload it later? Thanks in advance. Maria.
There is nothing impossible.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Check you mail!
There is instruction to apply patch for others:
1. Make sure you have "patch" utility. It's a GNU utility, and it defenitely exist on any *nix machine. If you run Windows, you can download it there: http://unxutils.sourceforge.net/[^] And add path, where you install it to PATH env. variable. 2. Go to the directory, where is .sln file located. 3. Copy-paste patch content to some file in this directory. Say, "sln2mak_botan.patch" 4. Execute the folowing command
patch -p1 -l -u -b -i sln2mak_botan.patch
That's all.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Fixes just have been uploaded, i'll appreciate if you can test a new version Thanks again!
There is nothing impossible.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
The information around this tool sounds promising, but I now wonder if it would be possible to make a binary version available that could be used without the whole VS setup.
I'd just like to give it a little test run, but I really don't want to download and install many hundred MB to potentially get it to work. I've got .NET 2.0, but I don't have VS 2005. Therefore any additional DLL files would need to be included as well.
Many thanks.
Cheers Martin
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
I'll do my best to do it as soon as possible, since i don't have VS2005 at home, and at work i don't have a time
There is nothing impossible.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
I used this tool on a project of mine. I got a few problems:
1. Issues with misplaced "else" in the Makefile. There were at least 2-3 "else" statements in the Makefile that should not have been there. 2. Issues with changing the directory. From the top-level, make enters the wrong directory before executing make -f . For example, if my solution has 2 projects, with the main makefile in one of the projects, it should enter the second project directory and execute make -f second_project_makefile. It does not enter the second project's directory... rather, it re-enters the old project's directory. 3. Some rules in the makefile have both -o and -c option, which gcc does not support at the same time.
Currently I am debugging these issues. Might post again with more details as I make further progress.
Great work, Maria!
If I make further progress or fix bugs, I will post here again.
modified on Friday, January 9, 2009 10:05 PM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, Thank you for feedback. 1. Known issue, i had no time to fix it. I promise to fix it ASAP. 2. and 3. require rechecking.
I'll really appreciate if you could post here further progress or fix bugs.
Thanks a lot. Regards, Maria
There is nothing impossible.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I looked at the source and thankfully it is pretty well organized. I created this patch which you can find below. Some things I am not sure why are there, but I commented and it worked for me. Please have a look at the patch below see what changes I made.
1. Added some spaces in dependencies. 2. Removed a loop which was creating multiple rules for a single project, which I don't think was needed. 3. Added uppercase WIN32 to be replaced by uppercase LINUX. 4. Removed -o option for cpp files. 5. Removed printing of "else" (I am not sure why this was needed in the first place).
The flushes I added just for debugging.
Your project now works for me.
Left base folder: C:\work\sln2mak_orig\sln2mak Right base folder: C:\work\sln2mak
File: sln2mak\VcProjInfo.cs 127c127 < m_MakFWriter.WriteLine("else"); --- > // m_MakFWriter.WriteLine("else"); 218a219 > // AHMAD 228c229,230 < m_MakFWriter.WriteLine("\t$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $<"); --- > //m_MakFWriter.WriteLine("\t$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $<"); > m_MakFWriter.WriteLine("\t$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<"); 436c438,439 < option = "D" + option; --- > // ahmad fixed this. > option = "-D" + option; 644c647,649 < line = line.Replace("-D_MSC_VER", ""); --- > line = line.Replace("-D_MSC_VER", ""); > // ahmad added > line = line.Replace("WIN32", "LINUX");
File: sln2mak\VcSlnInfo.cs 122a123,125 > #if false > // Ahmad added this to make sure it is relative path-ed for most compatiblity > // with linux builds. c:\ doesn't work really well with linux. 128a132 > #endif 257,258c261,262 < < pd_tmp = pd_tmp + m_ProjDependencies[m_MainProjectName][d]; --- > // ahmad added space here. > pd_tmp = pd_tmp + " "+ m_ProjDependencies[m_MainProjectName][d]; 271a276,277 > // ahmad added > m_MakefileWriter.Flush(); 277c283,284 < for (int d = 0; d < m_ProjDependencies[m_MainProjectName].Length; d++) --- > // ahmad: I don't think this loop is required. > //for (int d = 0; d < m_ProjDependencies[m_MainProjectName].Length; d++) 283c290,291 < pd_tmp = pd_tmp + m_ProjDependencies[projectName][k]; --- > // ahmad: Spaces should be added after names. > pd_tmp = pd_tmp + " "+ m_ProjDependencies[projectName][k]; 291c299,302 < m_MakefileWriter.WriteLine("\t$(MAKE) -f {0}", m_ProjMakFilePath[projectName]); --- > // ahmad: I think this is more robust (at least works for projects I have). > String projMakFilePath = m_ProjMakFilePath[projectName].Substring(0, m_ProjMakFilePath[projectName].Length - 4 - projectName.Length); > // ahmad changed this. > m_MakefileWriter.WriteLine("\tcd {0} && $(MAKE) -f {1}", projMakFilePath, projectName+".mak"); 297a309,310 > // ahmad added flush > m_MakefileWriter.Flush();
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |