MinGW/MSYS problem with search path

  • Thread starter Thread starter CRGreathouse
  • Start date Start date
  • Tags Tags
    Path Search
Click For Summary
SUMMARY

The discussion focuses on resolving issues with MinGW/MSYS related to search paths for header files when compiling software. The user successfully compiled GMP but encountered errors due to missing gmp.h. The solution involves modifying the GCC command to include specific directories using the -I and -L flags. Additionally, setting environment variables such as CPATH, C_INCLUDE_PATH, or CPLUS_INCLUDE_PATH can automate the inclusion of these directories for all GCC invocations, streamlining the build process.

PREREQUISITES
  • Familiarity with GCC command-line options
  • Understanding of MinGW/MSYS environment on Windows
  • Basic knowledge of Makefile structure and variables
  • Experience with setting environment variables in Windows
NEXT STEPS
  • Research how to customize GCC Specs File for automatic include paths
  • Learn about setting CPATH, C_INCLUDE_PATH, and CPLUS_INCLUDE_PATH environment variables
  • Explore advanced Makefile techniques for managing compiler flags
  • Investigate the use of CFLAGS and LDFLAGS for project-specific configurations
USEFUL FOR

Developers working with C/C++ on Windows, particularly those using MinGW/MSYS for compiling software and managing dependencies.

CRGreathouse
Science Advisor
Homework Helper
Messages
2,832
Reaction score
0
Since my plans for a Linux system are on hold, I'm trying to shore up my Windows machine to do some calculations.

I've been having trouble with MinGW/MSYS lately. I was able to compile GMP, but wasn't able to do anything with it -- anything I did gave me error messages saying it couldn't find gmp.h. (And yes, I did a make install.)

After searching through the settings, I found that it was nothing more than a problem with my search directories: if I compiled with
Code:
gcc blah.c -o blah -I /usr/local/include -L /usr/local/lib -lgmp
rather than simply
Code:
gcc blah.c -o blah -lgmp
it worked properly. But when I'm making a large piece of software, I can't just change all gcc command lines in the makefile -- I don't even know how half the thing works, let alone how to properly modify it.

This seems like a problem with a simple solution, but I haven't been able to find it. I can modify the $PATH to include both directories, but that doesn't work. I tried passing --libdir and --includedir to configure, but that had no apparent effect at all.

Any ideas?
 
Technology news on Phys.org
See http://www.mingw.org/wiki/IncludePathHOWTO
It doesn't look like there is an INCLUDE_PATH or LIBRARY_PATH you can set globally, in a makefile it's normal to have a variable that expands out to these at the top.
 
Last edited:
mgb_phys said:
See http://www.mingw.org/wiki/IncludePathHOWTO
It doesn't look like there is an INCLUDE_PATH or LIBRARY_PATH you can set globally, in a makefile it's normal to have a variable that expands out to these at the top.

Actually, there may be. The page linked says
thus the user must make provision to pass the appropriate "-I DIR", (and associated "-L DIR"), options to GCC, through his own projects' build systems. (This may be mitigated, in turn, by customising the GCC Specs File, to supply the necessary options automatically, for all invocations of GCC, or by appropriately defining GCC's CPATH and related environment variables
and links to http://gcc.gnu.org/onlinedocs/cpp/Environment-Variables.html"

which says

CPATH specifies a list of directories to be searched as if specified with -I, but after any paths given with -I options on the command line. This environment variable is used regardless of which language is being preprocessed.

So setting CPATH (or maybe C_INCLUDE_PATH or CPLUS_INCLUDE_PATH) *should* do it. Alternately, you could try setting CFLAGS and LDFLAGS with the appropriate -I includes.
 
Last edited by a moderator:

Similar threads

  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
5
Views
3K
  • · Replies 12 ·
Replies
12
Views
7K
  • · Replies 3 ·
Replies
3
Views
8K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 15 ·
Replies
15
Views
5K
Replies
3
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K