Author Topic: Problem with headers/search directories  (Read 14594 times)

CBuser

  • Guest
Problem with headers/search directories
« on: July 09, 2007, 07:48:35 pm »
I think the problem is with my understanding of how the compiler and/or CB handles headers and search directories.  Now for some background.  I'm attempting to migrate from Dev-C++, which is the only IDE I've really used in the past couple or so years.  Today I downloaded and installed Code::Blocks nightly build 4235.  The default compiler is set as 'Cygwin GCC' (installed in "D:\cygwin"), which CB detected automatically.  I'm attempting to create projects for my old C files that I had projects for in Dev-C++.  In one project, a 'generic' DLL, an early setup of CB resulted in a successful compile.  After compiling, I attempted to add a compiler 'search directory' entry to point to the Microsoft Platform SDK include directory (as this will be necessary with some of my other projects), with a path of "D:\Program Files\Microsoft SDK\include".  When I attempted to re-build my project, I was deluged with build errors, the first of which are shown below.

Compiling: generic.c
In file included from D:/c/genericdll/generic.c:2:
D:/Program Files/Microsoft SDK/include/windows.h:157:19: excpt.h: No such file or directory
In file included from D:/Program Files/Microsoft SDK/include/winnt.h:116,
                 from D:/Program Files/Microsoft SDK/include/windef.h:166,
                 from D:/Program Files/Microsoft SDK/include/windows.h:161,
                 from D:/c/genericdll/generic.c:2:

This leads me to my first question.  Why is the compiler trying to use the windows.h in my PSDK directory, instead of the default Cygwin directory that was used previously?  I found the "excpt.h" file in two primary locations, "D:\Program Files\Microsoft SDK\src\crt" and "D:\cygwin\usr\include\mingw".  If I add "D:\cygwin\usr\include\mingw" as a search directory, subsequent build attempts spew out many more errors, the first two of which are shown below.

Compiling: generic.c
In file included from D:/Program Files/Microsoft SDK/include/windef.h:166,
                 from D:/cygwin/usr/include/mingw/excpt.h:20,
                 from D:/Program Files/Microsoft SDK/include/windows.h:157,
                 from D:/c/genericdll/generic.c:2:
D:/Program Files/Microsoft SDK/include/winnt.h:237:1: warning: "_cdecl" redefined
<built-in>:77:1: warning: this is the location of the previous definition
D:/Program Files/Microsoft SDK/include/winnt.h:674:2: #error Must define a target architecture.

If I replace the "D:\cygwin\usr\include\mingw" search directory with "D:\Program Files\Microsoft SDK\src\crt", subsequent build attempts again results with a flood of errors, the first two of which are shown below.

Compiling: generic.c
In file included from D:/c/genericdll/generic.c:1:
D:/Program Files/Microsoft SDK/src/crt/stdio.h:23:2: #error ERROR: Only Win32 target supported!
D:/Program Files/Microsoft SDK/src/crt/stdio.h:31:2: #error ERROR: Use of C runtime library internal header file.
In file included from D:/Program Files/Microsoft SDK/src/crt/stdio.h:47,
                 from D:/c/genericdll/generic.c:1:
D:/Program Files/Microsoft SDK/src/crt/cruntime.h:27:2: #error ERROR: Use of C runtime library internal header file.

What am I doing wrong?  I didn't change any of my code, I simply added a search path for future use which has resulted in an inability to build my project.  I don't understand what's going on here.  In my Dev-C++ installation (no longer installed), I setup my project with a 'Library Directory' of "D:\Program Files\Microsoft SDK\Lib" and an 'Include Directory' of "D:\Program Files\Microsoft SDK\include", and all was well (no problems building the project).

Please help a poor confused noob.  Any input would be appreciated.


Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Problem with headers/search directories
« Reply #1 on: July 09, 2007, 10:18:14 pm »
project and compiler paths take precedence over the default mingw search paths. your new includes have overlapping filenames with the default includes. is it even possible to compile against the MS SDK with cygwin gcc?
« Last Edit: July 09, 2007, 10:43:57 pm by dmoore »

CBuser

  • Guest
