Author Topic: CB ignores search directories/Global variables  (Read 24308 times)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: CB ignores search directories/Global variables
« Reply #15 on: January 20, 2012, 10:56:10 pm »
OK you win.  I'm switching back to non-cygwin headers/libs BUT this codeBlocks problem is still a problem!


Note: I was wrong about you using the Cygwin Compiler. You are trying to use the MinGW-64 compiler that was modified by the Cywgin group to work in the Cygwin environment. This is more likely to work.

But, a problem is that Code::Blocks does not work that well the Cygwin GCC as compared to MinGW GCC.

NOTE: A question I forgot to ask are you using Windows 64-bit OS; because I think the version of MinGW-64 you are using requires that to be true.

Tim S.
« Last Edit: January 20, 2012, 10:57:58 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline eb

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: CB ignores search directories/Global variables
« Reply #16 on: January 21, 2012, 01:37:36 am »
2 things:
  1- I'm on XP-64bit and this program is for machines running 7-64bit.

  2-I started another new project but in a new folder and CodeBlocks Search directories settings seemed to work fine.  But when I came back to this project and switched back to Cygwin GCC the compiler is once again searching the directories of the previous project even though I have changed the default compiler and search directories.

Does this sound familiar?
Is this a bug?

edit: To re-cap:
  Search directories:
    C:\cygwin\home\eb\rap02
    C:\cygwin\usr\include

  yet Open #include file: 'rpc/clnt.h' opens "C:\rap02\include\glibc\rpc\rpc.h".
  C:\rap02\include\glibc is the search directory from the previous project.
« Last Edit: January 21, 2012, 01:42:36 am by eb »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: CB ignores search directories/Global variables
« Reply #17 on: January 21, 2012, 02:53:47 am »
There is two major places to change the search directories.

The compiler settings and the project/task settings.

You likely have only fixed one of them.

NOTE: I had to add the Cygwin include folder to search list for rpc.h to be found.

You will need to change "C:\GreenApps\Cygwin1_7" to "C:\cygwin"

I added include search folder "C:\GreenApps\Cygwin1_7\usr\include\tirpc"

Edit: This might work also "$(TARGET_COMPILER_DIR)\usr\include\tirpc".

My build command. Updated because I saw two search folders removed one.
Code
i686-pc-cygwin-gcc-4.exe -Wall  -g    -IC:/GreenApps/Cygwin1_7/usr/include/tirpc  -c H:/SourceCode/Projects/test-i686-w64/main.c -o obj/Debug/main.o
i686-pc-cygwin-g++-4.exe  -o bin/Debug/test-i686-w64.exe obj/Debug/main.o    -ltirpc

Note: "H:/SourceCode/Projects/test-i686-w64" is my project folder.

Tim S.
« Last Edit: January 21, 2012, 03:21:15 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: CB ignores search directories/Global variables
« Reply #18 on: January 21, 2012, 03:28:18 am »
I have decided that using the real Cygwin GCC likely works; but, trying to use the MinGW GCC versions are not possible for me to do. So, if you try the CygWin option I will help from time to time. But, the MinGW GCC is not worth any more effort on my part. Next post please include your Code::Blocks version; I am guessing it is 10.05.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline eb

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: CB ignores search directories/Global variables
« Reply #19 on: February 16, 2012, 08:06:23 pm »
Yes CodeBlocks 10.05
Windows XP Pro x64

Turns out both the compiler AND search directories problems are connected
For some reason now and then CodeBlocks ignores my Selected compiler and all of it's settings.
Currently no matter which Selected compiler I pick it will only use the Cygwin GCC settings.
I even set MinGW GCC as default, saved everything, closed/opened CodeBlocks, confirmed that MinGW GCC was my selected compiler, rebuilt the workspace, and it's still using my cygwin settings for Search directories and compilers.  Even double checked to confirm that my selected compiler was still MinGW.
I also confirmed the location of the files.
fyi - the difference between my MinGW settings and my Cygwin settings is the MinGW Search directories are under my c:\MingW directory.  My MinGW compilers are the ones in the c:\cygwin\bin directory with the default cygwin compiles.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: CB ignores search directories/Global variables
« Reply #20 on: February 16, 2012, 08:16:26 pm »
YOU Verified the CB project is using the correct compiler for ALL targets in ALL projects!
Is this correct?

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline eb

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: CB ignores search directories/Global variables
« Reply #21 on: February 16, 2012, 08:44:16 pm »
No, I'm saying that my compiler is doing this:
Quote
-------------- Build: Release in rap00 ---------------

