MinGW/MSYS problem with search path

In summary: 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 withgcc blah.c -o blah -I /usr/local/include -L /usr/local/lib -lgmprather than simply
  • #1
CRGreathouse
Science Advisor
Homework Helper
2,844
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
  • #2
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:
  • #3
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:

Related to MinGW/MSYS problem with search path

What is MinGW/MSYS?

MinGW/MSYS is a development environment for creating native Windows applications. It includes a set of open source tools and libraries that allow developers to compile and run C and C++ code on a Windows operating system.

What is the "search path" problem with MinGW/MSYS?

The "search path" problem with MinGW/MSYS refers to an issue where the development environment is unable to locate the necessary files and libraries needed to compile and run code. This can happen when the search path, which is a list of directories that the system checks for files, is not properly configured.

How can I fix the search path problem with MinGW/MSYS?

To fix the search path problem with MinGW/MSYS, you will need to add the necessary directories to the search path. This can be done by modifying the PATH environment variable or by manually specifying the directories in the development environment's settings.

What are some common causes of the search path problem with MinGW/MSYS?

The search path problem with MinGW/MSYS can be caused by a variety of factors, such as incorrect installation of MinGW/MSYS, outdated or missing system files, or incorrect configuration of the PATH environment variable.

Are there any resources available to help troubleshoot the search path problem with MinGW/MSYS?

Yes, there are many online resources available to help troubleshoot the search path problem with MinGW/MSYS. These include official documentation, forums, and community support groups where developers can ask for assistance and find solutions to common issues.

Similar threads

  • Programming and Computer Science
Replies
14
Views
1K
  • Programming and Computer Science
Replies
5
Views
1K
Replies
5
Views
2K
  • Programming and Computer Science
Replies
12
Views
6K
  • Programming and Computer Science
Replies
4
Views
7K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
2
Views
5K
  • Programming and Computer Science
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
5K
  • Programming and Computer Science
Replies
15
Views
5K
Back
Top