MinGW/MSYS problem with search path

  • Thread starter Thread starter CRGreathouse
  • Start date Start date
  • Tags Tags
    Path Search
Click For Summary
The discussion centers on troubleshooting issues with MinGW/MSYS while compiling software on a Windows machine. The user successfully compiled the GMP library but encountered errors related to missing header files, specifically gmp.h. The problem was traced to incorrect search directories, which required explicit inclusion of paths during compilation. The user sought a more efficient solution for managing these paths without altering every gcc command in the makefile. Suggestions included modifying the GCC Specs File to automate the inclusion of necessary options and utilizing environment variables like CPATH, C_INCLUDE_PATH, or CPLUS_INCLUDE_PATH to set search directories globally. Additionally, setting CFLAGS and LDFLAGS with the appropriate include paths was recommended as a potential workaround.
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:
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

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
2K
  • · Replies 15 ·
Replies
15
Views
5K
Replies
3
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K