gcc-3.exe -Wall  -O2    -IC:/cygwin/usr/include/tirpc -IC:/cygwin/usr/include -IC:/cygwin/home/eb/rap00 -IC:/cygwin/home/eb/rap00 -c C:/cygwin/home/eb/rap00/main.c -o obj/Release/main.o
g++-3.exe  -o bin/Release/rap00.exe obj/Release/main.o    C:/cygwin/lib/libtirpc.a C:/cygwin/Varkon_1.19D/sources/EX/lib/EXlib.a
Output size is 116.86 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings

Where my code blocks settings say it should be doing something more like this:

Quote
-------------- Build: Release in rap00 ---------------

mingw32-g++.exe -Wall  -O2    -IC:/MinGW/lib/gcc/mingw32/4.6.2/include -IC:/mingw/include/bits -IC:/mingw/lib/gcc/mingw32/4.6.2/include/c++/parallel -IC:/mingw/home/eb/rap00 -IC:/mingw/home/eb/rap00 -c C:/mingw/home/eb/rap00/main.c -o obj/Release/main.o
mingw32-g++-3.exe  -o bin/Release/rap00.exe obj/Release/main.o    C:/MinGW/lib/librpcrt4.a C:/cygwin/Varkon_1.19D/sources/EX/lib/EXlib.a C:/MinGW/lib/libmingw32.a C:/MinGW/lib/gcc/mingw32/4.6.2/libstdc++.a  
Output size is 116.86 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings

And yes I know I'm mixing libraries and compilers again (I just caught that) and it will probably fail, but that's not the point.
« Last Edit: February 16, 2012, 08:48:03 pm by eb »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: CB ignores search directories/Global variables
« Reply #22 on: February 16, 2012, 09:11:46 pm »
@devs:
I'm thinking of adding the compiler name in the build log. What do you think about it?

How about this patch? Is it correct?
Code
Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp     (revision 7807)
+++ src/plugins/compilergcc/compilergcc.cpp     (working copy)
@@ -1535,23 +1535,22 @@
     if (action ==  baClean)
         Action = _("Clean");
 
+    wxString compilerName(_("unknown"));
+    Compiler *compiler = CompilerFactory::GetCompiler(GetCurrentCompilerID(target));
+    if (compiler)
+        compilerName = compiler->GetName();
+
+#if wxCHECK_VERSION(2, 9, 0)
+    wxString targetName = target ? target->GetTitle().wx_str() : _("\"no target\"").wx_str();
+    wxString projectName = prj ? prj->GetTitle().wx_str() : _("\"no project\"").wx_str();
+#else
+    wxString targetName = target ? target->GetTitle().wx_str() : _("\"no target\"");
+    wxString projectName = prj ? prj->GetTitle().wx_str() : _("\"no project\"");
+#endif
+
     wxString banner;
-    banner.Printf(_("-------------- %s: %s in %s ---------------"),
-                    Action.wx_str(),
-                    target
-                        ? target->GetTitle().wx_str()
-                    #if wxCHECK_VERSION(2, 9, 0)
-                        : _("\"no target\"").wx_str(),
-                    #else
-                        : _("\"no target\""),
-                    #endif
-                    prj
-                        ? prj->GetTitle().wx_str()
-                    #if wxCHECK_VERSION(2, 9, 0)
-                        : _("\"no project\"").wx_str() );
-                    #else
-                        : _("\"no project\"") );
-                    #endif
+    banner.Printf(_("-------------- %s: %s in %s (compiler: %s)---------------"),
+                  Action.wx_str(), targetName.wx_str(), projectName.wx_str(), compilerName.wx_str());
     LogMessage(banner, cltNormal, ltAll, false, true);
 }
 
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CB ignores search directories/Global variables
« Reply #23 on: February 17, 2012, 01:19:33 am »
@devs:
I'm thinking of adding the compiler name in the build log. What do you think about it?