Re: Problem with headers/search directories
« Reply #2 on: July 09, 2007, 10:24:42 pm »
Well, as I said, Dev-C++ was able to compile this same c file (under a Dev-C++ project dedicated to just this file) with the PSDK header/lib directories included in the project.
D:\Dev-Cpp\bin\gcc --version shows "gcc (GCC) 3.4.2 (mingw-special)"
« Last Edit: July 09, 2007, 10:30:06 pm by CBuser »

Offline raph

  • Almost regular
  • **
  • Posts: 242
Re: Problem with headers/search directories
« Reply #3 on: July 09, 2007, 10:32:06 pm »
I would use mingw as compiler (like dev-c++ did).
You don't need Microsoft's psdk.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Problem with headers/search directories
« Reply #4 on: July 09, 2007, 10:39:20 pm »
you might need to reorder your search directories. what do your project and compiler search paths currently look like?

CBuser

  • Guest
Re: Problem with headers/search directories
« Reply #5 on: July 09, 2007, 10:47:07 pm »
I would use mingw as compiler (like dev-c++ did).
You don't need Microsoft's psdk.

I'm not a professional programmer; on the contrary, I'm pretty much a novice who writes small C programs for himself.  I will be using the Windows Update Agent API in this project, eventually.  According to my interpretation of MSDN documentation, PSDK is necessary for usage of the Windows Update Agent API; if I'm wrong in my interpretation, could you link me to any web pages that will guide me on usage of this API without linking to the PSDK?

CBuser

  • Guest
Re: Problem with headers/search directories
« Reply #6 on: July 09, 2007, 10:50:45 pm »
you might need to reorder your search directories. what do your project and compiler search paths currently look like?

Correction: My project has a single search directory entry "D:\psdk\wua_api_headers_i386" and my compiler has a single entry "D:\Program Files\Microsoft SDK\include".  I also added "D:\Program Files\Microsoft SDK\Lib" as a compiler search directory for testing, but this didn't seem to help.
« Last Edit: July 09, 2007, 11:07:13 pm by CBuser »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Problem with headers/search directories
« Reply #7 on: July 09, 2007, 10:59:24 pm »
did you try setting the project search directory to "D:\Program Files\Microsoft SDK\include"
and leaving the compiler search directory as "D:\cygwin\usr\include\mingw" (or whatever the default compiler search path is)
(I assume this is how it is in your Dev-CPP setup -- If it is different, post the differences.)

note that the project dirs get priority over the compiler dirs.

NB: you can post the project files if they are small enough. they get deleted by the mods pretty quickly.

CBuser

  • Guest
Re: Problem with headers/search directories
« Reply #8 on: July 09, 2007, 11:06:38 pm »
Please note my correction above.  I tried as you suggested:

Compiler:
- D:\cygwin\usr\include\mingw
Project:
- D:\psdk\wua_api_headers_i386
- D:\Program Files\Microsoft SDK\include

First two errors in the build log:

Compiling: generic.c
In file included from D:/Program Files/Microsoft SDK/include/windef.h:166,
                 from D:/cygwin/usr/include/mingw/excpt.h:20,
                 from D:/Program Files/Microsoft SDK/include/windows.h:157,
                 from D:/c/genericdll/generic.c:2:
D:/Program Files/Microsoft SDK/include/winnt.h:237:1: warning: "_cdecl" redefined
<built-in>:77:1: warning: this is the location of the previous definition
D:/Program Files/Microsoft SDK/include/winnt.h:674:2: #error Must define a target architecture.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Problem with headers/search directories
« Reply #9 on: July 09, 2007, 11:09:31 pm »
what are your dev-cpp compiler path settings? tool->compiler options->directories->c includes and ->c++ includes

CBuser

  • Guest
Re: Problem with headers/search directories
« Reply #10 on: July 09, 2007, 11:16:32 pm »
On another computer which has PSDK, Cygwin, and Dev-C++ installed in the same directory paths as this computer (though Dev-C++ doesn't use my Cygwin installation, and I've un-installed Dev-C++ from this computer), my compiler includes are as follows:

C:
- D:\Dev-Cpp\include
C++:
- D:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include
- D:\Dev-Cpp\include\c++\3.4.2\backward
- D:\Dev-Cpp\include\c++\3.4.2\mingw32
- D:\Dev-Cpp\include\c++\3.4.2
- D:\Dev-Cpp\include

Note that my project is setup as a C (not C++) Win32 DLL.

The Dev-C++ project has the following directory entries:
Library:
- D:\Program Files\Microsoft SDK\Lib
- D:\psdk\wua_api_headers_i386
Include:
- D:\Program Files\Microsoft SDK\include
- D:\psdk\wua_api_headers_i386
« Last Edit: July 09, 2007, 11:19:20 pm by CBuser »

CBuser

  • Guest
Re: Problem with headers/search directories
« Reply #11 on: July 10, 2007, 07:44:38 am »
I would use mingw as compiler (like dev-c++ did).
You don't need Microsoft's psdk.

For whatever reason, this is something I over-looked, perhaps because I didn't understand it well.  I'm not sure what the differences are between MinGW and Cygwin, or how to specify MinGW as the compiler.  Currently in CB I have 'Cygwin GCC' selected as the compiler; I don't see any mention of 'MinGW'.  I installed MinGW and tried selecting 'GNU GCC Compiler' as the compiler (not knowing what else to try).  CB was unable to detect my installation of MinGW, so I pointed it there manually ("D:\MinGW"), but buiding results in the error blow.

Compiling: generic.c
mingw32-gcc.exe: installation problem, cannot exec `cc1': No such file or directory

As for Dev-C++, the compiler is set as 'Default compiler', with no other options, therefore I've never tampered with this (it just worked).

Unfortunately, I'm no less confused at this point.  Any ideas?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Problem with headers/search directories
« Reply #12 on: July 10, 2007, 07:59:39 am »

Compiling: generic.c
mingw32-gcc.exe: installation problem, cannot exec `cc1': No such file or directory


That error is common for Windows Vista. What version of windows are you using?

If Vista see link below.

http://wiki.codeblocks.org/index.php?title=Installing_MinGW_with_Vista

Tim S
« Last Edit: July 10, 2007, 08:01:29 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

CBuser

  • Guest
Re: Problem with headers/search directories
« Reply #13 on: July 10, 2007, 08:20:01 am »
I am indeed running Windows Vista on this computer.  Actually, before you posted, I found the cc1.exe file and added it's path as an 'additional path' to the toolchain executables--this resulted in a successful compile.  However, when I added compiler search directory "D:\Program Files\Microsoft SDK\include" to my project, again, I'm flooded with errors.  I then read your post, continued to follow the suggestions provided (manually adding several compiler and linker search directories to the global compiler settings), but the errors I receive when trying to build do not change.

Example of the first couple or so errors:

Compiling: generic.c
In file included from D:/Program Files/Microsoft SDK/include/windef.h:166,
                 from /mingw/include/excpt.h:20,
                 from D:/Program Files/Microsoft SDK/include/windows.h:157,
                 from D:\c\genericdll\generic.c:2:
D:/Program Files/Microsoft SDK/include/winnt.h:674:2: #error Must define a target architecture.
In file included from D:/Program Files/Microsoft SDK/include/windows.h:164,
                 from D:\c\genericdll\generic.c:2:
D:/Program Files/Microsoft SDK/include/winuser.h:10564: warning: declaration does not declare anything
D:/Program Files/Microsoft SDK/include/winuser.h:10569: warning: declaration does not declare anything
In file included from D:/Program Files/Microsoft SDK/include/objbase.h:403,
                 from D:/Program Files/Microsoft SDK/include/ole2.h:69,
                 from D:/Program Files/Microsoft SDK/include/windows.h:207,
                 from D:\c\genericdll\generic.c:2:
D:/Program Files/Microsoft SDK/include/objidl.h:264: error: redefinition of typedef 'IRpcChannelBuffer'

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Problem with headers/search directories
« Reply #14 on: July 10, 2007, 06:20:09 pm »
D:/Program Files/Microsoft SDK/include/winnt.h:674:2: #error Must define a target architecture.

You have to define

_M_IX86

To avoid that error.

Note, I don't have the time to reply any more to this thread.

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