User forums > Using Code::Blocks
Minor error with makefile
Triniti:
Hello,
It is not relevant for many people, but there is something unexpected.
The "Compile single file" with makefile does not work.
To repreat the bug you have to create a HelloWorld project and apply this makefile.
--- Code: ---main.o: main.c
mingw32-gcc.exe -Wall -O2 -c main.c -o main.o
HelloWorld.exe: main.o
mingw32-g++.exe -o HelloWorld.exe main.o -s
--- End code ---
Then right click on file (main.c) to build this file. Codeblocks does not run makefile but run default compiler settings.
I discovered it when I was trying to implement another compiler in codeblocks. I am using codeblocks with PowerPC EABI compiler. I hope to share my compiller settings in the future, when I finished it.
Alex:
Same here.
I installed CB 13.12 yesterday after using 10.05 for years. Today I was trying to find out what might be wrong. It caused me a headache.
I don't think it is only relevant to a few people. It's a very annoying bug which I hope gets fixed as soon as possible.
Fortunately I found 10.05 and installed it again. I will continue to use it.
oBFusCATed:
What command do you expect to get executed?
Alex:
--- Quote from: oBFusCATed on July 28, 2014, 10:00:21 am ---What command do you expect to get executed?
--- End quote ---
That what is set at
Project's build options -> <selected target> -> "Make" commands -> Compile single file
I've usually filled this field with: $make -f $makefile $(ACTIVE_EDITOR_STEM).o to overcome some limitations of CB10.05.
In CB13.12 whatever is in the field it is ignored. Instead this is executed: "g++ -c <inputfile>.c -o .objs\<outputfile>.o" (don't know where the subdirectory .objs comes from, I definitely don't set it somewhere or ever used it).
stahta01:
Patch file that might fix the issue. I am way too tired to be sure this patch is correct.
Tim S.
--- Code: ---Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp (revision 9854)
+++ src/plugins/compilergcc/compilergcc.cpp (working copy)
@@ -2903,10 +2903,29 @@
return -2;
}
if (m_pProject)
- wxSetWorkingDirectory(m_pProject->GetBasePath());
+ {
+ if ( UseMake(m_pProject) )
+ {
+ wxSetWorkingDirectory(m_pProject->GetExecutionDir());
+ return CompileFileWithMake(file, m_pProject, bt); // compile file using custom makefile
+ }
+ else
+ {
+ wxSetWorkingDirectory(m_pProject->GetBasePath());
+ }
+ }
return CompileFileDefault(m_pProject, pf, bt); // compile file using default build system
}
+int CompilerGCC::CompileFileWithMake(const wxString& file, cbProject* project, ProjectBuildTarget* bt)
+{
+ wxString cmd = GetMakeCommandFor(mcCompileFile, project, bt);
+ cmd.Replace(_T("$file"), file);
+ m_CommandQueue.Add(new CompilerCommand(cmd, wxEmptyString, project, bt));
+
+ return DoRunQueue();
+}
+
int CompilerGCC::CompileFileWithoutProject(const wxString& file)
{
// compile single file not belonging to a project
Index: src/plugins/compilergcc/compilergcc.h
===================================================================
--- src/plugins/compilergcc/compilergcc.h (revision 9854)
+++ src/plugins/compilergcc/compilergcc.h (working copy)
@@ -115,6 +115,7 @@
virtual int RebuildWorkspace(const wxString& target = wxEmptyString);
virtual int CompileFile(const wxString& file);
virtual int CompileFileWithoutProject(const wxString& file);
+ virtual int CompileFileWithMake(const wxString& file, cbProject* project, ProjectBuildTarget* bt);
virtual int CompileFileDefault(cbProject* project, ProjectFile* pf, ProjectBuildTarget* bt);
virtual int KillProcess();
virtual bool IsRunning() const;
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version