How about this patch? Is it correct?
Code
Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp     (revision 7807)
+++ src/plugins/compilergcc/compilergcc.cpp     (working copy)
@@ -1535,23 +1535,22 @@
     if (action ==  baClean)
         Action = _("Clean");
 
+    wxString compilerName(_("unknown"));
+    Compiler *compiler = CompilerFactory::GetCompiler(GetCurrentCompilerID(target));
+    if (compiler)
+        compilerName = compiler->GetName();
+
+#if wxCHECK_VERSION(2, 9, 0)
+    wxString targetName = target ? target->GetTitle().wx_str() : _("\"no target\"").wx_str();
+    wxString projectName = prj ? prj->GetTitle().wx_str() : _("\"no project\"").wx_str();
+#else
+    wxString targetName = target ? target->GetTitle().wx_str() : _("\"no target\"");
+    wxString projectName = prj ? prj->GetTitle().wx_str() : _("\"no project\"");
+#endif
+
     wxString banner;
-    banner.Printf(_("-------------- %s: %s in %s ---------------"),
-                    Action.wx_str(),
-                    target
-                        ? target->GetTitle().wx_str()
-                    #if wxCHECK_VERSION(2, 9, 0)
-                        : _("\"no target\"").wx_str(),
-                    #else
-                        : _("\"no target\""),
-                    #endif
-                    prj
-                        ? prj->GetTitle().wx_str()
-                    #if wxCHECK_VERSION(2, 9, 0)
-                        : _("\"no project\"").wx_str() );
-                    #else
-                        : _("\"no project\"") );
-                    #endif
+    banner.Printf(_("-------------- %s: %s in %s (compiler: %s)---------------"),
+                  Action.wx_str(), targetName.wx_str(), projectName.wx_str(), compilerName.wx_str());
     LogMessage(banner, cltNormal, ltAll, false, true);
 }
 
The last wx_str() of this line is necessary?
Code
wxString targetName = target ? target->GetTitle().wx_str() : _("\"no target\"").wx_str();
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: CB ignores search directories/Global variables
« Reply #24 on: February 17, 2012, 08:33:28 am »
Yes, in wx29 it is necessary.

Edit:

Code
    wxString targetName = target ? target->GetTitle() : wxString(_("\"no target\""));
    wxString projectName = prj ? prj->GetTitle() : wxString(_("\"no project\""));
But this version works in both 2.8 and 2.9.
« Last Edit: February 17, 2012, 09:33:35 am by oBFusCATed »
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CB ignores search directories/Global variables
« Reply #25 on: February 17, 2012, 10:06:00 am »
How about this patch? Is it correct?
Looks good to me and will hopefully help us to trace user errors more easily.

BTW: The patch you've applied in the debugger branch concerning CB_LIBRARY_ENVVAR should probably had made it into trunk first and then merged into the branch. Do you mind to apply this in trunk, too?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: CB ignores search directories/Global variables
« Reply #26 on: February 17, 2012, 10:20:16 am »
Do you mind to apply this in trunk, too?
No, but I'm not sure if I can merge it properly. Can you do it for me?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CB ignores search directories/Global variables
« Reply #27 on: February 17, 2012, 12:57:27 pm »
No, but I'm not sure if I can merge it properly. Can you do it for me?
Did it, but made a mistake in the log: It should read 7743 and not 6643. :-(

Unfortunately we don't have a pre-revprop-change hook in place. :-(
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline eb

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: CB ignores search directories/Global variables
« Reply #28 on: February 17, 2012, 08:04:50 pm »
So does this mean there is a new build I should try?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: CB ignores search directories/Global variables
« Reply #29 on: February 17, 2012, 09:14:10 pm »
If you've not tried the nightly builds, then yes there is a new build, but I doubt it will help.
You have some configuration problem.

I just hijacked your topic and I'm sorry about it.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]