MinGW/MSYS problem with search path

  • Thread starter Thread starter CRGreathouse
  • Start date Start date
  • Tags Tags
    Path Search
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 5K views
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?
 
Physics news on Phys.org
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: